Built motion from commit aab208717af8d15f4fa224cdb6a202877019af9b. Version 3.0.0...
[motion-next.git] / server / api / analyticCustomReport / analyticCustomReport.controller.js
index c1c9e5c..f3986d6 100644 (file)
@@ -1 +1 @@
-const a5_0x4d7c=['../../config/logger','../../components/parsers/qs','%s-%s.%s','fields','params','findOne','UNIX_TIMESTAMP(%s)','child_process','count','value','%s.%s\x20=\x20%s.%s','DESC','stack','offset','update','startDate','squel','foreignTable','web','debug','groupBy','IS\x20NOT\x20EMPTY','group','foreignKey','../../mysqldb','SELECT','No\x20available\x20data','sort','SUM(%s)','parse','send','lodash','SEC_TO_TIME(%s)','from','path','replace','cross_join','autoAssociation','length','rows','CustomReports','IS\x20NULL','create','condition','Please\x20insert\x20at\x20least\x20one\x20field','run','like','Limited\x20Query:','role','function','type','left_join','util','MetricId','sequelize','joins','catch','cdr','../../components/export/','table','nolimit','select','options','AnalyticCustomReport','generate','Unable\x20to\x20retrieve\x20the\x20current\x20user','merge','where','toString','includes','join','VIRTUAL','fieldName','GROUP_CONCAT(%s)','../../files/reports','UserProfileResource','field','rules','get','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','includeAll','name','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','endDate','HOUR(%s)','AVG(%s)','right_join','MIN(%s)','body','MAX(%s)','savename','filter','DATE(%s)','operator','error','destroy','ROUND(%s)','json','clone','QueryTypes','Content-Range','index','output','then','intersection','include','alias','randomstring','status','sendStatus','findAll','orderBy','COUNT(DISTINCT\x20%s)','attributes','getFields','keys','IS\x20EMPTY','COUNT(*)','map','model','runReport','Reports','rawAttributes','keyBy','info','fork','set','key','format','metric','UserProfileSection','Run\x20Query:','filters','user','order','parentKey','COUNT(%s)','IS\x20NOT\x20NULL','.createdAt\x20BETWEEN\x20?\x20AND\x20?','conditions','AnalyticMetric','countTable','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','limit','query'];(function(_0x537ff9,_0x4d7cf5){const _0x3e3159=function(_0x44d574){while(--_0x44d574){_0x537ff9['push'](_0x537ff9['shift']());}};_0x3e3159(++_0x4d7cf5);}(a5_0x4d7c,0x14c));const a5_0x3e31=function(_0x537ff9,_0x4d7cf5){_0x537ff9=_0x537ff9-0x0;let _0x3e3159=a5_0x4d7c[_0x537ff9];return _0x3e3159;};const _0x3c51b8=a5_0x3e31;'use strict';const util=require(_0x3c51b8('0xa')),path=require(_0x3c51b8('0x89')),_=require(_0x3c51b8('0x86')),squel=require(_0x3c51b8('0x77')),qs=require(_0x3c51b8('0x68')),logger=require(_0x3c51b8('0x67'))('api'),db=require(_0x3c51b8('0x7f'))['db'],dbH=require(_0x3c51b8('0x7f'))['dbH'],{Op,ValidationErrorItem,QueryTypes}=require(_0x3c51b8('0xc'));function respondWithResult(_0x44d574,_0x4af35f){return _0x4af35f=_0x4af35f||0xc8,function(_0x28181b){const _0x3394f9=a5_0x3e31;if(_0x28181b)return _0x44d574[_0x3394f9('0x42')](_0x4af35f)[_0x3394f9('0x37')](_0x28181b);};}function respondWithFilteredResult(_0x36dcce,_0x2ecad0){return function(_0x5265b9){const _0x19b02e=a5_0x3e31;if(_0x5265b9){const _0x30b1cc=_0x5265b9[_0x19b02e('0x6f')],_0x524ffc=_0x2ecad0[_0x19b02e('0x74')];let _0x23f616=_0x2ecad0[_0x19b02e('0x74')]+_0x2ecad0[_0x19b02e('0x65')],_0x54ee3e;return _0x23f616>=_0x30b1cc?(_0x23f616=_0x30b1cc,_0x54ee3e=0xc8):_0x54ee3e=0xce,_0x36dcce[_0x19b02e('0x42')](_0x54ee3e),_0x36dcce[_0x19b02e('0x54')](_0x19b02e('0x3a'),_0x524ffc+'-'+_0x23f616+'/'+_0x30b1cc)[_0x19b02e('0x37')](_0x5265b9);}return null;};}function saveUpdates(_0x59ffd2){return function(_0x3214b1){if(_0x3214b1)return _0x3214b1['update'](_0x59ffd2)['then'](function(_0x3a7ade){return _0x3a7ade;});return null;};}function removeEntity(_0x2bbe35){return function(_0x3609ab){const _0x4352ef=a5_0x3e31;if(_0x3609ab)return _0x3609ab[_0x4352ef('0x35')]()[_0x4352ef('0x3d')](function(){const _0x1790cc=_0x4352ef,_0x5bd3cd=_0x3609ab[_0x1790cc('0x24')]({'plain':!![]}),_0x264e42='CustomReports';return db[_0x1790cc('0x21')]['destroy']({'where':{'type':_0x264e42,'resourceId':_0x5bd3cd['id']}})['then'](function(){return _0x3609ab;});})['then'](function(){const _0x391a80=_0x4352ef;_0x2bbe35[_0x391a80('0x42')](0xcc)['end']();});};}function handleEntityNotFound(_0x38eb56){return function(_0xafa8dd){const _0x17f2ae=a5_0x3e31;return!_0xafa8dd&&_0x38eb56[_0x17f2ae('0x43')](0x194),_0xafa8dd;};}function handleError(_0xff79be,_0x3f231b){return _0x3f231b=_0x3f231b||0x1f4,function(_0x2c5bc7){const _0x593b09=a5_0x3e31;logger[_0x593b09('0x34')](_0x2c5bc7[_0x593b09('0x73')]),_0x2c5bc7[_0x593b09('0x27')]&&delete _0x2c5bc7['name'],_0xff79be['status'](_0x3f231b)[_0x593b09('0x85')](_0x2c5bc7);};}exports[_0x3c51b8('0x3b')]=function(_0xd71a40,_0x45d940){const _0x426140=_0x3c51b8;let _0x2c9585={};const _0x5e480e={},_0x5e00e1={'count':0x0,'rows':[]},_0x4d6995=_[_0x426140('0x4c')](db[_0x426140('0x15')][_0x426140('0x50')],function(_0x4575e1){const _0x41fa67=_0x426140;return{'name':_0x4575e1[_0x41fa67('0x1e')],'type':_0x4575e1['type'][_0x41fa67('0x55')]};});_0x5e480e[_0x426140('0x4d')]=_[_0x426140('0x4c')](_0x4d6995,_0x426140('0x27')),_0x5e480e[_0x426140('0x66')]=_['keys'](_0xd71a40[_0x426140('0x66')]),_0x5e480e[_0x426140('0x5a')]=_['intersection'](_0x5e480e[_0x426140('0x4d')],_0x5e480e['query']),_0x2c9585[_0x426140('0x47')]=_[_0x426140('0x3e')](_0x5e480e['model'],qs[_0x426140('0x6a')](_0xd71a40[_0x426140('0x66')]['fields'])),_0x2c9585[_0x426140('0x47')]=_0x2c9585[_0x426140('0x47')][_0x426140('0x8d')]?_0x2c9585[_0x426140('0x47')]:_0x5e480e[_0x426140('0x4d')];typeof _0xd71a40[_0x426140('0x66')][_0x426140('0x12')]==='undefined'&&(_0x2c9585[_0x426140('0x65')]=qs[_0x426140('0x65')](_0xd71a40[_0x426140('0x66')][_0x426140('0x65')]),_0x2c9585[_0x426140('0x74')]=qs[_0x426140('0x74')](_0xd71a40['query'][_0x426140('0x74')]));_0x2c9585[_0x426140('0x5c')]=qs[_0x426140('0x82')](_0xd71a40[_0x426140('0x66')]['sort']),_0x2c9585[_0x426140('0x19')]=qs[_0x426140('0x5a')](_['pick'](_0xd71a40[_0x426140('0x66')],_0x5e480e[_0x426140('0x5a')]),_0x4d6995);_0xd71a40[_0x426140('0x66')][_0x426140('0x31')]&&(_0x2c9585[_0x426140('0x19')]=_[_0x426140('0x18')](_0x2c9585['where'],{[Op['or']]:_[_0x426140('0x4c')](_0x4d6995,function(_0x1874ea){const _0x318242=_0x426140;if(_0x1874ea[_0x318242('0x8')]!==_0x318242('0x1d')){const _0x2a7508={};return _0x2a7508[_0x1874ea[_0x318242('0x27')]]={[Op[_0x318242('0x4')]]:'%'+_0xd71a40[_0x318242('0x66')][_0x318242('0x31')]+'%'},_0x2a7508;}})}));_0x2c9585=_[_0x426140('0x18')]({},_0x2c9585,_0xd71a40[_0x426140('0x14')]);const _0x30eeda={'where':_0x2c9585['where']};return db[_0x426140('0x15')][_0x426140('0x6f')](_0x30eeda)[_0x426140('0x3d')](function(_0x3ae71e){const _0x3ab419=_0x426140;return _0x5e00e1[_0x3ab419('0x6f')]=_0x3ae71e,_0xd71a40[_0x3ab419('0x66')][_0x3ab419('0x26')]&&(_0x2c9585['include']=[{'all':!![]}]),db[_0x3ab419('0x15')]['findAll'](_0x2c9585);})[_0x426140('0x3d')](function(_0x35dd26){const _0x470bcd=_0x426140;return _0x5e00e1[_0x470bcd('0x8e')]=_0x35dd26,_0x5e00e1;})[_0x426140('0x3d')](respondWithFilteredResult(_0x45d940,_0x2c9585))[_0x426140('0xe')](handleError(_0x45d940,null));},exports['show']=function(_0x4519b6,_0x4a8989){const _0x330266=_0x3c51b8;let _0xfb89c5={'raw':![],'where':{'id':_0x4519b6['params']['id']}};const _0x3a4d8f={};return _0x3a4d8f[_0x330266('0x4d')]=_['keys'](db['AnalyticCustomReport'][_0x330266('0x50')]),_0x3a4d8f[_0x330266('0x66')]=_[_0x330266('0x49')](_0x4519b6[_0x330266('0x66')]),_0x3a4d8f[_0x330266('0x5a')]=_['intersection'](_0x3a4d8f['model'],_0x3a4d8f[_0x330266('0x66')]),_0xfb89c5['attributes']=_[_0x330266('0x3e')](_0x3a4d8f[_0x330266('0x4d')],qs[_0x330266('0x6a')](_0x4519b6[_0x330266('0x66')]['fields'])),_0xfb89c5['attributes']=_0xfb89c5[_0x330266('0x47')]['length']?_0xfb89c5['attributes']:_0x3a4d8f['model'],_0x4519b6['query']['includeAll']&&(_0xfb89c5[_0x330266('0x3f')]=[{'all':!![]}]),_0xfb89c5=_[_0x330266('0x18')]({},_0xfb89c5,_0x4519b6[_0x330266('0x14')]),db['AnalyticCustomReport'][_0x330266('0x6c')](_0xfb89c5)[_0x330266('0x3d')](handleEntityNotFound(_0x4a8989,null))[_0x330266('0x3d')](respondWithResult(_0x4a8989,null))[_0x330266('0xe')](handleError(_0x4a8989,null));},exports['create']=function(_0x15e022,_0x252864){const _0x6079a2=_0x3c51b8;return db[_0x6079a2('0x15')][_0x6079a2('0x0')](_0x15e022[_0x6079a2('0x2e')],{})[_0x6079a2('0x3d')](function(_0x545f48){const _0x52e33d=_0x6079a2,_0x4741e1=_0x15e022[_0x52e33d('0x5b')]['get']({'plain':!![]});if(!_0x4741e1)throw new Error(_0x52e33d('0x17'));if(_0x4741e1[_0x52e33d('0x6')]===_0x52e33d('0x5b')){const _0xc7206b=_0x545f48[_0x52e33d('0x24')]({'plain':!![]}),_0x21736b=_0x52e33d('0x4f');return db[_0x52e33d('0x58')][_0x52e33d('0x6c')]({'where':{'name':_0x21736b,'userProfileId':_0x4741e1['userProfileId']},'raw':!![]})[_0x52e33d('0x3d')](function(_0x238a48){const _0x3b28bd=_0x52e33d;return _0x238a48&&_0x238a48[_0x3b28bd('0x8c')]===0x0?db[_0x3b28bd('0x21')][_0x3b28bd('0x0')]({'name':_0xc7206b[_0x3b28bd('0x27')],'resourceId':_0xc7206b['id'],'type':_0x3b28bd('0x8f'),'sectionId':_0x238a48['id']},{})[_0x3b28bd('0x3d')](function(){return _0x545f48;}):_0x545f48;})[_0x52e33d('0xe')](function(_0x7359cc){const _0x36ee23=_0x52e33d;logger[_0x36ee23('0x34')](_0x36ee23('0x25'),_0x7359cc);throw _0x7359cc;});}return _0x545f48;})[_0x6079a2('0x3d')](respondWithResult(_0x252864,0xc9))['catch'](handleError(_0x252864,null));},exports[_0x3c51b8('0x75')]=function(_0x443202,_0x6bfafb){const _0x166c9b=_0x3c51b8;return _0x443202['body']['id']&&delete _0x443202[_0x166c9b('0x2e')]['id'],db[_0x166c9b('0x15')][_0x166c9b('0x6c')]({'where':{'id':_0x443202['params']['id']}})[_0x166c9b('0x3d')](handleEntityNotFound(_0x6bfafb,null))[_0x166c9b('0x3d')](saveUpdates(_0x443202[_0x166c9b('0x2e')],null))['then'](respondWithResult(_0x6bfafb,null))[_0x166c9b('0xe')](handleError(_0x6bfafb,null));},exports[_0x3c51b8('0x35')]=function(_0x1b58cf,_0x22c96c){const _0x34e55a=_0x3c51b8;return db[_0x34e55a('0x15')][_0x34e55a('0x6c')]({'where':{'id':_0x1b58cf['params']['id']}})[_0x34e55a('0x3d')](handleEntityNotFound(_0x22c96c,null))[_0x34e55a('0x3d')](removeEntity(_0x22c96c,null))[_0x34e55a('0xe')](handleError(_0x22c96c,null));},exports['preview']=function(_0x537c32,_0x2a98ac){const _0x5adfb4=_0x3c51b8,_0x378556=0xa,_0x3abf0f=['join',_0x5adfb4('0x9'),_0x5adfb4('0x2c'),'cross_join'],_0x2978a5={'SUM':_0x5adfb4('0x83'),'COUNT':'COUNT(%s)','COUNT\x20DISTINCT':_0x5adfb4('0x46'),'MAX':'MAX(%s)','MIN':_0x5adfb4('0x2d'),'AVG':_0x5adfb4('0x2b'),'GROUP_CONCAT':_0x5adfb4('0x1f'),'GROUP_CONCAT\x20ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT\x20DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'},_0x36bc6d={'SEC_TO_TIME':_0x5adfb4('0x87'),'DATE':_0x5adfb4('0x32'),'HOUR':'HOUR(%s)','ROUND':_0x5adfb4('0x36'),'UNIX_TIMESTAMP':_0x5adfb4('0x6d')},_0x178b8b=function(_0x3e7083){const _0x2bb294=_0x5adfb4;return!_[_0x2bb294('0x1b')]([_0x2bb294('0x90'),_0x2bb294('0x5f'),_0x2bb294('0x4a'),'IS\x20NOT\x20EMPTY'],_0x3e7083);},_0x3ff2aa=function(_0x4f3816){const _0x35f9f4=_0x5adfb4;if(!_0x4f3816||!_0x4f3816[_0x35f9f4('0x23')][_0x35f9f4('0x8d')])return'';let _0xf9678a='(';for(let _0x209233=0x0;_0x209233<_0x4f3816[_0x35f9f4('0x23')][_0x35f9f4('0x8d')];_0x209233+=0x1){_0x209233>0x0&&(_0xf9678a+='\x20'+_0x4f3816[_0x35f9f4('0x33')]+'\x20'),_0xf9678a+=_0x4f3816[_0x35f9f4('0x23')][_0x209233][_0x35f9f4('0x7d')]?_0x3ff2aa(_0x4f3816[_0x35f9f4('0x23')][_0x209233][_0x35f9f4('0x7d')]):_0x4f3816[_0x35f9f4('0x23')][_0x209233][_0x35f9f4('0x22')]+'\x20'+_0x4f3816[_0x35f9f4('0x23')][_0x209233]['condition']+(_0x178b8b(_0x4f3816[_0x35f9f4('0x23')][_0x209233][_0x35f9f4('0x1')])?'\x20'+_0x4f3816[_0x35f9f4('0x23')][_0x209233][_0x35f9f4('0x70')]:'');}return _0xf9678a+')';};let _0x178aba={'where':{'id':_0x537c32[_0x5adfb4('0x6b')]['id']}},_0x164115,_0x36a231,_0x4f5c4c;return _0x178aba=_[_0x5adfb4('0x18')]({},_0x178aba,_0x537c32[_0x5adfb4('0x14')]),db[_0x5adfb4('0x15')][_0x5adfb4('0x6c')](_0x178aba)['then'](function(_0xf75563){const _0x5cdb36=_0x5adfb4;if(_0xf75563)return _0x164115=_0xf75563,_0xf75563[_0x5cdb36('0x48')]();return null;})[_0x5adfb4('0x3d')](function(_0x1d09dc){const _0x14ed23=_0x5adfb4;if(_0x1d09dc){if(!_0x1d09dc[_0x14ed23('0x8d')])throw new ValidationErrorItem('Please\x20insert\x20at\x20least\x20one\x20field',0x193);return _0x36a231=_0x1d09dc,db[_0x14ed23('0x62')][_0x14ed23('0x44')]({'raw':!![]});}return null;})[_0x5adfb4('0x3d')](function(_0x12cd09){const _0x49ad35=_0x5adfb4;if(_0x12cd09){_0x4f5c4c=_[_0x49ad35('0x51')](_0x12cd09,'id');let _0x10ea64;const _0x461fc6=squel['select']();_0x461fc6[_0x49ad35('0x88')](_0x164115[_0x49ad35('0x11')]);for(let _0xae73ae=0x0;_0xae73ae<_0x36a231[_0x49ad35('0x8d')];_0xae73ae+=0x1){_0x10ea64=_0x36a231[_0xae73ae][_0x49ad35('0xb')]?_0x4f5c4c[_0x36a231[_0xae73ae][_0x49ad35('0xb')]][_0x49ad35('0x57')]:_0x36a231[_0xae73ae][_0x49ad35('0x22')],_0x10ea64=_0x36a231[_0xae73ae][_0x49ad35('0x7')]?_[_0x49ad35('0x8a')](_0x2978a5[_0x36a231[_0xae73ae][_0x49ad35('0x7')]],'%s',_0x10ea64):_0x10ea64,_0x10ea64=_0x36a231[_0xae73ae][_0x49ad35('0x56')]?_[_0x49ad35('0x8a')](_0x36bc6d[_0x36a231[_0xae73ae]['format']],'%s',_0x10ea64):_0x10ea64,_0x36a231[_0xae73ae][_0x49ad35('0x7b')]&&_0x461fc6[_0x49ad35('0x7d')](_0x10ea64),_0x36a231[_0xae73ae][_0x49ad35('0x45')]&&_0x461fc6[_0x49ad35('0x5c')](_0x10ea64,_0x36a231[_0xae73ae][_0x49ad35('0x45')]===_0x49ad35('0x72')?![]:!![]),_0x461fc6[_0x49ad35('0x22')](_0x10ea64,_0x36a231[_0xae73ae][_0x49ad35('0x40')]||_0x10ea64);}if(_0x164115['joins']){_0x164115[_0x49ad35('0xd')]=JSON['parse'](_0x164115[_0x49ad35('0xd')]);for(let _0x3fcd38=0x0;_0x3fcd38<_0x164115['joins'][_0x49ad35('0x8d')];_0x3fcd38+=0x1){_0x164115[_0x49ad35('0xd')][_0x3fcd38][_0x49ad35('0x8')]&&_[_0x49ad35('0x1b')](_0x3abf0f,_0x164115[_0x49ad35('0xd')][_0x3fcd38]['type'])&&_0x164115[_0x49ad35('0xd')][_0x3fcd38][_0x49ad35('0x5d')]&&_0x164115['joins'][_0x3fcd38][_0x49ad35('0x78')]&&_0x164115[_0x49ad35('0xd')][_0x3fcd38][_0x49ad35('0x7e')]&&_0x461fc6[_0x164115['joins'][_0x3fcd38]['type']](_0x164115['joins'][_0x3fcd38][_0x49ad35('0x78')],null,util['format'](_0x49ad35('0x71'),_0x164115['table'],_0x164115[_0x49ad35('0xd')][_0x3fcd38][_0x49ad35('0x5d')],_0x164115['joins'][_0x3fcd38]['foreignTable'],_0x164115[_0x49ad35('0xd')][_0x3fcd38]['foreignKey']));}}return _0x164115[_0x49ad35('0x61')]&&(_0x164115[_0x49ad35('0x61')]=JSON[_0x49ad35('0x84')](_0x164115[_0x49ad35('0x61')]),_0x461fc6[_0x49ad35('0x19')](_0x3ff2aa(_0x164115[_0x49ad35('0x61')][_0x49ad35('0x7d')]))),_0x461fc6[_0x49ad35('0x65')](_0x378556),_0x461fc6['offset'](0x0),logger[_0x49ad35('0x7a')](_0x49ad35('0x5'),_0x461fc6[_0x49ad35('0x1a')]()),db[_0x49ad35('0xc')][_0x49ad35('0x66')](_0x461fc6[_0x49ad35('0x1a')](),{'type':QueryTypes[_0x49ad35('0x80')]});}})[_0x5adfb4('0x3d')](respondWithResult(_0x2a98ac,null))[_0x5adfb4('0xe')](handleError(_0x2a98ac,null));};function runReport(_0x2b51ff,_0x1e8d57,_0x14867d){const _0x3d27e9=_0x3c51b8,_0x11b3a6=_0x1e8d57[_0x3d27e9('0x27')],_0x309c71=0xa,_0x7b56e9=[_0x3d27e9('0x1c'),_0x3d27e9('0x9'),'right_join','cross_join'],_0x24db5c={'SUM':_0x3d27e9('0x83'),'COUNT':_0x3d27e9('0x5e'),'COUNT\x20DISTINCT':_0x3d27e9('0x46'),'MAX':'MAX(%s)','MIN':_0x3d27e9('0x2d'),'AVG':_0x3d27e9('0x2b'),'GROUP_CONCAT':_0x3d27e9('0x1f'),'GROUP_CONCAT\x20ASC':_0x3d27e9('0x64'),'GROUP_CONCAT\x20DESC':_0x3d27e9('0x28')},_0x417cfd={'SEC_TO_TIME':_0x3d27e9('0x87'),'DATE':_0x3d27e9('0x32'),'HOUR':_0x3d27e9('0x2a'),'ROUND':_0x3d27e9('0x36'),'UNIX_TIMESTAMP':_0x3d27e9('0x6d')},_0x2ceaf6=function(_0x43c992){const _0x34ec3f=_0x3d27e9;return!_['includes'](['IS\x20NULL','IS\x20NOT\x20NULL',_0x34ec3f('0x4a'),_0x34ec3f('0x7c')],_0x43c992);},_0x28a990=function(_0x21fe57){const _0x5b25e8=_0x3d27e9;if(!_0x21fe57||!_0x21fe57[_0x5b25e8('0x23')][_0x5b25e8('0x8d')])return'';let _0x30030='(';for(let _0x3ff3f8=0x0;_0x3ff3f8<_0x21fe57[_0x5b25e8('0x23')]['length'];_0x3ff3f8+=0x1){_0x3ff3f8>0x0&&(_0x30030+='\x20'+_0x21fe57['operator']+'\x20'),_0x30030+=_0x21fe57[_0x5b25e8('0x23')][_0x3ff3f8][_0x5b25e8('0x7d')]?_0x28a990(_0x21fe57[_0x5b25e8('0x23')][_0x3ff3f8][_0x5b25e8('0x7d')]):_0x21fe57[_0x5b25e8('0x23')][_0x3ff3f8][_0x5b25e8('0x22')]+'\x20'+_0x21fe57['rules'][_0x3ff3f8][_0x5b25e8('0x1')]+(_0x2ceaf6(_0x21fe57[_0x5b25e8('0x23')][_0x3ff3f8][_0x5b25e8('0x1')])?'\x20'+_0x21fe57[_0x5b25e8('0x23')][_0x3ff3f8][_0x5b25e8('0x70')]:'');}return _0x30030+')';};let _0x197733={'where':{'id':_0x2b51ff['id']}},_0x3ce650,_0x39cb30,_0x8e501a,_0xd7c51c,_0x3e77be;return _0x197733=_[_0x3d27e9('0x18')]({},_0x197733,_0x14867d),db[_0x3d27e9('0x15')][_0x3d27e9('0x6c')](_0x197733)[_0x3d27e9('0x3d')](function(_0x436092){const _0x11a39b=_0x3d27e9;if(_0x436092)return _0x3ce650=_0x436092,_0x436092[_0x11a39b('0x48')]();return null;})[_0x3d27e9('0x3d')](function(_0x2d8977){const _0xd70ed1=_0x3d27e9;if(_0x2d8977){if(!_0x2d8977['length'])throw new ValidationErrorItem(_0xd70ed1('0x2'),0x193);return _0x39cb30=_0x2d8977,db['AnalyticMetric'][_0xd70ed1('0x44')]({'raw':!![]});}return null;})['then'](function(_0x2c66a9){const _0x16bd26=_0x3d27e9;if(_0x2c66a9){_0x8e501a=_['keyBy'](_0x2c66a9,'id');let _0x2448cc;const _0x5af7d1=squel[_0x16bd26('0x13')]();_0x5af7d1[_0x16bd26('0x88')](_0x3ce650['table']);for(let _0x5c0bc0=0x0;_0x5c0bc0<_0x39cb30[_0x16bd26('0x8d')];_0x5c0bc0+=0x1){_0x2448cc=_0x39cb30[_0x5c0bc0][_0x16bd26('0xb')]?_0x8e501a[_0x39cb30[_0x5c0bc0]['MetricId']][_0x16bd26('0x57')]:_0x39cb30[_0x5c0bc0][_0x16bd26('0x22')],_0x2448cc=_0x39cb30[_0x5c0bc0]['function']?_[_0x16bd26('0x8a')](_0x24db5c[_0x39cb30[_0x5c0bc0][_0x16bd26('0x7')]],'%s',_0x2448cc):_0x2448cc,_0x2448cc=_0x39cb30[_0x5c0bc0][_0x16bd26('0x56')]?_[_0x16bd26('0x8a')](_0x417cfd[_0x39cb30[_0x5c0bc0][_0x16bd26('0x56')]],'%s',_0x2448cc):_0x2448cc,_0x39cb30[_0x5c0bc0][_0x16bd26('0x7b')]&&_0x5af7d1['group'](_0x2448cc),_0x39cb30[_0x5c0bc0][_0x16bd26('0x45')]&&_0x5af7d1[_0x16bd26('0x5c')](_0x2448cc,_0x39cb30[_0x5c0bc0]['orderBy']===_0x16bd26('0x72')?![]:!![]),_0x5af7d1[_0x16bd26('0x22')](_0x2448cc,_0x39cb30[_0x5c0bc0][_0x16bd26('0x40')]||_0x2448cc);}if(_0x3ce650['joins']){_0x3ce650[_0x16bd26('0xd')]=JSON[_0x16bd26('0x84')](_0x3ce650[_0x16bd26('0xd')]);for(let _0x5a0d1f=0x0;_0x5a0d1f<_0x3ce650['joins'][_0x16bd26('0x8d')];_0x5a0d1f+=0x1){_0x3ce650[_0x16bd26('0xd')][_0x5a0d1f][_0x16bd26('0x8')]&&_[_0x16bd26('0x1b')](_0x7b56e9,_0x3ce650[_0x16bd26('0xd')][_0x5a0d1f][_0x16bd26('0x8')])&&_0x3ce650['joins'][_0x5a0d1f]['parentKey']&&_0x3ce650['joins'][_0x5a0d1f][_0x16bd26('0x78')]&&_0x3ce650[_0x16bd26('0xd')][_0x5a0d1f]['foreignKey']&&_0x5af7d1[_0x3ce650[_0x16bd26('0xd')][_0x5a0d1f][_0x16bd26('0x8')]](_0x3ce650[_0x16bd26('0xd')][_0x5a0d1f]['foreignTable'],null,util[_0x16bd26('0x56')](_0x16bd26('0x71'),_0x3ce650['table'],_0x3ce650[_0x16bd26('0xd')][_0x5a0d1f][_0x16bd26('0x5d')],_0x3ce650[_0x16bd26('0xd')][_0x5a0d1f][_0x16bd26('0x78')],_0x3ce650[_0x16bd26('0xd')][_0x5a0d1f][_0x16bd26('0x7e')]));}}return _0x3ce650[_0x16bd26('0x61')]&&(_0x3ce650['conditions']=JSON[_0x16bd26('0x84')](_0x3ce650[_0x16bd26('0x61')]),_0x5af7d1['where'](_0x28a990(_0x3ce650[_0x16bd26('0x61')][_0x16bd26('0x7d')]))),_0x3e77be=_0x5af7d1['clone'](),_0x5af7d1[_0x16bd26('0x65')](_0x309c71),_0x5af7d1[_0x16bd26('0x74')](0x0),logger[_0x16bd26('0x7a')](_0x16bd26('0x5'),_0x5af7d1[_0x16bd26('0x1a')]()),db[_0x16bd26('0xc')]['query'](_0x5af7d1[_0x16bd26('0x1a')](),{'type':QueryTypes[_0x16bd26('0x80')]});}})[_0x3d27e9('0x3d')](function(_0x33c49d){const _0x3a775a=_0x3d27e9;if(!_0x33c49d[_0x3a775a('0x8d')])throw new ValidationErrorItem(_0x3a775a('0x81'),0xcc);if(_0x1e8d57[_0x3a775a('0x3c')]===_0x3a775a('0x79'))return null;const _0x17987b=_[_0x3a775a('0x18')](_0x1e8d57,{'name':_0x1e8d57['fullPath']||_0x1e8d57[_0x3a775a('0x27')]||_0x3ce650[_0x3a775a('0x27')],'basename':_0x11b3a6,'savename':util['format'](_0x3a775a('0x69'),_0x1e8d57[_0x3a775a('0x27')]||_0x3ce650[_0x3a775a('0x27')],require(_0x3a775a('0x41'))[_0x3a775a('0x16')](0x4),_0x1e8d57[_0x3a775a('0x3c')]||'csv'),'reportId':_0x3ce650['id'],'reportType':'custom'});return db['AnalyticExtractedReport'][_0x3a775a('0x0')](_0x17987b,{'raw':!![]});})['then'](function(_0x4f364b){const _0x26fe85=_0x3d27e9;_0x3ce650[_0x26fe85('0x11')]===_0x26fe85('0xf')?_0x3e77be[_0x26fe85('0x19')](_0x3ce650[_0x26fe85('0x11')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x1e8d57[_0x26fe85('0x76')],_0x1e8d57['endDate']):_0x3e77be[_0x26fe85('0x19')](_0x3ce650['table']+_0x26fe85('0x60'),_0x1e8d57[_0x26fe85('0x76')],_0x1e8d57[_0x26fe85('0x29')]);if(_0x4f364b)return logger[_0x26fe85('0x52')](_0x26fe85('0x59'),_0x3e77be['toString']()),require(_0x26fe85('0x6e'))[_0x26fe85('0x53')](path[_0x26fe85('0x1c')](__dirname,_0x26fe85('0x10'),_0x4f364b[_0x26fe85('0x3c')]),[_0x4f364b['id'],_0x3e77be['toString'](),path[_0x26fe85('0x1c')](__dirname,_0x26fe85('0x20'),_0x4f364b[_0x26fe85('0x30')]),_0x11b3a6]),_0x4f364b;else{const _0x28995f=squel['select']();return _0x28995f[_0x26fe85('0x88')]('('+_0x3e77be[_0x26fe85('0x1a')]()+')',_0x26fe85('0x63')),_0x28995f[_0x26fe85('0x22')](_0x26fe85('0x4b'),_0x26fe85('0x6f')),_0x3e77be[_0x26fe85('0x65')](_0x1e8d57[_0x26fe85('0x65')]||_0x309c71),_0x3e77be[_0x26fe85('0x74')](_0x1e8d57[_0x26fe85('0x74')]||0x0),dbH[_0x26fe85('0xc')][_0x26fe85('0x66')](_0x28995f['toString'](),{'type':dbH['sequelize'][_0x26fe85('0x39')][_0x26fe85('0x80')]})[_0x26fe85('0x3d')](function(_0x5897c9){const _0x2b43ff=_0x26fe85;return!_0x5897c9['length']?_0xd7c51c=0x0:_0xd7c51c=_0x5897c9[0x0][_0x2b43ff('0x6f')]||0x0,dbH[_0x2b43ff('0xc')][_0x2b43ff('0x66')](_0x3e77be[_0x2b43ff('0x1a')](),{'type':dbH[_0x2b43ff('0xc')][_0x2b43ff('0x39')][_0x2b43ff('0x80')]});})[_0x26fe85('0x3d')](function(_0x37c76d){return{'rows':_0x37c76d||[],'count':_0xd7c51c};});}});}exports[_0x3c51b8('0x3')]=function(_0x1825bc,_0x46cc10){const _0x2620d3=_0x3c51b8;return runReport(_0x1825bc[_0x2620d3('0x6b')],_0x1825bc[_0x2620d3('0x66')],_0x1825bc[_0x2620d3('0x14')])[_0x2620d3('0x3d')](respondWithResult(_0x46cc10,null))[_0x2620d3('0xe')](handleError(_0x46cc10,null));},exports[_0x3c51b8('0x4e')]=runReport,exports[_0x3c51b8('0x66')]=function(_0x5bd6da,_0x883007){const _0x3ec8db=_0x3c51b8,_0x17bf0a=0xa,_0x557f2a=[_0x3ec8db('0x1c'),_0x3ec8db('0x9'),_0x3ec8db('0x2c'),_0x3ec8db('0x8b')],_0x3c134a={'SUM':_0x3ec8db('0x83'),'COUNT':_0x3ec8db('0x5e'),'COUNT\x20DISTINCT':_0x3ec8db('0x46'),'MAX':_0x3ec8db('0x2f'),'MIN':_0x3ec8db('0x2d'),'AVG':_0x3ec8db('0x2b'),'GROUP_CONCAT':_0x3ec8db('0x1f'),'GROUP_CONCAT\x20ASC':_0x3ec8db('0x64'),'GROUP_CONCAT\x20DESC':_0x3ec8db('0x28')},_0x1abe07={'SEC_TO_TIME':_0x3ec8db('0x87'),'DATE':'DATE(%s)','HOUR':_0x3ec8db('0x2a'),'ROUND':_0x3ec8db('0x36'),'UNIX_TIMESTAMP':_0x3ec8db('0x6d')},_0x398ccc=function(_0x3495ee){const _0xfb2ea0=_0x3ec8db;return!_[_0xfb2ea0('0x1b')]([_0xfb2ea0('0x90'),'IS\x20NOT\x20NULL',_0xfb2ea0('0x4a'),'IS\x20NOT\x20EMPTY'],_0x3495ee);},_0x557715=function(_0x188d39){const _0x621586=_0x3ec8db;if(!_0x188d39||!_0x188d39[_0x621586('0x23')][_0x621586('0x8d')])return'';let _0x3439e7='(';for(let _0x3ea7bf=0x0;_0x3ea7bf<_0x188d39[_0x621586('0x23')][_0x621586('0x8d')];_0x3ea7bf+=0x1){_0x3ea7bf>0x0&&(_0x3439e7+='\x20'+_0x188d39[_0x621586('0x33')]+'\x20'),_0x3439e7+=_0x188d39[_0x621586('0x23')][_0x3ea7bf][_0x621586('0x7d')]?_0x557715(_0x188d39['rules'][_0x3ea7bf][_0x621586('0x7d')]):_0x188d39['rules'][_0x3ea7bf][_0x621586('0x22')]+'\x20'+_0x188d39[_0x621586('0x23')][_0x3ea7bf][_0x621586('0x1')]+(_0x398ccc(_0x188d39[_0x621586('0x23')][_0x3ea7bf][_0x621586('0x1')])?'\x20'+_0x188d39[_0x621586('0x23')][_0x3ea7bf][_0x621586('0x70')]:'');}return _0x3439e7+')';};let _0x964a8e={'where':{'id':_0x5bd6da['params']['id']}},_0x41b01f,_0x4c8b95,_0x574358,_0x4678f5;return _0x964a8e=_[_0x3ec8db('0x18')]({},_0x964a8e,_0x5bd6da[_0x3ec8db('0x14')]),db[_0x3ec8db('0x15')]['findOne'](_0x964a8e)[_0x3ec8db('0x3d')](function(_0x1b1e1f){const _0x38ac5a=_0x3ec8db;if(_0x1b1e1f)return _0x41b01f=_0x1b1e1f,_0x1b1e1f[_0x38ac5a('0x48')]();return null;})[_0x3ec8db('0x3d')](function(_0x4ced81){const _0x1ca612=_0x3ec8db;if(_0x4ced81){if(!_0x4ced81[_0x1ca612('0x8d')])throw new ValidationErrorItem(_0x1ca612('0x2'),0x193);return _0x4c8b95=_0x4ced81,db[_0x1ca612('0x62')][_0x1ca612('0x44')]({'raw':!![]});}return null;})['then'](function(_0x57b8ec){const _0x3ffa58=_0x3ec8db;if(_0x57b8ec){_0x574358=_['keyBy'](_0x57b8ec,'id');let _0x3d3c1c;const _0x1da2ce=squel[_0x3ffa58('0x13')]();_0x1da2ce[_0x3ffa58('0x88')](_0x41b01f[_0x3ffa58('0x11')]);for(let _0x9b1d9e=0x0;_0x9b1d9e<_0x4c8b95['length'];_0x9b1d9e+=0x1){_0x3d3c1c=_0x4c8b95[_0x9b1d9e]['MetricId']?_0x574358[_0x4c8b95[_0x9b1d9e][_0x3ffa58('0xb')]][_0x3ffa58('0x57')]:_0x4c8b95[_0x9b1d9e][_0x3ffa58('0x22')],_0x3d3c1c=_0x4c8b95[_0x9b1d9e][_0x3ffa58('0x7')]?_[_0x3ffa58('0x8a')](_0x3c134a[_0x4c8b95[_0x9b1d9e][_0x3ffa58('0x7')]],'%s',_0x3d3c1c):_0x3d3c1c,_0x3d3c1c=_0x4c8b95[_0x9b1d9e][_0x3ffa58('0x56')]?_[_0x3ffa58('0x8a')](_0x1abe07[_0x4c8b95[_0x9b1d9e]['format']],'%s',_0x3d3c1c):_0x3d3c1c,_0x4c8b95[_0x9b1d9e][_0x3ffa58('0x7b')]&&_0x1da2ce[_0x3ffa58('0x7d')](_0x3d3c1c),_0x4c8b95[_0x9b1d9e]['orderBy']&&_0x1da2ce[_0x3ffa58('0x5c')](_0x3d3c1c,_0x4c8b95[_0x9b1d9e][_0x3ffa58('0x45')]==='DESC'?![]:!![]),_0x1da2ce[_0x3ffa58('0x22')](_0x3d3c1c,_0x4c8b95[_0x9b1d9e][_0x3ffa58('0x40')]||_0x3d3c1c);}if(_0x41b01f[_0x3ffa58('0xd')]){_0x41b01f[_0x3ffa58('0xd')]=JSON['parse'](_0x41b01f[_0x3ffa58('0xd')]);for(let _0x3ed084=0x0;_0x3ed084<_0x41b01f[_0x3ffa58('0xd')][_0x3ffa58('0x8d')];_0x3ed084+=0x1){_0x41b01f[_0x3ffa58('0xd')][_0x3ed084][_0x3ffa58('0x8')]&&_[_0x3ffa58('0x1b')](_0x557f2a,_0x41b01f[_0x3ffa58('0xd')][_0x3ed084][_0x3ffa58('0x8')])&&_0x41b01f[_0x3ffa58('0xd')][_0x3ed084]['parentKey']&&_0x41b01f[_0x3ffa58('0xd')][_0x3ed084]['foreignTable']&&_0x41b01f['joins'][_0x3ed084]['foreignKey']&&_0x1da2ce[_0x41b01f[_0x3ffa58('0xd')][_0x3ed084]['type']](_0x41b01f[_0x3ffa58('0xd')][_0x3ed084]['foreignTable'],null,util[_0x3ffa58('0x56')](_0x3ffa58('0x71'),_0x41b01f[_0x3ffa58('0x11')],_0x41b01f[_0x3ffa58('0xd')][_0x3ed084][_0x3ffa58('0x5d')],_0x41b01f[_0x3ffa58('0xd')][_0x3ed084][_0x3ffa58('0x78')],_0x41b01f[_0x3ffa58('0xd')][_0x3ed084][_0x3ffa58('0x7e')]));}}return _0x41b01f['conditions']&&(_0x41b01f['conditions']=JSON[_0x3ffa58('0x84')](_0x41b01f[_0x3ffa58('0x61')]),_0x1da2ce[_0x3ffa58('0x19')](_0x557715(_0x41b01f[_0x3ffa58('0x61')][_0x3ffa58('0x7d')]))),_0x4678f5=_0x1da2ce[_0x3ffa58('0x38')](),_0x1da2ce[_0x3ffa58('0x65')](_0x17bf0a),_0x1da2ce[_0x3ffa58('0x74')](0x0),logger['debug'](_0x3ffa58('0x5'),_0x1da2ce[_0x3ffa58('0x1a')]()),db['sequelize'][_0x3ffa58('0x66')](_0x1da2ce[_0x3ffa58('0x1a')](),{'type':QueryTypes[_0x3ffa58('0x80')]});}})[_0x3ec8db('0x3d')](function(){const _0x52f0e2=_0x3ec8db;return{'sql':_0x4678f5[_0x52f0e2('0x1a')]()};})[_0x3ec8db('0x3d')](respondWithResult(_0x883007,null))[_0x3ec8db('0xe')](handleError(_0x883007,null));};
\ No newline at end of file
+const a5_0x2128=['MetricId','Content-Range','undefined','COUNT(%s)','attributes','sequelize','rows','findOne','keyBy','clone','IS\x20NOT\x20NULL','fieldName','set','merge','keys','role','include','api','catch','groupBy','GROUP_CONCAT(%s)','type','info','model','Limited\x20Query:','dbH','COUNT(DISTINCT\x20%s)','../../files/reports','foreignKey','orderBy','SEC_TO_TIME(%s)','query','group','MIN(%s)','value','IS\x20NULL','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','alias','where','pick','SUM(%s)','metric','IS\x20EMPTY','count','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','create','foreignTable','randomstring','get','join','user','map','CustomReports','custom','parse','status','autoAssociation','Unable\x20to\x20retrieve\x20the\x20current\x20user','json','name','then','joins','fullPath','limit','preview','select','right_join','UserProfileResource','../../config/logger','offset','table','DATE(%s)','QueryTypes','sendStatus','userProfileId','web','filter','conditions','../../components/parsers/qs','savename','.createdAt\x20BETWEEN\x20?\x20AND\x20?','params','generate','ROUND(%s)','from','function','parentKey','%s.%s\x20=\x20%s.%s','Please\x20insert\x20at\x20least\x20one\x20field','debug','options','update','filters','Run\x20Query:','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','getFields','MAX(%s)','findAll','Reports','countTable','operator','rawAttributes','UNIX_TIMESTAMP(%s)','child_process','fields','body','intersection','../../components/export/','destroy','runReport','VIRTUAL','IS\x20NOT\x20EMPTY','AnalyticCustomReport','.calldate\x20BETWEEN\x20?\x20AND\x20?','AnalyticMetric','order','error','sort','cross_join','output','../../mysqldb','replace','endDate','condition','No\x20available\x20data','left_join','nolimit','AVG(%s)','DESC','SELECT','length','rules','format','AnalyticExtractedReport','fork','HOUR(%s)','includeAll','util','toString','index','end','field','includes'];(function(_0x4bd5b2,_0x2128c5){const _0x1c6a77=function(_0x48a30f){while(--_0x48a30f){_0x4bd5b2['push'](_0x4bd5b2['shift']());}};_0x1c6a77(++_0x2128c5);}(a5_0x2128,0x10b));const a5_0x1c6a=function(_0x4bd5b2,_0x2128c5){_0x4bd5b2=_0x4bd5b2-0x0;let _0x1c6a77=a5_0x2128[_0x4bd5b2];return _0x1c6a77;};const _0x24a81b=a5_0x1c6a;'use strict';const util=require(_0x24a81b('0xd')),path=require('path'),_=require('lodash'),squel=require('squel'),qs=require(_0x24a81b('0x61')),logger=require(_0x24a81b('0x57'))(_0x24a81b('0x24')),db=require(_0x24a81b('0x8b'))['db'],dbH=require(_0x24a81b('0x8b'))[_0x24a81b('0x2c')],{Op,ValidationErrorItem,QueryTypes}=require(_0x24a81b('0x18'));function respondWithResult(_0x48a30f,_0x19477c){return _0x19477c=_0x19477c||0xc8,function(_0x3a6aed){const _0x8d11a6=a5_0x1c6a;if(_0x3a6aed)return _0x48a30f[_0x8d11a6('0x4a')](_0x19477c)['json'](_0x3a6aed);};}function respondWithFilteredResult(_0x4fc07f,_0x2c0010){return function(_0x569c9f){const _0x7b899c=a5_0x1c6a;if(_0x569c9f){const _0x1097e1=_0x569c9f[_0x7b899c('0x3e')],_0x49dbbe=_0x2c0010['offset'];let _0xed751c=_0x2c0010['offset']+_0x2c0010[_0x7b899c('0x52')],_0x23e8f5;return _0xed751c>=_0x1097e1?(_0xed751c=_0x1097e1,_0x23e8f5=0xc8):_0x23e8f5=0xce,_0x4fc07f[_0x7b899c('0x4a')](_0x23e8f5),_0x4fc07f[_0x7b899c('0x1f')](_0x7b899c('0x14'),_0x49dbbe+'-'+_0xed751c+'/'+_0x1097e1)[_0x7b899c('0x4d')](_0x569c9f);}return null;};}function saveUpdates(_0x4e29eb){return function(_0x2ca32c){if(_0x2ca32c)return _0x2ca32c['update'](_0x4e29eb)['then'](function(_0x8def67){return _0x8def67;});return null;};}function removeEntity(_0xd03bb3){return function(_0x4161a8){const _0x50c38c=a5_0x1c6a;if(_0x4161a8)return _0x4161a8[_0x50c38c('0x7f')]()[_0x50c38c('0x4f')](function(){const _0x4452cb=_0x50c38c,_0x8d6707=_0x4161a8[_0x4452cb('0x43')]({'plain':!![]}),_0x21ace2=_0x4452cb('0x47');return db[_0x4452cb('0x56')][_0x4452cb('0x7f')]({'where':{'type':_0x21ace2,'resourceId':_0x8d6707['id']}})['then'](function(){return _0x4161a8;});})[_0x50c38c('0x4f')](function(){const _0x374534=_0x50c38c;_0xd03bb3[_0x374534('0x4a')](0xcc)[_0x374534('0x10')]();});};}function handleEntityNotFound(_0x4720a7){return function(_0x4521c2){const _0x220b0d=a5_0x1c6a;return!_0x4521c2&&_0x4720a7[_0x220b0d('0x5c')](0x194),_0x4521c2;};}function handleError(_0x40165c,_0x3ca797){return _0x3ca797=_0x3ca797||0x1f4,function(_0xd3f8e8){const _0x946519=a5_0x1c6a;logger[_0x946519('0x87')](_0xd3f8e8['stack']),_0xd3f8e8[_0x946519('0x4e')]&&delete _0xd3f8e8[_0x946519('0x4e')],_0x40165c[_0x946519('0x4a')](_0x3ca797)['send'](_0xd3f8e8);};}exports[_0x24a81b('0xf')]=function(_0x17b42e,_0x2405ee){const _0x369dae=_0x24a81b;let _0x3a2c0d={};const _0x1bae7a={},_0x794923={'count':0x0,'rows':[]},_0x2089f8=_[_0x369dae('0x46')](db[_0x369dae('0x83')][_0x369dae('0x78')],function(_0x5129fd){const _0xbd6f2b=_0x369dae;return{'name':_0x5129fd[_0xbd6f2b('0x1e')],'type':_0x5129fd[_0xbd6f2b('0x28')]['key']};});_0x1bae7a[_0x369dae('0x2a')]=_[_0x369dae('0x46')](_0x2089f8,_0x369dae('0x4e')),_0x1bae7a[_0x369dae('0x32')]=_[_0x369dae('0x21')](_0x17b42e[_0x369dae('0x32')]),_0x1bae7a['filters']=_[_0x369dae('0x7d')](_0x1bae7a[_0x369dae('0x2a')],_0x1bae7a[_0x369dae('0x32')]),_0x3a2c0d[_0x369dae('0x17')]=_[_0x369dae('0x7d')](_0x1bae7a[_0x369dae('0x2a')],qs[_0x369dae('0x7b')](_0x17b42e[_0x369dae('0x32')][_0x369dae('0x7b')])),_0x3a2c0d[_0x369dae('0x17')]=_0x3a2c0d['attributes'][_0x369dae('0x6')]?_0x3a2c0d[_0x369dae('0x17')]:_0x1bae7a[_0x369dae('0x2a')];typeof _0x17b42e['query'][_0x369dae('0x2')]===_0x369dae('0x15')&&(_0x3a2c0d['limit']=qs[_0x369dae('0x52')](_0x17b42e[_0x369dae('0x32')]['limit']),_0x3a2c0d[_0x369dae('0x58')]=qs[_0x369dae('0x58')](_0x17b42e[_0x369dae('0x32')][_0x369dae('0x58')]));_0x3a2c0d[_0x369dae('0x86')]=qs[_0x369dae('0x88')](_0x17b42e[_0x369dae('0x32')][_0x369dae('0x88')]),_0x3a2c0d[_0x369dae('0x39')]=qs[_0x369dae('0x6f')](_[_0x369dae('0x3a')](_0x17b42e[_0x369dae('0x32')],_0x1bae7a[_0x369dae('0x6f')]),_0x2089f8);_0x17b42e[_0x369dae('0x32')][_0x369dae('0x5f')]&&(_0x3a2c0d[_0x369dae('0x39')]=_[_0x369dae('0x20')](_0x3a2c0d['where'],{[Op['or']]:_['map'](_0x2089f8,function(_0x56a53){const _0x520b6f=_0x369dae;if(_0x56a53[_0x520b6f('0x28')]!==_0x520b6f('0x81')){const _0x34a708={};return _0x34a708[_0x56a53['name']]={[Op['like']]:'%'+_0x17b42e[_0x520b6f('0x32')][_0x520b6f('0x5f')]+'%'},_0x34a708;}})}));_0x3a2c0d=_[_0x369dae('0x20')]({},_0x3a2c0d,_0x17b42e['options']);const _0x6db5a2={'where':_0x3a2c0d[_0x369dae('0x39')]};return db[_0x369dae('0x83')][_0x369dae('0x3e')](_0x6db5a2)[_0x369dae('0x4f')](function(_0x75eeab){const _0x3d1818=_0x369dae;return _0x794923['count']=_0x75eeab,_0x17b42e[_0x3d1818('0x32')][_0x3d1818('0xc')]&&(_0x3a2c0d[_0x3d1818('0x23')]=[{'all':!![]}]),db[_0x3d1818('0x83')]['findAll'](_0x3a2c0d);})[_0x369dae('0x4f')](function(_0xad0ac5){const _0x3e8a54=_0x369dae;return _0x794923[_0x3e8a54('0x19')]=_0xad0ac5,_0x794923;})[_0x369dae('0x4f')](respondWithFilteredResult(_0x2405ee,_0x3a2c0d))[_0x369dae('0x25')](handleError(_0x2405ee,null));},exports['show']=function(_0x5cacc7,_0x7c124f){const _0x45c8d9=_0x24a81b;let _0x5a0b38={'raw':![],'where':{'id':_0x5cacc7[_0x45c8d9('0x64')]['id']}};const _0x2f97dd={};return _0x2f97dd[_0x45c8d9('0x2a')]=_[_0x45c8d9('0x21')](db[_0x45c8d9('0x83')][_0x45c8d9('0x78')]),_0x2f97dd[_0x45c8d9('0x32')]=_[_0x45c8d9('0x21')](_0x5cacc7[_0x45c8d9('0x32')]),_0x2f97dd['filters']=_[_0x45c8d9('0x7d')](_0x2f97dd[_0x45c8d9('0x2a')],_0x2f97dd['query']),_0x5a0b38['attributes']=_[_0x45c8d9('0x7d')](_0x2f97dd['model'],qs[_0x45c8d9('0x7b')](_0x5cacc7[_0x45c8d9('0x32')][_0x45c8d9('0x7b')])),_0x5a0b38[_0x45c8d9('0x17')]=_0x5a0b38[_0x45c8d9('0x17')]['length']?_0x5a0b38['attributes']:_0x2f97dd[_0x45c8d9('0x2a')],_0x5cacc7['query'][_0x45c8d9('0xc')]&&(_0x5a0b38[_0x45c8d9('0x23')]=[{'all':!![]}]),_0x5a0b38=_[_0x45c8d9('0x20')]({},_0x5a0b38,_0x5cacc7['options']),db[_0x45c8d9('0x83')][_0x45c8d9('0x1a')](_0x5a0b38)['then'](handleEntityNotFound(_0x7c124f,null))[_0x45c8d9('0x4f')](respondWithResult(_0x7c124f,null))['catch'](handleError(_0x7c124f,null));},exports[_0x24a81b('0x40')]=function(_0x4d55df,_0x12cf8f){const _0x214633=_0x24a81b;return db[_0x214633('0x83')][_0x214633('0x40')](_0x4d55df['body'],{})[_0x214633('0x4f')](function(_0x3a3a85){const _0xf48c08=_0x214633,_0x10b299=_0x4d55df['user'][_0xf48c08('0x43')]({'plain':!![]});if(!_0x10b299)throw new Error(_0xf48c08('0x4c'));if(_0x10b299[_0xf48c08('0x22')]===_0xf48c08('0x45')){const _0x3ab6d1=_0x3a3a85[_0xf48c08('0x43')]({'plain':!![]}),_0x4c7841=_0xf48c08('0x75');return db['UserProfileSection'][_0xf48c08('0x1a')]({'where':{'name':_0x4c7841,'userProfileId':_0x10b299[_0xf48c08('0x5d')]},'raw':!![]})[_0xf48c08('0x4f')](function(_0x19d190){const _0xd2bb64=_0xf48c08;return _0x19d190&&_0x19d190[_0xd2bb64('0x4b')]===0x0?db['UserProfileResource']['create']({'name':_0x3ab6d1['name'],'resourceId':_0x3ab6d1['id'],'type':'CustomReports','sectionId':_0x19d190['id']},{})[_0xd2bb64('0x4f')](function(){return _0x3a3a85;}):_0x3a3a85;})['catch'](function(_0x258769){const _0x582de1=_0xf48c08;logger[_0x582de1('0x87')](_0x582de1('0x3f'),_0x258769);throw _0x258769;});}return _0x3a3a85;})['then'](respondWithResult(_0x12cf8f,0xc9))[_0x214633('0x25')](handleError(_0x12cf8f,null));},exports[_0x24a81b('0x6e')]=function(_0x354d28,_0x2bdbd6){const _0x3dcf56=_0x24a81b;return _0x354d28[_0x3dcf56('0x7c')]['id']&&delete _0x354d28[_0x3dcf56('0x7c')]['id'],db[_0x3dcf56('0x83')]['findOne']({'where':{'id':_0x354d28['params']['id']}})[_0x3dcf56('0x4f')](handleEntityNotFound(_0x2bdbd6,null))[_0x3dcf56('0x4f')](saveUpdates(_0x354d28[_0x3dcf56('0x7c')],null))[_0x3dcf56('0x4f')](respondWithResult(_0x2bdbd6,null))['catch'](handleError(_0x2bdbd6,null));},exports[_0x24a81b('0x7f')]=function(_0x19f3af,_0x40227f){const _0x21894a=_0x24a81b;return db[_0x21894a('0x83')][_0x21894a('0x1a')]({'where':{'id':_0x19f3af['params']['id']}})[_0x21894a('0x4f')](handleEntityNotFound(_0x40227f,null))[_0x21894a('0x4f')](removeEntity(_0x40227f,null))[_0x21894a('0x25')](handleError(_0x40227f,null));},exports[_0x24a81b('0x53')]=function(_0x4d3aae,_0x3adba1){const _0x18f66a=_0x24a81b,_0x42b7ea=0xa,_0x482966=[_0x18f66a('0x44'),_0x18f66a('0x1'),_0x18f66a('0x55'),_0x18f66a('0x89')],_0xde6e11={'SUM':'SUM(%s)','COUNT':_0x18f66a('0x16'),'COUNT\x20DISTINCT':_0x18f66a('0x2d'),'MAX':_0x18f66a('0x73'),'MIN':_0x18f66a('0x34'),'AVG':_0x18f66a('0x3'),'GROUP_CONCAT':_0x18f66a('0x27'),'GROUP_CONCAT\x20ASC':_0x18f66a('0x37'),'GROUP_CONCAT\x20DESC':_0x18f66a('0x71')},_0x3f490c={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x18f66a('0x5a'),'HOUR':_0x18f66a('0xb'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x18f66a('0x79')},_0x7b569e=function(_0x5c41af){const _0x17bc5c=_0x18f66a;return!_[_0x17bc5c('0x12')](['IS\x20NULL','IS\x20NOT\x20NULL',_0x17bc5c('0x3d'),_0x17bc5c('0x82')],_0x5c41af);},_0x6599df=function(_0x5c2c30){const _0x3fb456=_0x18f66a;if(!_0x5c2c30||!_0x5c2c30[_0x3fb456('0x7')][_0x3fb456('0x6')])return'';let _0xfc796c='(';for(let _0x3ea892=0x0;_0x3ea892<_0x5c2c30[_0x3fb456('0x7')][_0x3fb456('0x6')];_0x3ea892+=0x1){_0x3ea892>0x0&&(_0xfc796c+='\x20'+_0x5c2c30[_0x3fb456('0x77')]+'\x20'),_0xfc796c+=_0x5c2c30[_0x3fb456('0x7')][_0x3ea892][_0x3fb456('0x33')]?_0x6599df(_0x5c2c30['rules'][_0x3ea892][_0x3fb456('0x33')]):_0x5c2c30[_0x3fb456('0x7')][_0x3ea892][_0x3fb456('0x11')]+'\x20'+_0x5c2c30[_0x3fb456('0x7')][_0x3ea892][_0x3fb456('0x8e')]+(_0x7b569e(_0x5c2c30[_0x3fb456('0x7')][_0x3ea892][_0x3fb456('0x8e')])?'\x20'+_0x5c2c30['rules'][_0x3ea892][_0x3fb456('0x35')]:'');}return _0xfc796c+')';};let _0x215e00={'where':{'id':_0x4d3aae[_0x18f66a('0x64')]['id']}},_0x55d396,_0x3dbef8,_0x509bde;return _0x215e00=_[_0x18f66a('0x20')]({},_0x215e00,_0x4d3aae['options']),db[_0x18f66a('0x83')][_0x18f66a('0x1a')](_0x215e00)['then'](function(_0x4ab017){const _0x22fb00=_0x18f66a;if(_0x4ab017)return _0x55d396=_0x4ab017,_0x4ab017[_0x22fb00('0x72')]();return null;})[_0x18f66a('0x4f')](function(_0x233d8a){const _0x495011=_0x18f66a;if(_0x233d8a){if(!_0x233d8a[_0x495011('0x6')])throw new ValidationErrorItem('Please\x20insert\x20at\x20least\x20one\x20field',0x193);return _0x3dbef8=_0x233d8a,db[_0x495011('0x85')][_0x495011('0x74')]({'raw':!![]});}return null;})[_0x18f66a('0x4f')](function(_0x57a4df){const _0x27bd91=_0x18f66a;if(_0x57a4df){_0x509bde=_['keyBy'](_0x57a4df,'id');let _0x3edbd0;const _0x4c384c=squel[_0x27bd91('0x54')]();_0x4c384c[_0x27bd91('0x67')](_0x55d396['table']);for(let _0x34810f=0x0;_0x34810f<_0x3dbef8['length'];_0x34810f+=0x1){_0x3edbd0=_0x3dbef8[_0x34810f][_0x27bd91('0x13')]?_0x509bde[_0x3dbef8[_0x34810f][_0x27bd91('0x13')]][_0x27bd91('0x3c')]:_0x3dbef8[_0x34810f]['field'],_0x3edbd0=_0x3dbef8[_0x34810f][_0x27bd91('0x68')]?_[_0x27bd91('0x8c')](_0xde6e11[_0x3dbef8[_0x34810f]['function']],'%s',_0x3edbd0):_0x3edbd0,_0x3edbd0=_0x3dbef8[_0x34810f][_0x27bd91('0x8')]?_[_0x27bd91('0x8c')](_0x3f490c[_0x3dbef8[_0x34810f][_0x27bd91('0x8')]],'%s',_0x3edbd0):_0x3edbd0,_0x3dbef8[_0x34810f][_0x27bd91('0x26')]&&_0x4c384c[_0x27bd91('0x33')](_0x3edbd0),_0x3dbef8[_0x34810f]['orderBy']&&_0x4c384c[_0x27bd91('0x86')](_0x3edbd0,_0x3dbef8[_0x34810f][_0x27bd91('0x30')]==='DESC'?![]:!![]),_0x4c384c['field'](_0x3edbd0,_0x3dbef8[_0x34810f][_0x27bd91('0x38')]||_0x3edbd0);}if(_0x55d396[_0x27bd91('0x50')]){_0x55d396[_0x27bd91('0x50')]=JSON[_0x27bd91('0x49')](_0x55d396[_0x27bd91('0x50')]);for(let _0x5059b3=0x0;_0x5059b3<_0x55d396['joins'][_0x27bd91('0x6')];_0x5059b3+=0x1){_0x55d396[_0x27bd91('0x50')][_0x5059b3][_0x27bd91('0x28')]&&_[_0x27bd91('0x12')](_0x482966,_0x55d396[_0x27bd91('0x50')][_0x5059b3][_0x27bd91('0x28')])&&_0x55d396['joins'][_0x5059b3][_0x27bd91('0x69')]&&_0x55d396['joins'][_0x5059b3][_0x27bd91('0x41')]&&_0x55d396[_0x27bd91('0x50')][_0x5059b3][_0x27bd91('0x2f')]&&_0x4c384c[_0x55d396[_0x27bd91('0x50')][_0x5059b3]['type']](_0x55d396['joins'][_0x5059b3][_0x27bd91('0x41')],null,util[_0x27bd91('0x8')]('%s.%s\x20=\x20%s.%s',_0x55d396['table'],_0x55d396['joins'][_0x5059b3][_0x27bd91('0x69')],_0x55d396['joins'][_0x5059b3][_0x27bd91('0x41')],_0x55d396[_0x27bd91('0x50')][_0x5059b3][_0x27bd91('0x2f')]));}}return _0x55d396[_0x27bd91('0x60')]&&(_0x55d396[_0x27bd91('0x60')]=JSON[_0x27bd91('0x49')](_0x55d396[_0x27bd91('0x60')]),_0x4c384c[_0x27bd91('0x39')](_0x6599df(_0x55d396['conditions'][_0x27bd91('0x33')]))),_0x4c384c[_0x27bd91('0x52')](_0x42b7ea),_0x4c384c[_0x27bd91('0x58')](0x0),logger['debug'](_0x27bd91('0x2b'),_0x4c384c[_0x27bd91('0xe')]()),db[_0x27bd91('0x18')][_0x27bd91('0x32')](_0x4c384c[_0x27bd91('0xe')](),{'type':QueryTypes[_0x27bd91('0x5')]});}})[_0x18f66a('0x4f')](respondWithResult(_0x3adba1,null))[_0x18f66a('0x25')](handleError(_0x3adba1,null));};function runReport(_0xd358ea,_0x703c8d,_0x15aece){const _0x1f16b3=_0x24a81b,_0xdf070c=_0x703c8d[_0x1f16b3('0x4e')],_0x3d4d39=0xa,_0x3fdb7f=['join',_0x1f16b3('0x1'),_0x1f16b3('0x55'),_0x1f16b3('0x89')],_0x251b1={'SUM':_0x1f16b3('0x3b'),'COUNT':_0x1f16b3('0x16'),'COUNT\x20DISTINCT':_0x1f16b3('0x2d'),'MAX':_0x1f16b3('0x73'),'MIN':_0x1f16b3('0x34'),'AVG':_0x1f16b3('0x3'),'GROUP_CONCAT':_0x1f16b3('0x27'),'GROUP_CONCAT\x20ASC':_0x1f16b3('0x37'),'GROUP_CONCAT\x20DESC':_0x1f16b3('0x71')},_0x51ba8e={'SEC_TO_TIME':_0x1f16b3('0x31'),'DATE':_0x1f16b3('0x5a'),'HOUR':_0x1f16b3('0xb'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x1f16b3('0x79')},_0x5c8572=function(_0x38e303){const _0x53b8f1=_0x1f16b3;return!_[_0x53b8f1('0x12')]([_0x53b8f1('0x36'),_0x53b8f1('0x1d'),_0x53b8f1('0x3d'),_0x53b8f1('0x82')],_0x38e303);},_0x3ce90c=function(_0x5588fa){const _0x12ba10=_0x1f16b3;if(!_0x5588fa||!_0x5588fa[_0x12ba10('0x7')]['length'])return'';let _0x445ac5='(';for(let _0x2a34bd=0x0;_0x2a34bd<_0x5588fa[_0x12ba10('0x7')]['length'];_0x2a34bd+=0x1){_0x2a34bd>0x0&&(_0x445ac5+='\x20'+_0x5588fa[_0x12ba10('0x77')]+'\x20'),_0x445ac5+=_0x5588fa['rules'][_0x2a34bd][_0x12ba10('0x33')]?_0x3ce90c(_0x5588fa['rules'][_0x2a34bd][_0x12ba10('0x33')]):_0x5588fa[_0x12ba10('0x7')][_0x2a34bd][_0x12ba10('0x11')]+'\x20'+_0x5588fa['rules'][_0x2a34bd][_0x12ba10('0x8e')]+(_0x5c8572(_0x5588fa[_0x12ba10('0x7')][_0x2a34bd][_0x12ba10('0x8e')])?'\x20'+_0x5588fa[_0x12ba10('0x7')][_0x2a34bd][_0x12ba10('0x35')]:'');}return _0x445ac5+')';};let _0x2c85cb={'where':{'id':_0xd358ea['id']}},_0x15b3cf,_0x33c1e0,_0x5f99d4,_0x36f22e,_0x492aec;return _0x2c85cb=_[_0x1f16b3('0x20')]({},_0x2c85cb,_0x15aece),db['AnalyticCustomReport']['findOne'](_0x2c85cb)[_0x1f16b3('0x4f')](function(_0x33489c){if(_0x33489c)return _0x15b3cf=_0x33489c,_0x33489c['getFields']();return null;})['then'](function(_0x3447a6){const _0x276c87=_0x1f16b3;if(_0x3447a6){if(!_0x3447a6['length'])throw new ValidationErrorItem(_0x276c87('0x6b'),0x193);return _0x33c1e0=_0x3447a6,db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0x1f16b3('0x4f')](function(_0x13d4fe){const _0x23e15a=_0x1f16b3;if(_0x13d4fe){_0x5f99d4=_['keyBy'](_0x13d4fe,'id');let _0x552c8c;const _0x569b34=squel['select']();_0x569b34['from'](_0x15b3cf[_0x23e15a('0x59')]);for(let _0x4c00f2=0x0;_0x4c00f2<_0x33c1e0[_0x23e15a('0x6')];_0x4c00f2+=0x1){_0x552c8c=_0x33c1e0[_0x4c00f2][_0x23e15a('0x13')]?_0x5f99d4[_0x33c1e0[_0x4c00f2][_0x23e15a('0x13')]]['metric']:_0x33c1e0[_0x4c00f2][_0x23e15a('0x11')],_0x552c8c=_0x33c1e0[_0x4c00f2][_0x23e15a('0x68')]?_['replace'](_0x251b1[_0x33c1e0[_0x4c00f2][_0x23e15a('0x68')]],'%s',_0x552c8c):_0x552c8c,_0x552c8c=_0x33c1e0[_0x4c00f2][_0x23e15a('0x8')]?_[_0x23e15a('0x8c')](_0x51ba8e[_0x33c1e0[_0x4c00f2][_0x23e15a('0x8')]],'%s',_0x552c8c):_0x552c8c,_0x33c1e0[_0x4c00f2][_0x23e15a('0x26')]&&_0x569b34['group'](_0x552c8c),_0x33c1e0[_0x4c00f2][_0x23e15a('0x30')]&&_0x569b34['order'](_0x552c8c,_0x33c1e0[_0x4c00f2][_0x23e15a('0x30')]===_0x23e15a('0x4')?![]:!![]),_0x569b34[_0x23e15a('0x11')](_0x552c8c,_0x33c1e0[_0x4c00f2][_0x23e15a('0x38')]||_0x552c8c);}if(_0x15b3cf[_0x23e15a('0x50')]){_0x15b3cf[_0x23e15a('0x50')]=JSON[_0x23e15a('0x49')](_0x15b3cf[_0x23e15a('0x50')]);for(let _0x5067c1=0x0;_0x5067c1<_0x15b3cf['joins'][_0x23e15a('0x6')];_0x5067c1+=0x1){_0x15b3cf[_0x23e15a('0x50')][_0x5067c1][_0x23e15a('0x28')]&&_[_0x23e15a('0x12')](_0x3fdb7f,_0x15b3cf[_0x23e15a('0x50')][_0x5067c1][_0x23e15a('0x28')])&&_0x15b3cf[_0x23e15a('0x50')][_0x5067c1][_0x23e15a('0x69')]&&_0x15b3cf['joins'][_0x5067c1][_0x23e15a('0x41')]&&_0x15b3cf[_0x23e15a('0x50')][_0x5067c1][_0x23e15a('0x2f')]&&_0x569b34[_0x15b3cf[_0x23e15a('0x50')][_0x5067c1][_0x23e15a('0x28')]](_0x15b3cf['joins'][_0x5067c1][_0x23e15a('0x41')],null,util[_0x23e15a('0x8')](_0x23e15a('0x6a'),_0x15b3cf[_0x23e15a('0x59')],_0x15b3cf[_0x23e15a('0x50')][_0x5067c1][_0x23e15a('0x69')],_0x15b3cf[_0x23e15a('0x50')][_0x5067c1][_0x23e15a('0x41')],_0x15b3cf[_0x23e15a('0x50')][_0x5067c1][_0x23e15a('0x2f')]));}}return _0x15b3cf[_0x23e15a('0x60')]&&(_0x15b3cf[_0x23e15a('0x60')]=JSON['parse'](_0x15b3cf[_0x23e15a('0x60')]),_0x569b34[_0x23e15a('0x39')](_0x3ce90c(_0x15b3cf[_0x23e15a('0x60')][_0x23e15a('0x33')]))),_0x492aec=_0x569b34[_0x23e15a('0x1c')](),_0x569b34[_0x23e15a('0x52')](_0x3d4d39),_0x569b34['offset'](0x0),logger[_0x23e15a('0x6c')](_0x23e15a('0x2b'),_0x569b34[_0x23e15a('0xe')]()),db['sequelize']['query'](_0x569b34[_0x23e15a('0xe')](),{'type':QueryTypes['SELECT']});}})['then'](function(_0x3e9013){const _0xb9f67e=_0x1f16b3;if(!_0x3e9013[_0xb9f67e('0x6')])throw new ValidationErrorItem(_0xb9f67e('0x0'),0xcc);if(_0x703c8d[_0xb9f67e('0x8a')]===_0xb9f67e('0x5e'))return null;const _0x263fac=_['merge'](_0x703c8d,{'name':_0x703c8d[_0xb9f67e('0x51')]||_0x703c8d[_0xb9f67e('0x4e')]||_0x15b3cf[_0xb9f67e('0x4e')],'basename':_0xdf070c,'savename':util[_0xb9f67e('0x8')]('%s-%s.%s',_0x703c8d[_0xb9f67e('0x4e')]||_0x15b3cf[_0xb9f67e('0x4e')],require(_0xb9f67e('0x42'))[_0xb9f67e('0x65')](0x4),_0x703c8d[_0xb9f67e('0x8a')]||'csv'),'reportId':_0x15b3cf['id'],'reportType':_0xb9f67e('0x48')});return db[_0xb9f67e('0x9')][_0xb9f67e('0x40')](_0x263fac,{'raw':!![]});})['then'](function(_0x4ca9c8){const _0x5ccf3b=_0x1f16b3;_0x15b3cf[_0x5ccf3b('0x59')]==='cdr'?_0x492aec[_0x5ccf3b('0x39')](_0x15b3cf[_0x5ccf3b('0x59')]+_0x5ccf3b('0x84'),_0x703c8d['startDate'],_0x703c8d['endDate']):_0x492aec[_0x5ccf3b('0x39')](_0x15b3cf[_0x5ccf3b('0x59')]+_0x5ccf3b('0x63'),_0x703c8d['startDate'],_0x703c8d[_0x5ccf3b('0x8d')]);if(_0x4ca9c8)return logger[_0x5ccf3b('0x29')](_0x5ccf3b('0x70'),_0x492aec[_0x5ccf3b('0xe')]()),require(_0x5ccf3b('0x7a'))[_0x5ccf3b('0xa')](path['join'](__dirname,_0x5ccf3b('0x7e'),_0x4ca9c8[_0x5ccf3b('0x8a')]),[_0x4ca9c8['id'],_0x492aec[_0x5ccf3b('0xe')](),path[_0x5ccf3b('0x44')](__dirname,_0x5ccf3b('0x2e'),_0x4ca9c8[_0x5ccf3b('0x62')]),_0xdf070c]),_0x4ca9c8;else{const _0x14090d=squel['select']();return _0x14090d['from']('('+_0x492aec[_0x5ccf3b('0xe')]()+')',_0x5ccf3b('0x76')),_0x14090d[_0x5ccf3b('0x11')]('COUNT(*)',_0x5ccf3b('0x3e')),_0x492aec[_0x5ccf3b('0x52')](_0x703c8d[_0x5ccf3b('0x52')]||_0x3d4d39),_0x492aec[_0x5ccf3b('0x58')](_0x703c8d[_0x5ccf3b('0x58')]||0x0),dbH[_0x5ccf3b('0x18')][_0x5ccf3b('0x32')](_0x14090d[_0x5ccf3b('0xe')](),{'type':dbH[_0x5ccf3b('0x18')][_0x5ccf3b('0x5b')]['SELECT']})[_0x5ccf3b('0x4f')](function(_0x397f91){const _0x51d383=_0x5ccf3b;return!_0x397f91['length']?_0x36f22e=0x0:_0x36f22e=_0x397f91[0x0][_0x51d383('0x3e')]||0x0,dbH[_0x51d383('0x18')][_0x51d383('0x32')](_0x492aec[_0x51d383('0xe')](),{'type':dbH[_0x51d383('0x18')][_0x51d383('0x5b')][_0x51d383('0x5')]});})['then'](function(_0x5f4260){return{'rows':_0x5f4260||[],'count':_0x36f22e};});}});}exports['run']=function(_0x5b0255,_0x415cf0){const _0x3903dc=_0x24a81b;return runReport(_0x5b0255[_0x3903dc('0x64')],_0x5b0255[_0x3903dc('0x32')],_0x5b0255[_0x3903dc('0x6d')])[_0x3903dc('0x4f')](respondWithResult(_0x415cf0,null))['catch'](handleError(_0x415cf0,null));},exports[_0x24a81b('0x80')]=runReport,exports[_0x24a81b('0x32')]=function(_0x384738,_0x2de8d8){const _0x4d0650=_0x24a81b,_0x35864e=0xa,_0x8ebf8=['join',_0x4d0650('0x1'),_0x4d0650('0x55'),_0x4d0650('0x89')],_0x46df91={'SUM':_0x4d0650('0x3b'),'COUNT':'COUNT(%s)','COUNT\x20DISTINCT':_0x4d0650('0x2d'),'MAX':_0x4d0650('0x73'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT\x20ASC':_0x4d0650('0x37'),'GROUP_CONCAT\x20DESC':_0x4d0650('0x71')},_0x3f482b={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x4d0650('0x5a'),'HOUR':'HOUR(%s)','ROUND':_0x4d0650('0x66'),'UNIX_TIMESTAMP':_0x4d0650('0x79')},_0x91e5ed=function(_0x228734){const _0x2fddff=_0x4d0650;return!_[_0x2fddff('0x12')]([_0x2fddff('0x36'),_0x2fddff('0x1d'),_0x2fddff('0x3d'),_0x2fddff('0x82')],_0x228734);},_0x3436ef=function(_0x155f88){const _0x72b8c2=_0x4d0650;if(!_0x155f88||!_0x155f88[_0x72b8c2('0x7')][_0x72b8c2('0x6')])return'';let _0x229907='(';for(let _0x135f1c=0x0;_0x135f1c<_0x155f88[_0x72b8c2('0x7')][_0x72b8c2('0x6')];_0x135f1c+=0x1){_0x135f1c>0x0&&(_0x229907+='\x20'+_0x155f88[_0x72b8c2('0x77')]+'\x20'),_0x229907+=_0x155f88[_0x72b8c2('0x7')][_0x135f1c]['group']?_0x3436ef(_0x155f88[_0x72b8c2('0x7')][_0x135f1c][_0x72b8c2('0x33')]):_0x155f88[_0x72b8c2('0x7')][_0x135f1c][_0x72b8c2('0x11')]+'\x20'+_0x155f88[_0x72b8c2('0x7')][_0x135f1c][_0x72b8c2('0x8e')]+(_0x91e5ed(_0x155f88[_0x72b8c2('0x7')][_0x135f1c]['condition'])?'\x20'+_0x155f88[_0x72b8c2('0x7')][_0x135f1c][_0x72b8c2('0x35')]:'');}return _0x229907+')';};let _0x8a924f={'where':{'id':_0x384738[_0x4d0650('0x64')]['id']}},_0x11394e,_0x59451e,_0x3687b7,_0x39e863;return _0x8a924f=_[_0x4d0650('0x20')]({},_0x8a924f,_0x384738[_0x4d0650('0x6d')]),db[_0x4d0650('0x83')]['findOne'](_0x8a924f)['then'](function(_0x527826){if(_0x527826)return _0x11394e=_0x527826,_0x527826['getFields']();return null;})[_0x4d0650('0x4f')](function(_0x395f19){const _0x321d82=_0x4d0650;if(_0x395f19){if(!_0x395f19[_0x321d82('0x6')])throw new ValidationErrorItem(_0x321d82('0x6b'),0x193);return _0x59451e=_0x395f19,db[_0x321d82('0x85')][_0x321d82('0x74')]({'raw':!![]});}return null;})[_0x4d0650('0x4f')](function(_0x23ecfe){const _0x5035c1=_0x4d0650;if(_0x23ecfe){_0x3687b7=_[_0x5035c1('0x1b')](_0x23ecfe,'id');let _0x49153a;const _0x3439e8=squel[_0x5035c1('0x54')]();_0x3439e8['from'](_0x11394e[_0x5035c1('0x59')]);for(let _0x46658d=0x0;_0x46658d<_0x59451e['length'];_0x46658d+=0x1){_0x49153a=_0x59451e[_0x46658d][_0x5035c1('0x13')]?_0x3687b7[_0x59451e[_0x46658d][_0x5035c1('0x13')]][_0x5035c1('0x3c')]:_0x59451e[_0x46658d][_0x5035c1('0x11')],_0x49153a=_0x59451e[_0x46658d][_0x5035c1('0x68')]?_[_0x5035c1('0x8c')](_0x46df91[_0x59451e[_0x46658d][_0x5035c1('0x68')]],'%s',_0x49153a):_0x49153a,_0x49153a=_0x59451e[_0x46658d][_0x5035c1('0x8')]?_[_0x5035c1('0x8c')](_0x3f482b[_0x59451e[_0x46658d][_0x5035c1('0x8')]],'%s',_0x49153a):_0x49153a,_0x59451e[_0x46658d][_0x5035c1('0x26')]&&_0x3439e8[_0x5035c1('0x33')](_0x49153a),_0x59451e[_0x46658d]['orderBy']&&_0x3439e8[_0x5035c1('0x86')](_0x49153a,_0x59451e[_0x46658d][_0x5035c1('0x30')]==='DESC'?![]:!![]),_0x3439e8[_0x5035c1('0x11')](_0x49153a,_0x59451e[_0x46658d][_0x5035c1('0x38')]||_0x49153a);}if(_0x11394e[_0x5035c1('0x50')]){_0x11394e[_0x5035c1('0x50')]=JSON['parse'](_0x11394e[_0x5035c1('0x50')]);for(let _0x256f2=0x0;_0x256f2<_0x11394e[_0x5035c1('0x50')][_0x5035c1('0x6')];_0x256f2+=0x1){_0x11394e[_0x5035c1('0x50')][_0x256f2][_0x5035c1('0x28')]&&_[_0x5035c1('0x12')](_0x8ebf8,_0x11394e['joins'][_0x256f2][_0x5035c1('0x28')])&&_0x11394e[_0x5035c1('0x50')][_0x256f2]['parentKey']&&_0x11394e['joins'][_0x256f2][_0x5035c1('0x41')]&&_0x11394e[_0x5035c1('0x50')][_0x256f2][_0x5035c1('0x2f')]&&_0x3439e8[_0x11394e[_0x5035c1('0x50')][_0x256f2]['type']](_0x11394e['joins'][_0x256f2]['foreignTable'],null,util[_0x5035c1('0x8')](_0x5035c1('0x6a'),_0x11394e[_0x5035c1('0x59')],_0x11394e[_0x5035c1('0x50')][_0x256f2][_0x5035c1('0x69')],_0x11394e[_0x5035c1('0x50')][_0x256f2][_0x5035c1('0x41')],_0x11394e['joins'][_0x256f2][_0x5035c1('0x2f')]));}}return _0x11394e[_0x5035c1('0x60')]&&(_0x11394e[_0x5035c1('0x60')]=JSON['parse'](_0x11394e[_0x5035c1('0x60')]),_0x3439e8[_0x5035c1('0x39')](_0x3436ef(_0x11394e[_0x5035c1('0x60')]['group']))),_0x39e863=_0x3439e8[_0x5035c1('0x1c')](),_0x3439e8[_0x5035c1('0x52')](_0x35864e),_0x3439e8['offset'](0x0),logger[_0x5035c1('0x6c')](_0x5035c1('0x2b'),_0x3439e8['toString']()),db['sequelize']['query'](_0x3439e8[_0x5035c1('0xe')](),{'type':QueryTypes['SELECT']});}})[_0x4d0650('0x4f')](function(){const _0x960ce9=_0x4d0650;return{'sql':_0x39e863[_0x960ce9('0xe')]()};})[_0x4d0650('0x4f')](respondWithResult(_0x2de8d8,null))['catch'](handleError(_0x2de8d8,null));};
\ No newline at end of file