Built motion from commit ded33658aad58fc8de845a8299a9db59a88cc353. Version 3.0.0...
[motion-next.git] / server / api / analyticCustomReport / analyticCustomReport.controller.js
index 7275110..334c518 100644 (file)
@@ -1 +1 @@
-const a5_0x5715=['GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','end','SUM(%s)','destroy','COUNT(DISTINCT\x20%s)','UserProfileResource','merge','AnalyticCustomReport','IS\x20NOT\x20NULL','index','join','key','length','options','AnalyticExtractedReport','type','web','CustomReports','conditions','set','order','replace','intersection','fieldName','csv','VIRTUAL','AnalyticMetric','stack','%s.%s\x20=\x20%s.%s','Limited\x20Query:','../../mysqldb','right_join','GROUP_CONCAT(%s)','dbH','groupBy','catch','format','includes','query','AVG(%s)','like','findAll','fields','group','select','%s-%s.%s','../../files/reports','runReport','path','MetricId','role','child_process','userProfileId','body','table','attributes','No\x20available\x20data','endDate','keys','cross_join','COUNT(%s)','undefined','foreignTable','preview','MAX(%s)','Unable\x20to\x20retrieve\x20the\x20current\x20user','DATE(%s)','field','SEC_TO_TIME(%s)','rawAttributes','update','parentKey','offset','sequelize','sort','status','model','getFields','function','map','create','keyBy','parse','left_join','debug','nolimit','foreignKey','Reports','MIN(%s)','sendStatus','IS\x20NOT\x20EMPTY','alias','clone','params','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','joins','error','SELECT','filters','DESC','savename','limit','ROUND(%s)','operator','includeAll','toString','IS\x20EMPTY','name','orderBy','then','pick','count','rules','output','HOUR(%s)','api','include','value','condition','../../components/export/','startDate','UNIX_TIMESTAMP(%s)','../../config/logger','get','Please\x20insert\x20at\x20least\x20one\x20field','show','autoAssociation','filter','.createdAt\x20BETWEEN\x20?\x20AND\x20?','from','randomstring','findOne','Content-Range','json','IS\x20NULL','metric','util','countTable','where'];(function(_0x580bf0,_0x571569){const _0x5b9f50=function(_0x59d2c6){while(--_0x59d2c6){_0x580bf0['push'](_0x580bf0['shift']());}};_0x5b9f50(++_0x571569);}(a5_0x5715,0x1ef));const a5_0x5b9f=function(_0x580bf0,_0x571569){_0x580bf0=_0x580bf0-0x0;let _0x5b9f50=a5_0x5715[_0x580bf0];return _0x5b9f50;};const _0x29b815=a5_0x5b9f;'use strict';const util=require(_0x29b815('0x3a')),path=require(_0x29b815('0x6d')),_=require('lodash'),squel=require('squel'),qs=require('../../components/parsers/qs'),logger=require(_0x29b815('0x2c'))(_0x29b815('0x25')),db=require(_0x29b815('0x5b'))['db'],dbH=require(_0x29b815('0x5b'))[_0x29b815('0x5e')],{Op,ValidationErrorItem,QueryTypes}=require(_0x29b815('0x86'));function respondWithResult(_0x59d2c6,_0x13e972){return _0x13e972=_0x13e972||0xc8,function(_0x2225c8){const _0x410f0b=a5_0x5b9f;if(_0x2225c8)return _0x59d2c6[_0x410f0b('0x88')](_0x13e972)['json'](_0x2225c8);};}function respondWithFilteredResult(_0x38f48b,_0x1360fe){return function(_0x4b4bee){const _0x11692a=a5_0x5b9f;if(_0x4b4bee){const _0x1efe6c=_0x4b4bee[_0x11692a('0x21')],_0x4cecf3=_0x1360fe[_0x11692a('0x85')];let _0x3ac877=_0x1360fe[_0x11692a('0x85')]+_0x1360fe[_0x11692a('0x17')],_0x2b848e;return _0x3ac877>=_0x1efe6c?(_0x3ac877=_0x1efe6c,_0x2b848e=0xc8):_0x2b848e=0xce,_0x38f48b[_0x11692a('0x88')](_0x2b848e),_0x38f48b[_0x11692a('0x50')](_0x11692a('0x36'),_0x4cecf3+'-'+_0x3ac877+'/'+_0x1efe6c)[_0x11692a('0x37')](_0x4b4bee);}return null;};}function saveUpdates(_0x1967fb){return function(_0x3112cf){const _0x4b4e45=a5_0x5b9f;if(_0x3112cf)return _0x3112cf[_0x4b4e45('0x83')](_0x1967fb)['then'](function(_0x1939ca){return _0x1939ca;});return null;};}function removeEntity(_0x479a4b){return function(_0x570eda){const _0x1f103e=a5_0x5b9f;if(_0x570eda)return _0x570eda[_0x1f103e('0x40')]()[_0x1f103e('0x1f')](function(){const _0x229bb7=_0x1f103e,_0x2dda97=_0x570eda[_0x229bb7('0x2d')]({'plain':!![]}),_0x177635='CustomReports';return db['UserProfileResource']['destroy']({'where':{'type':_0x177635,'resourceId':_0x2dda97['id']}})['then'](function(){return _0x570eda;});})['then'](function(){const _0x3adcb5=_0x1f103e;_0x479a4b['status'](0xcc)[_0x3adcb5('0x3e')]();});};}function handleEntityNotFound(_0xb5a386){return function(_0x401462){const _0x3c8548=a5_0x5b9f;return!_0x401462&&_0xb5a386[_0x3c8548('0xb')](0x194),_0x401462;};}function handleError(_0x5f37c8,_0xbd4a30){return _0xbd4a30=_0xbd4a30||0x1f4,function(_0x383536){const _0x51c833=a5_0x5b9f;logger[_0x51c833('0x12')](_0x383536[_0x51c833('0x58')]),_0x383536[_0x51c833('0x1d')]&&delete _0x383536[_0x51c833('0x1d')],_0x5f37c8[_0x51c833('0x88')](_0xbd4a30)['send'](_0x383536);};}exports[_0x29b815('0x46')]=function(_0x14284b,_0x5131bd){const _0x173d1d=_0x29b815;let _0x572bc0={};const _0x2b7a72={},_0x28eac2={'count':0x0,'rows':[]},_0x1825e6=_[_0x173d1d('0x1')](db['AnalyticCustomReport'][_0x173d1d('0x82')],function(_0x194e3e){const _0xb17c90=_0x173d1d;return{'name':_0x194e3e[_0xb17c90('0x54')],'type':_0x194e3e['type'][_0xb17c90('0x48')]};});_0x2b7a72[_0x173d1d('0x89')]=_[_0x173d1d('0x1')](_0x1825e6,_0x173d1d('0x1d')),_0x2b7a72[_0x173d1d('0x63')]=_['keys'](_0x14284b[_0x173d1d('0x63')]),_0x2b7a72[_0x173d1d('0x14')]=_['intersection'](_0x2b7a72[_0x173d1d('0x89')],_0x2b7a72[_0x173d1d('0x63')]),_0x572bc0[_0x173d1d('0x74')]=_[_0x173d1d('0x53')](_0x2b7a72[_0x173d1d('0x89')],qs[_0x173d1d('0x67')](_0x14284b[_0x173d1d('0x63')][_0x173d1d('0x67')])),_0x572bc0[_0x173d1d('0x74')]=_0x572bc0[_0x173d1d('0x74')][_0x173d1d('0x49')]?_0x572bc0[_0x173d1d('0x74')]:_0x2b7a72[_0x173d1d('0x89')];typeof _0x14284b[_0x173d1d('0x63')][_0x173d1d('0x7')]===_0x173d1d('0x7a')&&(_0x572bc0['limit']=qs['limit'](_0x14284b['query'][_0x173d1d('0x17')]),_0x572bc0[_0x173d1d('0x85')]=qs['offset'](_0x14284b[_0x173d1d('0x63')][_0x173d1d('0x85')]));_0x572bc0['order']=qs[_0x173d1d('0x87')](_0x14284b['query']['sort']),_0x572bc0[_0x173d1d('0x3c')]=qs[_0x173d1d('0x14')](_[_0x173d1d('0x20')](_0x14284b[_0x173d1d('0x63')],_0x2b7a72[_0x173d1d('0x14')]),_0x1825e6);_0x14284b[_0x173d1d('0x63')][_0x173d1d('0x31')]&&(_0x572bc0['where']=_[_0x173d1d('0x43')](_0x572bc0[_0x173d1d('0x3c')],{[Op['or']]:_[_0x173d1d('0x1')](_0x1825e6,function(_0x13ceca){const _0x37c039=_0x173d1d;if(_0x13ceca['type']!==_0x37c039('0x56')){const _0x52b6ac={};return _0x52b6ac[_0x13ceca[_0x37c039('0x1d')]]={[Op[_0x37c039('0x65')]]:'%'+_0x14284b[_0x37c039('0x63')]['filter']+'%'},_0x52b6ac;}})}));_0x572bc0=_[_0x173d1d('0x43')]({},_0x572bc0,_0x14284b[_0x173d1d('0x4a')]);const _0x26ff6c={'where':_0x572bc0[_0x173d1d('0x3c')]};return db[_0x173d1d('0x44')][_0x173d1d('0x21')](_0x26ff6c)[_0x173d1d('0x1f')](function(_0x2e14e5){const _0xaeb9e=_0x173d1d;return _0x28eac2['count']=_0x2e14e5,_0x14284b[_0xaeb9e('0x63')][_0xaeb9e('0x1a')]&&(_0x572bc0[_0xaeb9e('0x26')]=[{'all':!![]}]),db[_0xaeb9e('0x44')][_0xaeb9e('0x66')](_0x572bc0);})['then'](function(_0x5bd880){return _0x28eac2['rows']=_0x5bd880,_0x28eac2;})[_0x173d1d('0x1f')](respondWithFilteredResult(_0x5131bd,_0x572bc0))['catch'](handleError(_0x5131bd,null));},exports[_0x29b815('0x2f')]=function(_0xbf2c5e,_0xa3c54a){const _0x2ae4f2=_0x29b815;let _0xadd30e={'raw':![],'where':{'id':_0xbf2c5e[_0x2ae4f2('0xf')]['id']}};const _0x324329={};return _0x324329[_0x2ae4f2('0x89')]=_[_0x2ae4f2('0x77')](db[_0x2ae4f2('0x44')][_0x2ae4f2('0x82')]),_0x324329[_0x2ae4f2('0x63')]=_['keys'](_0xbf2c5e[_0x2ae4f2('0x63')]),_0x324329['filters']=_[_0x2ae4f2('0x53')](_0x324329[_0x2ae4f2('0x89')],_0x324329[_0x2ae4f2('0x63')]),_0xadd30e[_0x2ae4f2('0x74')]=_[_0x2ae4f2('0x53')](_0x324329['model'],qs['fields'](_0xbf2c5e[_0x2ae4f2('0x63')]['fields'])),_0xadd30e[_0x2ae4f2('0x74')]=_0xadd30e[_0x2ae4f2('0x74')]['length']?_0xadd30e[_0x2ae4f2('0x74')]:_0x324329[_0x2ae4f2('0x89')],_0xbf2c5e[_0x2ae4f2('0x63')][_0x2ae4f2('0x1a')]&&(_0xadd30e[_0x2ae4f2('0x26')]=[{'all':!![]}]),_0xadd30e=_['merge']({},_0xadd30e,_0xbf2c5e[_0x2ae4f2('0x4a')]),db[_0x2ae4f2('0x44')][_0x2ae4f2('0x35')](_0xadd30e)['then'](handleEntityNotFound(_0xa3c54a,null))[_0x2ae4f2('0x1f')](respondWithResult(_0xa3c54a,null))[_0x2ae4f2('0x60')](handleError(_0xa3c54a,null));},exports[_0x29b815('0x2')]=function(_0xbc8b6e,_0x58aa70){const _0xf2624d=_0x29b815;return db[_0xf2624d('0x44')][_0xf2624d('0x2')](_0xbc8b6e['body'],{})[_0xf2624d('0x1f')](function(_0xc63a26){const _0x7f1a0c=_0xf2624d,_0x26e2dc=_0xbc8b6e['user'][_0x7f1a0c('0x2d')]({'plain':!![]});if(!_0x26e2dc)throw new Error(_0x7f1a0c('0x7e'));if(_0x26e2dc[_0x7f1a0c('0x6f')]==='user'){const _0x3bb4fc=_0xc63a26['get']({'plain':!![]}),_0x38537e=_0x7f1a0c('0x9');return db['UserProfileSection'][_0x7f1a0c('0x35')]({'where':{'name':_0x38537e,'userProfileId':_0x26e2dc[_0x7f1a0c('0x71')]},'raw':!![]})['then'](function(_0x20c8ac){const _0x1bb703=_0x7f1a0c;return _0x20c8ac&&_0x20c8ac[_0x1bb703('0x30')]===0x0?db[_0x1bb703('0x42')][_0x1bb703('0x2')]({'name':_0x3bb4fc['name'],'resourceId':_0x3bb4fc['id'],'type':_0x1bb703('0x4e'),'sectionId':_0x20c8ac['id']},{})['then'](function(){return _0xc63a26;}):_0xc63a26;})[_0x7f1a0c('0x60')](function(_0x277acd){const _0x3e01c4=_0x7f1a0c;logger[_0x3e01c4('0x12')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x277acd);throw _0x277acd;});}return _0xc63a26;})[_0xf2624d('0x1f')](respondWithResult(_0x58aa70,0xc9))[_0xf2624d('0x60')](handleError(_0x58aa70,null));},exports[_0x29b815('0x83')]=function(_0xbacc25,_0x5215fe){const _0x1ae77b=_0x29b815;return _0xbacc25[_0x1ae77b('0x72')]['id']&&delete _0xbacc25[_0x1ae77b('0x72')]['id'],db['AnalyticCustomReport']['findOne']({'where':{'id':_0xbacc25[_0x1ae77b('0xf')]['id']}})[_0x1ae77b('0x1f')](handleEntityNotFound(_0x5215fe,null))['then'](saveUpdates(_0xbacc25[_0x1ae77b('0x72')],null))[_0x1ae77b('0x1f')](respondWithResult(_0x5215fe,null))[_0x1ae77b('0x60')](handleError(_0x5215fe,null));},exports[_0x29b815('0x40')]=function(_0x288305,_0x1c951a){const _0x52dfc9=_0x29b815;return db[_0x52dfc9('0x44')][_0x52dfc9('0x35')]({'where':{'id':_0x288305[_0x52dfc9('0xf')]['id']}})['then'](handleEntityNotFound(_0x1c951a,null))['then'](removeEntity(_0x1c951a,null))['catch'](handleError(_0x1c951a,null));},exports[_0x29b815('0x7c')]=function(_0xb37778,_0x3fe37a){const _0x35223b=_0x29b815,_0xf5ee0b=0xa,_0x1bb909=[_0x35223b('0x47'),'left_join','right_join',_0x35223b('0x78')],_0x28d027={'SUM':_0x35223b('0x3f'),'COUNT':_0x35223b('0x79'),'COUNT\x20DISTINCT':_0x35223b('0x41'),'MAX':_0x35223b('0x7d'),'MIN':_0x35223b('0xa'),'AVG':_0x35223b('0x64'),'GROUP_CONCAT':_0x35223b('0x5d'),'GROUP_CONCAT\x20ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT\x20DESC':_0x35223b('0x10')},_0x7ab46={'SEC_TO_TIME':_0x35223b('0x81'),'DATE':_0x35223b('0x7f'),'HOUR':_0x35223b('0x24'),'ROUND':_0x35223b('0x18'),'UNIX_TIMESTAMP':_0x35223b('0x2b')},_0x31a541=function(_0x330b02){const _0x39c368=_0x35223b;return!_[_0x39c368('0x62')]([_0x39c368('0x38'),_0x39c368('0x45'),_0x39c368('0x1c'),_0x39c368('0xc')],_0x330b02);},_0x127488=function(_0x17aad6){const _0x198a94=_0x35223b;if(!_0x17aad6||!_0x17aad6['rules'][_0x198a94('0x49')])return'';let _0x50ac27='(';for(let _0x2fbea8=0x0;_0x2fbea8<_0x17aad6['rules'][_0x198a94('0x49')];_0x2fbea8+=0x1){_0x2fbea8>0x0&&(_0x50ac27+='\x20'+_0x17aad6[_0x198a94('0x19')]+'\x20'),_0x50ac27+=_0x17aad6[_0x198a94('0x22')][_0x2fbea8][_0x198a94('0x68')]?_0x127488(_0x17aad6[_0x198a94('0x22')][_0x2fbea8][_0x198a94('0x68')]):_0x17aad6[_0x198a94('0x22')][_0x2fbea8]['field']+'\x20'+_0x17aad6['rules'][_0x2fbea8][_0x198a94('0x28')]+(_0x31a541(_0x17aad6[_0x198a94('0x22')][_0x2fbea8]['condition'])?'\x20'+_0x17aad6[_0x198a94('0x22')][_0x2fbea8][_0x198a94('0x27')]:'');}return _0x50ac27+')';};let _0x42059d={'where':{'id':_0xb37778[_0x35223b('0xf')]['id']}},_0x3341b9,_0xc53e72,_0x2486a0;return _0x42059d=_['merge']({},_0x42059d,_0xb37778[_0x35223b('0x4a')]),db[_0x35223b('0x44')][_0x35223b('0x35')](_0x42059d)[_0x35223b('0x1f')](function(_0x3d760e){if(_0x3d760e)return _0x3341b9=_0x3d760e,_0x3d760e['getFields']();return null;})[_0x35223b('0x1f')](function(_0x12be66){const _0x30661d=_0x35223b;if(_0x12be66){if(!_0x12be66[_0x30661d('0x49')])throw new ValidationErrorItem(_0x30661d('0x2e'),0x193);return _0xc53e72=_0x12be66,db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0x35223b('0x1f')](function(_0x1dd106){const _0x21cab9=_0x35223b;if(_0x1dd106){_0x2486a0=_['keyBy'](_0x1dd106,'id');let _0x581370;const _0x3c0e47=squel[_0x21cab9('0x69')]();_0x3c0e47[_0x21cab9('0x33')](_0x3341b9[_0x21cab9('0x73')]);for(let _0x57235a=0x0;_0x57235a<_0xc53e72[_0x21cab9('0x49')];_0x57235a+=0x1){_0x581370=_0xc53e72[_0x57235a][_0x21cab9('0x6e')]?_0x2486a0[_0xc53e72[_0x57235a][_0x21cab9('0x6e')]][_0x21cab9('0x39')]:_0xc53e72[_0x57235a][_0x21cab9('0x80')],_0x581370=_0xc53e72[_0x57235a][_0x21cab9('0x0')]?_[_0x21cab9('0x52')](_0x28d027[_0xc53e72[_0x57235a][_0x21cab9('0x0')]],'%s',_0x581370):_0x581370,_0x581370=_0xc53e72[_0x57235a]['format']?_[_0x21cab9('0x52')](_0x7ab46[_0xc53e72[_0x57235a]['format']],'%s',_0x581370):_0x581370,_0xc53e72[_0x57235a][_0x21cab9('0x5f')]&&_0x3c0e47[_0x21cab9('0x68')](_0x581370),_0xc53e72[_0x57235a]['orderBy']&&_0x3c0e47[_0x21cab9('0x51')](_0x581370,_0xc53e72[_0x57235a]['orderBy']==='DESC'?![]:!![]),_0x3c0e47[_0x21cab9('0x80')](_0x581370,_0xc53e72[_0x57235a][_0x21cab9('0xd')]||_0x581370);}if(_0x3341b9[_0x21cab9('0x11')]){_0x3341b9['joins']=JSON[_0x21cab9('0x4')](_0x3341b9[_0x21cab9('0x11')]);for(let _0x4bf805=0x0;_0x4bf805<_0x3341b9[_0x21cab9('0x11')][_0x21cab9('0x49')];_0x4bf805+=0x1){_0x3341b9[_0x21cab9('0x11')][_0x4bf805][_0x21cab9('0x4c')]&&_[_0x21cab9('0x62')](_0x1bb909,_0x3341b9[_0x21cab9('0x11')][_0x4bf805]['type'])&&_0x3341b9[_0x21cab9('0x11')][_0x4bf805][_0x21cab9('0x84')]&&_0x3341b9[_0x21cab9('0x11')][_0x4bf805][_0x21cab9('0x7b')]&&_0x3341b9['joins'][_0x4bf805]['foreignKey']&&_0x3c0e47[_0x3341b9[_0x21cab9('0x11')][_0x4bf805][_0x21cab9('0x4c')]](_0x3341b9[_0x21cab9('0x11')][_0x4bf805]['foreignTable'],null,util['format']('%s.%s\x20=\x20%s.%s',_0x3341b9[_0x21cab9('0x73')],_0x3341b9[_0x21cab9('0x11')][_0x4bf805][_0x21cab9('0x84')],_0x3341b9[_0x21cab9('0x11')][_0x4bf805][_0x21cab9('0x7b')],_0x3341b9[_0x21cab9('0x11')][_0x4bf805][_0x21cab9('0x8')]));}}return _0x3341b9[_0x21cab9('0x4f')]&&(_0x3341b9[_0x21cab9('0x4f')]=JSON['parse'](_0x3341b9['conditions']),_0x3c0e47[_0x21cab9('0x3c')](_0x127488(_0x3341b9[_0x21cab9('0x4f')][_0x21cab9('0x68')]))),_0x3c0e47[_0x21cab9('0x17')](_0xf5ee0b),_0x3c0e47[_0x21cab9('0x85')](0x0),logger['debug'](_0x21cab9('0x5a'),_0x3c0e47[_0x21cab9('0x1b')]()),db['sequelize'][_0x21cab9('0x63')](_0x3c0e47['toString'](),{'type':QueryTypes['SELECT']});}})[_0x35223b('0x1f')](respondWithResult(_0x3fe37a,null))['catch'](handleError(_0x3fe37a,null));};function runReport(_0x50522d,_0x3a372a,_0x279c92){const _0x161361=_0x29b815,_0x400df3=_0x3a372a[_0x161361('0x1d')],_0x1297f2=0xa,_0x20185e=['join',_0x161361('0x5'),'right_join',_0x161361('0x78')],_0x42859e={'SUM':_0x161361('0x3f'),'COUNT':_0x161361('0x79'),'COUNT\x20DISTINCT':_0x161361('0x41'),'MAX':_0x161361('0x7d'),'MIN':_0x161361('0xa'),'AVG':_0x161361('0x64'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT\x20ASC':_0x161361('0x3d'),'GROUP_CONCAT\x20DESC':_0x161361('0x10')},_0x1c0148={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x161361('0x7f'),'HOUR':_0x161361('0x24'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x161361('0x2b')},_0x39d509=function(_0x16a5d9){const _0x2ab450=_0x161361;return!_[_0x2ab450('0x62')](['IS\x20NULL',_0x2ab450('0x45'),'IS\x20EMPTY',_0x2ab450('0xc')],_0x16a5d9);},_0x28972b=function(_0x5cb78f){const _0x458689=_0x161361;if(!_0x5cb78f||!_0x5cb78f[_0x458689('0x22')]['length'])return'';let _0xb3454d='(';for(let _0x4871da=0x0;_0x4871da<_0x5cb78f[_0x458689('0x22')][_0x458689('0x49')];_0x4871da+=0x1){_0x4871da>0x0&&(_0xb3454d+='\x20'+_0x5cb78f['operator']+'\x20'),_0xb3454d+=_0x5cb78f[_0x458689('0x22')][_0x4871da][_0x458689('0x68')]?_0x28972b(_0x5cb78f['rules'][_0x4871da][_0x458689('0x68')]):_0x5cb78f[_0x458689('0x22')][_0x4871da][_0x458689('0x80')]+'\x20'+_0x5cb78f[_0x458689('0x22')][_0x4871da][_0x458689('0x28')]+(_0x39d509(_0x5cb78f[_0x458689('0x22')][_0x4871da]['condition'])?'\x20'+_0x5cb78f[_0x458689('0x22')][_0x4871da]['value']:'');}return _0xb3454d+')';};let _0x41fb38={'where':{'id':_0x50522d['id']}},_0x4553df,_0x200311,_0x5e99bc,_0x4dd186,_0x11864a;return _0x41fb38=_['merge']({},_0x41fb38,_0x279c92),db[_0x161361('0x44')][_0x161361('0x35')](_0x41fb38)[_0x161361('0x1f')](function(_0x15543b){const _0x356e2d=_0x161361;if(_0x15543b)return _0x4553df=_0x15543b,_0x15543b[_0x356e2d('0x8a')]();return null;})['then'](function(_0x4fb5e5){const _0x277e21=_0x161361;if(_0x4fb5e5){if(!_0x4fb5e5['length'])throw new ValidationErrorItem(_0x277e21('0x2e'),0x193);return _0x200311=_0x4fb5e5,db['AnalyticMetric'][_0x277e21('0x66')]({'raw':!![]});}return null;})['then'](function(_0x2032cc){const _0x2aeccf=_0x161361;if(_0x2032cc){_0x5e99bc=_[_0x2aeccf('0x3')](_0x2032cc,'id');let _0x5b7bb1;const _0x4fce65=squel[_0x2aeccf('0x69')]();_0x4fce65[_0x2aeccf('0x33')](_0x4553df[_0x2aeccf('0x73')]);for(let _0x158b13=0x0;_0x158b13<_0x200311[_0x2aeccf('0x49')];_0x158b13+=0x1){_0x5b7bb1=_0x200311[_0x158b13]['MetricId']?_0x5e99bc[_0x200311[_0x158b13][_0x2aeccf('0x6e')]][_0x2aeccf('0x39')]:_0x200311[_0x158b13]['field'],_0x5b7bb1=_0x200311[_0x158b13][_0x2aeccf('0x0')]?_[_0x2aeccf('0x52')](_0x42859e[_0x200311[_0x158b13]['function']],'%s',_0x5b7bb1):_0x5b7bb1,_0x5b7bb1=_0x200311[_0x158b13][_0x2aeccf('0x61')]?_['replace'](_0x1c0148[_0x200311[_0x158b13][_0x2aeccf('0x61')]],'%s',_0x5b7bb1):_0x5b7bb1,_0x200311[_0x158b13]['groupBy']&&_0x4fce65['group'](_0x5b7bb1),_0x200311[_0x158b13]['orderBy']&&_0x4fce65['order'](_0x5b7bb1,_0x200311[_0x158b13][_0x2aeccf('0x1e')]===_0x2aeccf('0x15')?![]:!![]),_0x4fce65[_0x2aeccf('0x80')](_0x5b7bb1,_0x200311[_0x158b13][_0x2aeccf('0xd')]||_0x5b7bb1);}if(_0x4553df[_0x2aeccf('0x11')]){_0x4553df[_0x2aeccf('0x11')]=JSON[_0x2aeccf('0x4')](_0x4553df['joins']);for(let _0x3e70f9=0x0;_0x3e70f9<_0x4553df[_0x2aeccf('0x11')][_0x2aeccf('0x49')];_0x3e70f9+=0x1){_0x4553df[_0x2aeccf('0x11')][_0x3e70f9][_0x2aeccf('0x4c')]&&_[_0x2aeccf('0x62')](_0x20185e,_0x4553df[_0x2aeccf('0x11')][_0x3e70f9]['type'])&&_0x4553df[_0x2aeccf('0x11')][_0x3e70f9][_0x2aeccf('0x84')]&&_0x4553df[_0x2aeccf('0x11')][_0x3e70f9]['foreignTable']&&_0x4553df['joins'][_0x3e70f9]['foreignKey']&&_0x4fce65[_0x4553df[_0x2aeccf('0x11')][_0x3e70f9][_0x2aeccf('0x4c')]](_0x4553df[_0x2aeccf('0x11')][_0x3e70f9][_0x2aeccf('0x7b')],null,util['format'](_0x2aeccf('0x59'),_0x4553df[_0x2aeccf('0x73')],_0x4553df[_0x2aeccf('0x11')][_0x3e70f9][_0x2aeccf('0x84')],_0x4553df[_0x2aeccf('0x11')][_0x3e70f9]['foreignTable'],_0x4553df[_0x2aeccf('0x11')][_0x3e70f9]['foreignKey']));}}return _0x4553df['conditions']&&(_0x4553df['conditions']=JSON['parse'](_0x4553df[_0x2aeccf('0x4f')]),_0x4fce65['where'](_0x28972b(_0x4553df[_0x2aeccf('0x4f')][_0x2aeccf('0x68')]))),_0x11864a=_0x4fce65[_0x2aeccf('0xe')](),_0x4fce65[_0x2aeccf('0x17')](_0x1297f2),_0x4fce65[_0x2aeccf('0x85')](0x0),logger[_0x2aeccf('0x6')]('Limited\x20Query:',_0x4fce65[_0x2aeccf('0x1b')]()),db[_0x2aeccf('0x86')]['query'](_0x4fce65[_0x2aeccf('0x1b')](),{'type':QueryTypes[_0x2aeccf('0x13')]});}})[_0x161361('0x1f')](function(_0x3c6a15){const _0x524477=_0x161361;if(!_0x3c6a15[_0x524477('0x49')])throw new ValidationErrorItem(_0x524477('0x75'),0xcc);if(_0x3a372a[_0x524477('0x23')]===_0x524477('0x4d'))return null;const _0x3037e6=_['merge'](_0x3a372a,{'name':_0x3a372a['fullPath']||_0x3a372a[_0x524477('0x1d')]||_0x4553df[_0x524477('0x1d')],'basename':_0x400df3,'savename':util[_0x524477('0x61')](_0x524477('0x6a'),_0x3a372a[_0x524477('0x1d')]||_0x4553df[_0x524477('0x1d')],require(_0x524477('0x34'))['generate'](0x4),_0x3a372a[_0x524477('0x23')]||_0x524477('0x55')),'reportId':_0x4553df['id'],'reportType':'custom'});return db[_0x524477('0x4b')][_0x524477('0x2')](_0x3037e6,{'raw':!![]});})['then'](function(_0x557244){const _0x1f1286=_0x161361;_0x4553df[_0x1f1286('0x73')]==='cdr'?_0x11864a['where'](_0x4553df[_0x1f1286('0x73')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x3a372a[_0x1f1286('0x2a')],_0x3a372a['endDate']):_0x11864a[_0x1f1286('0x3c')](_0x4553df[_0x1f1286('0x73')]+_0x1f1286('0x32'),_0x3a372a[_0x1f1286('0x2a')],_0x3a372a[_0x1f1286('0x76')]);if(_0x557244)return logger['info']('Run\x20Query:',_0x11864a['toString']()),require(_0x1f1286('0x70'))['fork'](path[_0x1f1286('0x47')](__dirname,_0x1f1286('0x29'),_0x557244[_0x1f1286('0x23')]),[_0x557244['id'],_0x11864a['toString'](),path['join'](__dirname,_0x1f1286('0x6b'),_0x557244[_0x1f1286('0x16')]),_0x400df3]),_0x557244;else{const _0xa35796=squel[_0x1f1286('0x69')]();return _0xa35796[_0x1f1286('0x33')]('('+_0x11864a['toString']()+')',_0x1f1286('0x3b')),_0xa35796[_0x1f1286('0x80')]('COUNT(*)','count'),_0x11864a[_0x1f1286('0x17')](_0x3a372a[_0x1f1286('0x17')]||_0x1297f2),_0x11864a[_0x1f1286('0x85')](_0x3a372a['offset']||0x0),dbH[_0x1f1286('0x86')]['query'](_0xa35796[_0x1f1286('0x1b')](),{'type':dbH[_0x1f1286('0x86')]['QueryTypes'][_0x1f1286('0x13')]})[_0x1f1286('0x1f')](function(_0x4b6c22){const _0x36fcc1=_0x1f1286;return!_0x4b6c22[_0x36fcc1('0x49')]?_0x4dd186=0x0:_0x4dd186=_0x4b6c22[0x0]['count']||0x0,dbH[_0x36fcc1('0x86')]['query'](_0x11864a[_0x36fcc1('0x1b')](),{'type':dbH[_0x36fcc1('0x86')]['QueryTypes'][_0x36fcc1('0x13')]});})[_0x1f1286('0x1f')](function(_0x3b1bb2){return{'rows':_0x3b1bb2||[],'count':_0x4dd186};});}});}exports['run']=function(_0x5657c7,_0x4b4f34){const _0x5993a9=_0x29b815;return runReport(_0x5657c7[_0x5993a9('0xf')],_0x5657c7[_0x5993a9('0x63')],_0x5657c7[_0x5993a9('0x4a')])[_0x5993a9('0x1f')](respondWithResult(_0x4b4f34,null))[_0x5993a9('0x60')](handleError(_0x4b4f34,null));},exports[_0x29b815('0x6c')]=runReport,exports['query']=function(_0x479d10,_0x2d211f){const _0xdd163=_0x29b815,_0x4b6398=0xa,_0x4ad330=[_0xdd163('0x47'),_0xdd163('0x5'),_0xdd163('0x5c'),'cross_join'],_0x529d58={'SUM':_0xdd163('0x3f'),'COUNT':_0xdd163('0x79'),'COUNT\x20DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xdd163('0x7d'),'MIN':'MIN(%s)','AVG':_0xdd163('0x64'),'GROUP_CONCAT':_0xdd163('0x5d'),'GROUP_CONCAT\x20ASC':_0xdd163('0x3d'),'GROUP_CONCAT\x20DESC':_0xdd163('0x10')},_0x297a73={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xdd163('0x7f'),'HOUR':'HOUR(%s)','ROUND':_0xdd163('0x18'),'UNIX_TIMESTAMP':_0xdd163('0x2b')},_0x7eefb8=function(_0x3bf1dd){const _0x59e21f=_0xdd163;return!_['includes']([_0x59e21f('0x38'),_0x59e21f('0x45'),'IS\x20EMPTY','IS\x20NOT\x20EMPTY'],_0x3bf1dd);},_0x1b2b02=function(_0xbf5b11){const _0x2a6914=_0xdd163;if(!_0xbf5b11||!_0xbf5b11[_0x2a6914('0x22')]['length'])return'';let _0x29cb59='(';for(let _0xa79805=0x0;_0xa79805<_0xbf5b11['rules'][_0x2a6914('0x49')];_0xa79805+=0x1){_0xa79805>0x0&&(_0x29cb59+='\x20'+_0xbf5b11[_0x2a6914('0x19')]+'\x20'),_0x29cb59+=_0xbf5b11[_0x2a6914('0x22')][_0xa79805][_0x2a6914('0x68')]?_0x1b2b02(_0xbf5b11['rules'][_0xa79805][_0x2a6914('0x68')]):_0xbf5b11[_0x2a6914('0x22')][_0xa79805][_0x2a6914('0x80')]+'\x20'+_0xbf5b11[_0x2a6914('0x22')][_0xa79805][_0x2a6914('0x28')]+(_0x7eefb8(_0xbf5b11[_0x2a6914('0x22')][_0xa79805][_0x2a6914('0x28')])?'\x20'+_0xbf5b11[_0x2a6914('0x22')][_0xa79805]['value']:'');}return _0x29cb59+')';};let _0x48eb6f={'where':{'id':_0x479d10[_0xdd163('0xf')]['id']}},_0x1935c5,_0x200c44,_0x5f5254,_0x1fb34c;return _0x48eb6f=_['merge']({},_0x48eb6f,_0x479d10[_0xdd163('0x4a')]),db[_0xdd163('0x44')]['findOne'](_0x48eb6f)['then'](function(_0x14e998){const _0x5ad33e=_0xdd163;if(_0x14e998)return _0x1935c5=_0x14e998,_0x14e998[_0x5ad33e('0x8a')]();return null;})[_0xdd163('0x1f')](function(_0x39ea57){const _0x2a1bf3=_0xdd163;if(_0x39ea57){if(!_0x39ea57[_0x2a1bf3('0x49')])throw new ValidationErrorItem('Please\x20insert\x20at\x20least\x20one\x20field',0x193);return _0x200c44=_0x39ea57,db[_0x2a1bf3('0x57')][_0x2a1bf3('0x66')]({'raw':!![]});}return null;})[_0xdd163('0x1f')](function(_0x124d06){const _0x105c50=_0xdd163;if(_0x124d06){_0x5f5254=_['keyBy'](_0x124d06,'id');let _0x28bc40;const _0x5aeba1=squel[_0x105c50('0x69')]();_0x5aeba1[_0x105c50('0x33')](_0x1935c5[_0x105c50('0x73')]);for(let _0x13f320=0x0;_0x13f320<_0x200c44[_0x105c50('0x49')];_0x13f320+=0x1){_0x28bc40=_0x200c44[_0x13f320][_0x105c50('0x6e')]?_0x5f5254[_0x200c44[_0x13f320][_0x105c50('0x6e')]][_0x105c50('0x39')]:_0x200c44[_0x13f320][_0x105c50('0x80')],_0x28bc40=_0x200c44[_0x13f320]['function']?_[_0x105c50('0x52')](_0x529d58[_0x200c44[_0x13f320][_0x105c50('0x0')]],'%s',_0x28bc40):_0x28bc40,_0x28bc40=_0x200c44[_0x13f320][_0x105c50('0x61')]?_['replace'](_0x297a73[_0x200c44[_0x13f320]['format']],'%s',_0x28bc40):_0x28bc40,_0x200c44[_0x13f320][_0x105c50('0x5f')]&&_0x5aeba1[_0x105c50('0x68')](_0x28bc40),_0x200c44[_0x13f320][_0x105c50('0x1e')]&&_0x5aeba1[_0x105c50('0x51')](_0x28bc40,_0x200c44[_0x13f320][_0x105c50('0x1e')]==='DESC'?![]:!![]),_0x5aeba1['field'](_0x28bc40,_0x200c44[_0x13f320][_0x105c50('0xd')]||_0x28bc40);}if(_0x1935c5[_0x105c50('0x11')]){_0x1935c5['joins']=JSON[_0x105c50('0x4')](_0x1935c5['joins']);for(let _0x476827=0x0;_0x476827<_0x1935c5['joins'][_0x105c50('0x49')];_0x476827+=0x1){_0x1935c5[_0x105c50('0x11')][_0x476827]['type']&&_[_0x105c50('0x62')](_0x4ad330,_0x1935c5[_0x105c50('0x11')][_0x476827][_0x105c50('0x4c')])&&_0x1935c5[_0x105c50('0x11')][_0x476827][_0x105c50('0x84')]&&_0x1935c5[_0x105c50('0x11')][_0x476827]['foreignTable']&&_0x1935c5[_0x105c50('0x11')][_0x476827][_0x105c50('0x8')]&&_0x5aeba1[_0x1935c5[_0x105c50('0x11')][_0x476827]['type']](_0x1935c5['joins'][_0x476827][_0x105c50('0x7b')],null,util[_0x105c50('0x61')](_0x105c50('0x59'),_0x1935c5[_0x105c50('0x73')],_0x1935c5[_0x105c50('0x11')][_0x476827]['parentKey'],_0x1935c5[_0x105c50('0x11')][_0x476827][_0x105c50('0x7b')],_0x1935c5['joins'][_0x476827][_0x105c50('0x8')]));}}return _0x1935c5[_0x105c50('0x4f')]&&(_0x1935c5['conditions']=JSON[_0x105c50('0x4')](_0x1935c5[_0x105c50('0x4f')]),_0x5aeba1[_0x105c50('0x3c')](_0x1b2b02(_0x1935c5[_0x105c50('0x4f')][_0x105c50('0x68')]))),_0x1fb34c=_0x5aeba1['clone'](),_0x5aeba1[_0x105c50('0x17')](_0x4b6398),_0x5aeba1[_0x105c50('0x85')](0x0),logger['debug'](_0x105c50('0x5a'),_0x5aeba1['toString']()),db[_0x105c50('0x86')][_0x105c50('0x63')](_0x5aeba1['toString'](),{'type':QueryTypes[_0x105c50('0x13')]});}})[_0xdd163('0x1f')](function(){const _0x4e5f8e=_0xdd163;return{'sql':_0x1fb34c[_0x4e5f8e('0x1b')]()};})[_0xdd163('0x1f')](respondWithResult(_0x2d211f,null))[_0xdd163('0x60')](handleError(_0x2d211f,null));};
\ No newline at end of file
+const a5_0x48e4=['.calldate\x20BETWEEN\x20?\x20AND\x20?','VIRTUAL','SEC_TO_TIME(%s)','alias','limit','then','output','No\x20available\x20data','rules','../../files/reports','autoAssociation','debug','error','joins','UserProfileResource','keys','includes','api','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','groupBy','DATE(%s)','fieldName','GROUP_CONCAT(%s)','join','where','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','clone','fullPath','cross_join','stack','Limited\x20Query:','IS\x20NULL','count','type','IS\x20NOT\x20NULL','MIN(%s)','countTable','endDate','catch','startDate','COUNT(%s)','runReport','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','offset','function','undefined','format','sendStatus','Unable\x20to\x20retrieve\x20the\x20current\x20user','MAX(%s)','left_join','filter','findOne','condition','toString','Content-Range','create','path','options','foreignKey','getFields','sort','rawAttributes','query','key','cdr','map','name','params','update','AVG(%s)','replace','AnalyticMetric','Reports','order','info','right_join','preview','index','from','get','SUM(%s)','keyBy','QueryTypes','%s-%s.%s','parentKey','intersection','util','like','AnalyticCustomReport','operator','run','fork','attributes','IS\x20NOT\x20EMPTY','value','userProfileId','../../mysqldb','length','conditions','sequelize','model','filters','ROUND(%s)','generate','IS\x20EMPTY','role','end','SELECT','metric','savename','orderBy','lodash','custom','field','table','body','merge','../../components/parsers/qs','parse','status','foreignTable','pick','select','dbH','web','user','COUNT(DISTINCT\x20%s)','include','fields','HOUR(%s)','UNIX_TIMESTAMP(%s)','findAll','%s.%s\x20=\x20%s.%s','CustomReports','nolimit','DESC','group','MetricId','Please\x20insert\x20at\x20least\x20one\x20field'];(function(_0x2be0ad,_0x48e462){const _0x46236c=function(_0x27b3bd){while(--_0x27b3bd){_0x2be0ad['push'](_0x2be0ad['shift']());}};_0x46236c(++_0x48e462);}(a5_0x48e4,0x7f));const a5_0x4623=function(_0x2be0ad,_0x48e462){_0x2be0ad=_0x2be0ad-0x0;let _0x46236c=a5_0x48e4[_0x2be0ad];return _0x46236c;};const _0x3994b9=a5_0x4623;'use strict';const util=require(_0x3994b9('0x66')),path=require(_0x3994b9('0x48')),_=require(_0x3994b9('0x7f')),squel=require('squel'),qs=require(_0x3994b9('0x85')),logger=require('../../config/logger')(_0x3994b9('0x1f')),db=require(_0x3994b9('0x70'))['db'],dbH=require('../../mysqldb')[_0x3994b9('0x8b')],{Op,ValidationErrorItem,QueryTypes}=require('sequelize');function respondWithResult(_0x27b3bd,_0x9107b2){return _0x9107b2=_0x9107b2||0xc8,function(_0x813dfd){const _0xf3932d=a5_0x4623;if(_0x813dfd)return _0x27b3bd[_0xf3932d('0x87')](_0x9107b2)['json'](_0x813dfd);};}function respondWithFilteredResult(_0x55078a,_0x16de1a){return function(_0x519626){const _0x13c846=a5_0x4623;if(_0x519626){const _0xe60c73=_0x519626[_0x13c846('0x2f')],_0x457631=_0x16de1a[_0x13c846('0x3a')];let _0x1944f0=_0x16de1a[_0x13c846('0x3a')]+_0x16de1a[_0x13c846('0x12')],_0x41b8c8;return _0x1944f0>=_0xe60c73?(_0x1944f0=_0xe60c73,_0x41b8c8=0xc8):_0x41b8c8=0xce,_0x55078a['status'](_0x41b8c8),_0x55078a['set'](_0x13c846('0x46'),_0x457631+'-'+_0x1944f0+'/'+_0xe60c73)['json'](_0x519626);}return null;};}function saveUpdates(_0x13a7a7){return function(_0x4c8cb2){const _0x39a43f=a5_0x4623;if(_0x4c8cb2)return _0x4c8cb2[_0x39a43f('0x54')](_0x13a7a7)[_0x39a43f('0x13')](function(_0x45f88c){return _0x45f88c;});return null;};}function removeEntity(_0x537321){return function(_0x3c7a29){const _0x2ed0d9=a5_0x4623;if(_0x3c7a29)return _0x3c7a29[_0x2ed0d9('0x21')]()['then'](function(){const _0x57ee19=_0x2ed0d9,_0x1c2f9d=_0x3c7a29['get']({'plain':!![]}),_0x4937e0=_0x57ee19('0x8');return db[_0x57ee19('0x1c')][_0x57ee19('0x21')]({'where':{'type':_0x4937e0,'resourceId':_0x1c2f9d['id']}})[_0x57ee19('0x13')](function(){return _0x3c7a29;});})[_0x2ed0d9('0x13')](function(){const _0x2cf199=_0x2ed0d9;_0x537321[_0x2cf199('0x87')](0xcc)[_0x2cf199('0x7a')]();});};}function handleEntityNotFound(_0x4dcff7){return function(_0x3b00b8){const _0x2762e1=a5_0x4623;return!_0x3b00b8&&_0x4dcff7[_0x2762e1('0x3e')](0x194),_0x3b00b8;};}function handleError(_0x1686b4,_0x2bfb76){return _0x2bfb76=_0x2bfb76||0x1f4,function(_0x5851cb){const _0x33ea22=a5_0x4623;logger[_0x33ea22('0x1a')](_0x5851cb[_0x33ea22('0x2c')]),_0x5851cb[_0x33ea22('0x52')]&&delete _0x5851cb[_0x33ea22('0x52')],_0x1686b4[_0x33ea22('0x87')](_0x2bfb76)['send'](_0x5851cb);};}exports[_0x3994b9('0x5d')]=function(_0x599d32,_0x478970){const _0x396471=_0x3994b9;let _0x2831be={};const _0x57209e={},_0x3aa2b2={'count':0x0,'rows':[]},_0x4caf6e=_[_0x396471('0x51')](db['AnalyticCustomReport'][_0x396471('0x4d')],function(_0x368f22){const _0x312348=_0x396471;return{'name':_0x368f22[_0x312348('0x24')],'type':_0x368f22[_0x312348('0x30')][_0x312348('0x4f')]};});_0x57209e[_0x396471('0x74')]=_[_0x396471('0x51')](_0x4caf6e,_0x396471('0x52')),_0x57209e[_0x396471('0x4e')]=_[_0x396471('0x1d')](_0x599d32['query']),_0x57209e[_0x396471('0x75')]=_[_0x396471('0x65')](_0x57209e[_0x396471('0x74')],_0x57209e[_0x396471('0x4e')]),_0x2831be[_0x396471('0x6c')]=_[_0x396471('0x65')](_0x57209e['model'],qs[_0x396471('0x3')](_0x599d32['query']['fields'])),_0x2831be[_0x396471('0x6c')]=_0x2831be[_0x396471('0x6c')][_0x396471('0x71')]?_0x2831be[_0x396471('0x6c')]:_0x57209e[_0x396471('0x74')];typeof _0x599d32[_0x396471('0x4e')][_0x396471('0x9')]===_0x396471('0x3c')&&(_0x2831be['limit']=qs[_0x396471('0x12')](_0x599d32['query'][_0x396471('0x12')]),_0x2831be[_0x396471('0x3a')]=qs['offset'](_0x599d32[_0x396471('0x4e')][_0x396471('0x3a')]));_0x2831be[_0x396471('0x59')]=qs[_0x396471('0x4c')](_0x599d32[_0x396471('0x4e')]['sort']),_0x2831be[_0x396471('0x27')]=qs['filters'](_[_0x396471('0x89')](_0x599d32[_0x396471('0x4e')],_0x57209e[_0x396471('0x75')]),_0x4caf6e);_0x599d32[_0x396471('0x4e')][_0x396471('0x42')]&&(_0x2831be[_0x396471('0x27')]=_[_0x396471('0x84')](_0x2831be[_0x396471('0x27')],{[Op['or']]:_[_0x396471('0x51')](_0x4caf6e,function(_0x58565d){const _0x6e904c=_0x396471;if(_0x58565d[_0x6e904c('0x30')]!==_0x6e904c('0xf')){const _0x20861d={};return _0x20861d[_0x58565d['name']]={[Op[_0x6e904c('0x67')]]:'%'+_0x599d32[_0x6e904c('0x4e')]['filter']+'%'},_0x20861d;}})}));_0x2831be=_[_0x396471('0x84')]({},_0x2831be,_0x599d32['options']);const _0x2cc485={'where':_0x2831be[_0x396471('0x27')]};return db[_0x396471('0x68')][_0x396471('0x2f')](_0x2cc485)['then'](function(_0x4c7bc3){const _0x53f11c=_0x396471;return _0x3aa2b2[_0x53f11c('0x2f')]=_0x4c7bc3,_0x599d32['query']['includeAll']&&(_0x2831be[_0x53f11c('0x2')]=[{'all':!![]}]),db['AnalyticCustomReport'][_0x53f11c('0x6')](_0x2831be);})['then'](function(_0x1f6dd9){return _0x3aa2b2['rows']=_0x1f6dd9,_0x3aa2b2;})[_0x396471('0x13')](respondWithFilteredResult(_0x478970,_0x2831be))[_0x396471('0x35')](handleError(_0x478970,null));},exports['show']=function(_0x1dc6ef,_0x5759a9){const _0x4a9097=_0x3994b9;let _0x213862={'raw':![],'where':{'id':_0x1dc6ef[_0x4a9097('0x53')]['id']}};const _0x4f3c5c={};return _0x4f3c5c[_0x4a9097('0x74')]=_[_0x4a9097('0x1d')](db['AnalyticCustomReport'][_0x4a9097('0x4d')]),_0x4f3c5c[_0x4a9097('0x4e')]=_[_0x4a9097('0x1d')](_0x1dc6ef[_0x4a9097('0x4e')]),_0x4f3c5c[_0x4a9097('0x75')]=_['intersection'](_0x4f3c5c[_0x4a9097('0x74')],_0x4f3c5c[_0x4a9097('0x4e')]),_0x213862[_0x4a9097('0x6c')]=_['intersection'](_0x4f3c5c[_0x4a9097('0x74')],qs[_0x4a9097('0x3')](_0x1dc6ef[_0x4a9097('0x4e')][_0x4a9097('0x3')])),_0x213862['attributes']=_0x213862['attributes'][_0x4a9097('0x71')]?_0x213862['attributes']:_0x4f3c5c[_0x4a9097('0x74')],_0x1dc6ef[_0x4a9097('0x4e')]['includeAll']&&(_0x213862['include']=[{'all':!![]}]),_0x213862=_['merge']({},_0x213862,_0x1dc6ef['options']),db[_0x4a9097('0x68')][_0x4a9097('0x43')](_0x213862)['then'](handleEntityNotFound(_0x5759a9,null))[_0x4a9097('0x13')](respondWithResult(_0x5759a9,null))[_0x4a9097('0x35')](handleError(_0x5759a9,null));},exports[_0x3994b9('0x47')]=function(_0xc5399,_0x227fb1){const _0x4f8e89=_0x3994b9;return db[_0x4f8e89('0x68')][_0x4f8e89('0x47')](_0xc5399[_0x4f8e89('0x83')],{})[_0x4f8e89('0x13')](function(_0x4aab60){const _0x57e686=_0x4f8e89,_0xdfdbca=_0xc5399[_0x57e686('0x0')][_0x57e686('0x5f')]({'plain':!![]});if(!_0xdfdbca)throw new Error(_0x57e686('0x3f'));if(_0xdfdbca[_0x57e686('0x79')]===_0x57e686('0x0')){const _0xa6d9dd=_0x4aab60[_0x57e686('0x5f')]({'plain':!![]}),_0x4c7e26=_0x57e686('0x58');return db['UserProfileSection']['findOne']({'where':{'name':_0x4c7e26,'userProfileId':_0xdfdbca[_0x57e686('0x6f')]},'raw':!![]})[_0x57e686('0x13')](function(_0x55072d){const _0x39407b=_0x57e686;return _0x55072d&&_0x55072d[_0x39407b('0x18')]===0x0?db[_0x39407b('0x1c')][_0x39407b('0x47')]({'name':_0xa6d9dd[_0x39407b('0x52')],'resourceId':_0xa6d9dd['id'],'type':_0x39407b('0x8'),'sectionId':_0x55072d['id']},{})[_0x39407b('0x13')](function(){return _0x4aab60;}):_0x4aab60;})[_0x57e686('0x35')](function(_0x5d94fb){const _0x342508=_0x57e686;logger[_0x342508('0x1a')](_0x342508('0x20'),_0x5d94fb);throw _0x5d94fb;});}return _0x4aab60;})[_0x4f8e89('0x13')](respondWithResult(_0x227fb1,0xc9))['catch'](handleError(_0x227fb1,null));},exports['update']=function(_0x1932b8,_0x4dd732){const _0x4ec623=_0x3994b9;return _0x1932b8[_0x4ec623('0x83')]['id']&&delete _0x1932b8[_0x4ec623('0x83')]['id'],db['AnalyticCustomReport']['findOne']({'where':{'id':_0x1932b8['params']['id']}})[_0x4ec623('0x13')](handleEntityNotFound(_0x4dd732,null))[_0x4ec623('0x13')](saveUpdates(_0x1932b8[_0x4ec623('0x83')],null))[_0x4ec623('0x13')](respondWithResult(_0x4dd732,null))['catch'](handleError(_0x4dd732,null));},exports['destroy']=function(_0x41eeae,_0x389f13){const _0x353ccb=_0x3994b9;return db[_0x353ccb('0x68')][_0x353ccb('0x43')]({'where':{'id':_0x41eeae[_0x353ccb('0x53')]['id']}})[_0x353ccb('0x13')](handleEntityNotFound(_0x389f13,null))[_0x353ccb('0x13')](removeEntity(_0x389f13,null))['catch'](handleError(_0x389f13,null));},exports[_0x3994b9('0x5c')]=function(_0x3abcce,_0x4c14ce){const _0x1a284a=_0x3994b9,_0x4eea70=0xa,_0x5d67c8=['join',_0x1a284a('0x41'),_0x1a284a('0x5b'),_0x1a284a('0x2b')],_0x4cc176={'SUM':_0x1a284a('0x60'),'COUNT':_0x1a284a('0x37'),'COUNT\x20DISTINCT':_0x1a284a('0x1'),'MAX':_0x1a284a('0x40'),'MIN':'MIN(%s)','AVG':_0x1a284a('0x55'),'GROUP_CONCAT':_0x1a284a('0x25'),'GROUP_CONCAT\x20ASC':_0x1a284a('0x28'),'GROUP_CONCAT\x20DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'},_0x1d7403={'SEC_TO_TIME':_0x1a284a('0x10'),'DATE':'DATE(%s)','HOUR':'HOUR(%s)','ROUND':_0x1a284a('0x76'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'},_0x2ee54b=function(_0x2cbdd5){const _0xd485f7=_0x1a284a;return!_[_0xd485f7('0x1e')]([_0xd485f7('0x2e'),_0xd485f7('0x31'),_0xd485f7('0x78'),_0xd485f7('0x6d')],_0x2cbdd5);},_0x5ce5eb=function(_0x46f54a){const _0x2222b4=_0x1a284a;if(!_0x46f54a||!_0x46f54a[_0x2222b4('0x16')][_0x2222b4('0x71')])return'';let _0x282cd5='(';for(let _0x500bf3=0x0;_0x500bf3<_0x46f54a[_0x2222b4('0x16')]['length'];_0x500bf3+=0x1){_0x500bf3>0x0&&(_0x282cd5+='\x20'+_0x46f54a['operator']+'\x20'),_0x282cd5+=_0x46f54a[_0x2222b4('0x16')][_0x500bf3][_0x2222b4('0xb')]?_0x5ce5eb(_0x46f54a[_0x2222b4('0x16')][_0x500bf3][_0x2222b4('0xb')]):_0x46f54a[_0x2222b4('0x16')][_0x500bf3][_0x2222b4('0x81')]+'\x20'+_0x46f54a[_0x2222b4('0x16')][_0x500bf3][_0x2222b4('0x44')]+(_0x2ee54b(_0x46f54a[_0x2222b4('0x16')][_0x500bf3][_0x2222b4('0x44')])?'\x20'+_0x46f54a['rules'][_0x500bf3][_0x2222b4('0x6e')]:'');}return _0x282cd5+')';};let _0x26ca55={'where':{'id':_0x3abcce['params']['id']}},_0x1697ec,_0x8273d4,_0x54a523;return _0x26ca55=_['merge']({},_0x26ca55,_0x3abcce['options']),db['AnalyticCustomReport']['findOne'](_0x26ca55)['then'](function(_0x4635a9){const _0x1bb718=_0x1a284a;if(_0x4635a9)return _0x1697ec=_0x4635a9,_0x4635a9[_0x1bb718('0x4b')]();return null;})[_0x1a284a('0x13')](function(_0x101c73){const _0x416fb0=_0x1a284a;if(_0x101c73){if(!_0x101c73[_0x416fb0('0x71')])throw new ValidationErrorItem(_0x416fb0('0xd'),0x193);return _0x8273d4=_0x101c73,db[_0x416fb0('0x57')][_0x416fb0('0x6')]({'raw':!![]});}return null;})['then'](function(_0xf8b90){const _0x15f02e=_0x1a284a;if(_0xf8b90){_0x54a523=_[_0x15f02e('0x61')](_0xf8b90,'id');let _0x589df1;const _0x1ea675=squel[_0x15f02e('0x8a')]();_0x1ea675[_0x15f02e('0x5e')](_0x1697ec['table']);for(let _0x1db185=0x0;_0x1db185<_0x8273d4[_0x15f02e('0x71')];_0x1db185+=0x1){_0x589df1=_0x8273d4[_0x1db185]['MetricId']?_0x54a523[_0x8273d4[_0x1db185][_0x15f02e('0xc')]][_0x15f02e('0x7c')]:_0x8273d4[_0x1db185][_0x15f02e('0x81')],_0x589df1=_0x8273d4[_0x1db185][_0x15f02e('0x3b')]?_[_0x15f02e('0x56')](_0x4cc176[_0x8273d4[_0x1db185]['function']],'%s',_0x589df1):_0x589df1,_0x589df1=_0x8273d4[_0x1db185][_0x15f02e('0x3d')]?_[_0x15f02e('0x56')](_0x1d7403[_0x8273d4[_0x1db185]['format']],'%s',_0x589df1):_0x589df1,_0x8273d4[_0x1db185][_0x15f02e('0x22')]&&_0x1ea675[_0x15f02e('0xb')](_0x589df1),_0x8273d4[_0x1db185][_0x15f02e('0x7e')]&&_0x1ea675[_0x15f02e('0x59')](_0x589df1,_0x8273d4[_0x1db185]['orderBy']===_0x15f02e('0xa')?![]:!![]),_0x1ea675[_0x15f02e('0x81')](_0x589df1,_0x8273d4[_0x1db185][_0x15f02e('0x11')]||_0x589df1);}if(_0x1697ec[_0x15f02e('0x1b')]){_0x1697ec['joins']=JSON[_0x15f02e('0x86')](_0x1697ec[_0x15f02e('0x1b')]);for(let _0x1b3c83=0x0;_0x1b3c83<_0x1697ec[_0x15f02e('0x1b')][_0x15f02e('0x71')];_0x1b3c83+=0x1){_0x1697ec[_0x15f02e('0x1b')][_0x1b3c83][_0x15f02e('0x30')]&&_[_0x15f02e('0x1e')](_0x5d67c8,_0x1697ec[_0x15f02e('0x1b')][_0x1b3c83][_0x15f02e('0x30')])&&_0x1697ec[_0x15f02e('0x1b')][_0x1b3c83][_0x15f02e('0x64')]&&_0x1697ec[_0x15f02e('0x1b')][_0x1b3c83]['foreignTable']&&_0x1697ec[_0x15f02e('0x1b')][_0x1b3c83][_0x15f02e('0x4a')]&&_0x1ea675[_0x1697ec[_0x15f02e('0x1b')][_0x1b3c83][_0x15f02e('0x30')]](_0x1697ec['joins'][_0x1b3c83][_0x15f02e('0x88')],null,util[_0x15f02e('0x3d')](_0x15f02e('0x7'),_0x1697ec['table'],_0x1697ec[_0x15f02e('0x1b')][_0x1b3c83]['parentKey'],_0x1697ec['joins'][_0x1b3c83]['foreignTable'],_0x1697ec['joins'][_0x1b3c83]['foreignKey']));}}return _0x1697ec['conditions']&&(_0x1697ec[_0x15f02e('0x72')]=JSON[_0x15f02e('0x86')](_0x1697ec[_0x15f02e('0x72')]),_0x1ea675[_0x15f02e('0x27')](_0x5ce5eb(_0x1697ec[_0x15f02e('0x72')][_0x15f02e('0xb')]))),_0x1ea675[_0x15f02e('0x12')](_0x4eea70),_0x1ea675[_0x15f02e('0x3a')](0x0),logger[_0x15f02e('0x19')]('Limited\x20Query:',_0x1ea675['toString']()),db[_0x15f02e('0x73')][_0x15f02e('0x4e')](_0x1ea675[_0x15f02e('0x45')](),{'type':QueryTypes[_0x15f02e('0x7b')]});}})['then'](respondWithResult(_0x4c14ce,null))['catch'](handleError(_0x4c14ce,null));};function runReport(_0x1b3321,_0x44387a,_0x33b874){const _0x25fc98=_0x3994b9,_0x21502c=_0x44387a[_0x25fc98('0x52')],_0x59cd19=0xa,_0x47b15b=[_0x25fc98('0x26'),'left_join','right_join',_0x25fc98('0x2b')],_0x3cc793={'SUM':_0x25fc98('0x60'),'COUNT':_0x25fc98('0x37'),'COUNT\x20DISTINCT':_0x25fc98('0x1'),'MAX':_0x25fc98('0x40'),'MIN':_0x25fc98('0x32'),'AVG':_0x25fc98('0x55'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT\x20ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT\x20DESC':_0x25fc98('0x39')},_0x4b1f06={'SEC_TO_TIME':_0x25fc98('0x10'),'DATE':_0x25fc98('0x23'),'HOUR':_0x25fc98('0x4'),'ROUND':_0x25fc98('0x76'),'UNIX_TIMESTAMP':_0x25fc98('0x5')},_0x346913=function(_0x4bb35b){const _0xd5a10=_0x25fc98;return!_[_0xd5a10('0x1e')]([_0xd5a10('0x2e'),_0xd5a10('0x31'),'IS\x20EMPTY','IS\x20NOT\x20EMPTY'],_0x4bb35b);},_0x438759=function(_0x2dc6d3){const _0xa4257d=_0x25fc98;if(!_0x2dc6d3||!_0x2dc6d3[_0xa4257d('0x16')][_0xa4257d('0x71')])return'';let _0x335db8='(';for(let _0x44114f=0x0;_0x44114f<_0x2dc6d3[_0xa4257d('0x16')]['length'];_0x44114f+=0x1){_0x44114f>0x0&&(_0x335db8+='\x20'+_0x2dc6d3[_0xa4257d('0x69')]+'\x20'),_0x335db8+=_0x2dc6d3[_0xa4257d('0x16')][_0x44114f]['group']?_0x438759(_0x2dc6d3['rules'][_0x44114f][_0xa4257d('0xb')]):_0x2dc6d3[_0xa4257d('0x16')][_0x44114f][_0xa4257d('0x81')]+'\x20'+_0x2dc6d3[_0xa4257d('0x16')][_0x44114f][_0xa4257d('0x44')]+(_0x346913(_0x2dc6d3[_0xa4257d('0x16')][_0x44114f]['condition'])?'\x20'+_0x2dc6d3[_0xa4257d('0x16')][_0x44114f]['value']:'');}return _0x335db8+')';};let _0xc4e83a={'where':{'id':_0x1b3321['id']}},_0x20a3cf,_0x4b8d74,_0x225576,_0x586a2c,_0x2d82c7;return _0xc4e83a=_[_0x25fc98('0x84')]({},_0xc4e83a,_0x33b874),db[_0x25fc98('0x68')][_0x25fc98('0x43')](_0xc4e83a)[_0x25fc98('0x13')](function(_0x3eb9d4){if(_0x3eb9d4)return _0x20a3cf=_0x3eb9d4,_0x3eb9d4['getFields']();return null;})[_0x25fc98('0x13')](function(_0x2d5e36){const _0x20bfb8=_0x25fc98;if(_0x2d5e36){if(!_0x2d5e36[_0x20bfb8('0x71')])throw new ValidationErrorItem(_0x20bfb8('0xd'),0x193);return _0x4b8d74=_0x2d5e36,db[_0x20bfb8('0x57')]['findAll']({'raw':!![]});}return null;})['then'](function(_0x286533){const _0x27ca90=_0x25fc98;if(_0x286533){_0x225576=_['keyBy'](_0x286533,'id');let _0x581428;const _0x46ab3c=squel[_0x27ca90('0x8a')]();_0x46ab3c['from'](_0x20a3cf['table']);for(let _0x2826b3=0x0;_0x2826b3<_0x4b8d74[_0x27ca90('0x71')];_0x2826b3+=0x1){_0x581428=_0x4b8d74[_0x2826b3][_0x27ca90('0xc')]?_0x225576[_0x4b8d74[_0x2826b3]['MetricId']]['metric']:_0x4b8d74[_0x2826b3][_0x27ca90('0x81')],_0x581428=_0x4b8d74[_0x2826b3][_0x27ca90('0x3b')]?_['replace'](_0x3cc793[_0x4b8d74[_0x2826b3][_0x27ca90('0x3b')]],'%s',_0x581428):_0x581428,_0x581428=_0x4b8d74[_0x2826b3][_0x27ca90('0x3d')]?_[_0x27ca90('0x56')](_0x4b1f06[_0x4b8d74[_0x2826b3]['format']],'%s',_0x581428):_0x581428,_0x4b8d74[_0x2826b3][_0x27ca90('0x22')]&&_0x46ab3c[_0x27ca90('0xb')](_0x581428),_0x4b8d74[_0x2826b3][_0x27ca90('0x7e')]&&_0x46ab3c['order'](_0x581428,_0x4b8d74[_0x2826b3]['orderBy']===_0x27ca90('0xa')?![]:!![]),_0x46ab3c[_0x27ca90('0x81')](_0x581428,_0x4b8d74[_0x2826b3][_0x27ca90('0x11')]||_0x581428);}if(_0x20a3cf['joins']){_0x20a3cf[_0x27ca90('0x1b')]=JSON[_0x27ca90('0x86')](_0x20a3cf['joins']);for(let _0x467b34=0x0;_0x467b34<_0x20a3cf[_0x27ca90('0x1b')]['length'];_0x467b34+=0x1){_0x20a3cf['joins'][_0x467b34][_0x27ca90('0x30')]&&_[_0x27ca90('0x1e')](_0x47b15b,_0x20a3cf[_0x27ca90('0x1b')][_0x467b34][_0x27ca90('0x30')])&&_0x20a3cf[_0x27ca90('0x1b')][_0x467b34]['parentKey']&&_0x20a3cf['joins'][_0x467b34][_0x27ca90('0x88')]&&_0x20a3cf[_0x27ca90('0x1b')][_0x467b34]['foreignKey']&&_0x46ab3c[_0x20a3cf[_0x27ca90('0x1b')][_0x467b34][_0x27ca90('0x30')]](_0x20a3cf[_0x27ca90('0x1b')][_0x467b34][_0x27ca90('0x88')],null,util[_0x27ca90('0x3d')](_0x27ca90('0x7'),_0x20a3cf[_0x27ca90('0x82')],_0x20a3cf[_0x27ca90('0x1b')][_0x467b34][_0x27ca90('0x64')],_0x20a3cf[_0x27ca90('0x1b')][_0x467b34][_0x27ca90('0x88')],_0x20a3cf['joins'][_0x467b34]['foreignKey']));}}return _0x20a3cf[_0x27ca90('0x72')]&&(_0x20a3cf[_0x27ca90('0x72')]=JSON[_0x27ca90('0x86')](_0x20a3cf[_0x27ca90('0x72')]),_0x46ab3c[_0x27ca90('0x27')](_0x438759(_0x20a3cf['conditions'][_0x27ca90('0xb')]))),_0x2d82c7=_0x46ab3c[_0x27ca90('0x29')](),_0x46ab3c[_0x27ca90('0x12')](_0x59cd19),_0x46ab3c[_0x27ca90('0x3a')](0x0),logger['debug'](_0x27ca90('0x2d'),_0x46ab3c['toString']()),db['sequelize']['query'](_0x46ab3c[_0x27ca90('0x45')](),{'type':QueryTypes[_0x27ca90('0x7b')]});}})[_0x25fc98('0x13')](function(_0x180751){const _0x2db471=_0x25fc98;if(!_0x180751[_0x2db471('0x71')])throw new ValidationErrorItem(_0x2db471('0x15'),0xcc);if(_0x44387a['output']===_0x2db471('0x8c'))return null;const _0x1e1ed6=_[_0x2db471('0x84')](_0x44387a,{'name':_0x44387a[_0x2db471('0x2a')]||_0x44387a[_0x2db471('0x52')]||_0x20a3cf[_0x2db471('0x52')],'basename':_0x21502c,'savename':util['format'](_0x2db471('0x63'),_0x44387a[_0x2db471('0x52')]||_0x20a3cf[_0x2db471('0x52')],require('randomstring')[_0x2db471('0x77')](0x4),_0x44387a[_0x2db471('0x14')]||'csv'),'reportId':_0x20a3cf['id'],'reportType':_0x2db471('0x80')});return db['AnalyticExtractedReport'][_0x2db471('0x47')](_0x1e1ed6,{'raw':!![]});})['then'](function(_0x5a7bd5){const _0x2814da=_0x25fc98;_0x20a3cf[_0x2814da('0x82')]===_0x2814da('0x50')?_0x2d82c7[_0x2814da('0x27')](_0x20a3cf[_0x2814da('0x82')]+_0x2814da('0xe'),_0x44387a[_0x2814da('0x36')],_0x44387a[_0x2814da('0x34')]):_0x2d82c7[_0x2814da('0x27')](_0x20a3cf[_0x2814da('0x82')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x44387a[_0x2814da('0x36')],_0x44387a[_0x2814da('0x34')]);if(_0x5a7bd5)return logger[_0x2814da('0x5a')]('Run\x20Query:',_0x2d82c7[_0x2814da('0x45')]()),require('child_process')[_0x2814da('0x6b')](path[_0x2814da('0x26')](__dirname,'../../components/export/',_0x5a7bd5[_0x2814da('0x14')]),[_0x5a7bd5['id'],_0x2d82c7['toString'](),path[_0x2814da('0x26')](__dirname,_0x2814da('0x17'),_0x5a7bd5[_0x2814da('0x7d')]),_0x21502c]),_0x5a7bd5;else{const _0x493313=squel[_0x2814da('0x8a')]();return _0x493313['from']('('+_0x2d82c7[_0x2814da('0x45')]()+')',_0x2814da('0x33')),_0x493313[_0x2814da('0x81')]('COUNT(*)',_0x2814da('0x2f')),_0x2d82c7[_0x2814da('0x12')](_0x44387a[_0x2814da('0x12')]||_0x59cd19),_0x2d82c7[_0x2814da('0x3a')](_0x44387a[_0x2814da('0x3a')]||0x0),dbH[_0x2814da('0x73')][_0x2814da('0x4e')](_0x493313[_0x2814da('0x45')](),{'type':dbH[_0x2814da('0x73')][_0x2814da('0x62')][_0x2814da('0x7b')]})[_0x2814da('0x13')](function(_0x3ab619){const _0x3d52d4=_0x2814da;return!_0x3ab619[_0x3d52d4('0x71')]?_0x586a2c=0x0:_0x586a2c=_0x3ab619[0x0][_0x3d52d4('0x2f')]||0x0,dbH[_0x3d52d4('0x73')][_0x3d52d4('0x4e')](_0x2d82c7[_0x3d52d4('0x45')](),{'type':dbH[_0x3d52d4('0x73')][_0x3d52d4('0x62')][_0x3d52d4('0x7b')]});})[_0x2814da('0x13')](function(_0xd3d0d7){return{'rows':_0xd3d0d7||[],'count':_0x586a2c};});}});}exports[_0x3994b9('0x6a')]=function(_0x182ba1,_0x24ab78){const _0x2a1983=_0x3994b9;return runReport(_0x182ba1[_0x2a1983('0x53')],_0x182ba1[_0x2a1983('0x4e')],_0x182ba1[_0x2a1983('0x49')])[_0x2a1983('0x13')](respondWithResult(_0x24ab78,null))['catch'](handleError(_0x24ab78,null));},exports[_0x3994b9('0x38')]=runReport,exports[_0x3994b9('0x4e')]=function(_0xd56979,_0xa0d00){const _0xab1485=_0x3994b9,_0x2cfc28=0xa,_0x139a58=[_0xab1485('0x26'),_0xab1485('0x41'),_0xab1485('0x5b'),_0xab1485('0x2b')],_0x548f8e={'SUM':_0xab1485('0x60'),'COUNT':_0xab1485('0x37'),'COUNT\x20DISTINCT':_0xab1485('0x1'),'MAX':_0xab1485('0x40'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xab1485('0x25'),'GROUP_CONCAT\x20ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT\x20DESC':_0xab1485('0x39')},_0x5c0561={'SEC_TO_TIME':_0xab1485('0x10'),'DATE':_0xab1485('0x23'),'HOUR':_0xab1485('0x4'),'ROUND':_0xab1485('0x76'),'UNIX_TIMESTAMP':_0xab1485('0x5')},_0x146086=function(_0xc5481e){const _0x2230c=_0xab1485;return!_['includes']([_0x2230c('0x2e'),_0x2230c('0x31'),_0x2230c('0x78'),'IS\x20NOT\x20EMPTY'],_0xc5481e);},_0x37e544=function(_0x2ad6df){const _0xe37c1=_0xab1485;if(!_0x2ad6df||!_0x2ad6df[_0xe37c1('0x16')][_0xe37c1('0x71')])return'';let _0x1d6c73='(';for(let _0x240b29=0x0;_0x240b29<_0x2ad6df['rules'][_0xe37c1('0x71')];_0x240b29+=0x1){_0x240b29>0x0&&(_0x1d6c73+='\x20'+_0x2ad6df[_0xe37c1('0x69')]+'\x20'),_0x1d6c73+=_0x2ad6df[_0xe37c1('0x16')][_0x240b29]['group']?_0x37e544(_0x2ad6df[_0xe37c1('0x16')][_0x240b29][_0xe37c1('0xb')]):_0x2ad6df[_0xe37c1('0x16')][_0x240b29][_0xe37c1('0x81')]+'\x20'+_0x2ad6df[_0xe37c1('0x16')][_0x240b29][_0xe37c1('0x44')]+(_0x146086(_0x2ad6df[_0xe37c1('0x16')][_0x240b29][_0xe37c1('0x44')])?'\x20'+_0x2ad6df[_0xe37c1('0x16')][_0x240b29][_0xe37c1('0x6e')]:'');}return _0x1d6c73+')';};let _0x478b5b={'where':{'id':_0xd56979[_0xab1485('0x53')]['id']}},_0x1b66f3,_0x25147d,_0xb0d026,_0x3af72b;return _0x478b5b=_[_0xab1485('0x84')]({},_0x478b5b,_0xd56979[_0xab1485('0x49')]),db['AnalyticCustomReport'][_0xab1485('0x43')](_0x478b5b)[_0xab1485('0x13')](function(_0x5ec43f){const _0x1f70a7=_0xab1485;if(_0x5ec43f)return _0x1b66f3=_0x5ec43f,_0x5ec43f[_0x1f70a7('0x4b')]();return null;})['then'](function(_0x5bcd73){const _0x3e9a46=_0xab1485;if(_0x5bcd73){if(!_0x5bcd73[_0x3e9a46('0x71')])throw new ValidationErrorItem(_0x3e9a46('0xd'),0x193);return _0x25147d=_0x5bcd73,db[_0x3e9a46('0x57')]['findAll']({'raw':!![]});}return null;})[_0xab1485('0x13')](function(_0x5bf883){const _0x2086e9=_0xab1485;if(_0x5bf883){_0xb0d026=_['keyBy'](_0x5bf883,'id');let _0x58e3f7;const _0x16860d=squel[_0x2086e9('0x8a')]();_0x16860d[_0x2086e9('0x5e')](_0x1b66f3[_0x2086e9('0x82')]);for(let _0x1f5428=0x0;_0x1f5428<_0x25147d[_0x2086e9('0x71')];_0x1f5428+=0x1){_0x58e3f7=_0x25147d[_0x1f5428][_0x2086e9('0xc')]?_0xb0d026[_0x25147d[_0x1f5428][_0x2086e9('0xc')]]['metric']:_0x25147d[_0x1f5428]['field'],_0x58e3f7=_0x25147d[_0x1f5428][_0x2086e9('0x3b')]?_[_0x2086e9('0x56')](_0x548f8e[_0x25147d[_0x1f5428]['function']],'%s',_0x58e3f7):_0x58e3f7,_0x58e3f7=_0x25147d[_0x1f5428][_0x2086e9('0x3d')]?_[_0x2086e9('0x56')](_0x5c0561[_0x25147d[_0x1f5428][_0x2086e9('0x3d')]],'%s',_0x58e3f7):_0x58e3f7,_0x25147d[_0x1f5428][_0x2086e9('0x22')]&&_0x16860d['group'](_0x58e3f7),_0x25147d[_0x1f5428][_0x2086e9('0x7e')]&&_0x16860d[_0x2086e9('0x59')](_0x58e3f7,_0x25147d[_0x1f5428][_0x2086e9('0x7e')]==='DESC'?![]:!![]),_0x16860d['field'](_0x58e3f7,_0x25147d[_0x1f5428][_0x2086e9('0x11')]||_0x58e3f7);}if(_0x1b66f3[_0x2086e9('0x1b')]){_0x1b66f3[_0x2086e9('0x1b')]=JSON[_0x2086e9('0x86')](_0x1b66f3[_0x2086e9('0x1b')]);for(let _0x36a133=0x0;_0x36a133<_0x1b66f3[_0x2086e9('0x1b')][_0x2086e9('0x71')];_0x36a133+=0x1){_0x1b66f3['joins'][_0x36a133][_0x2086e9('0x30')]&&_[_0x2086e9('0x1e')](_0x139a58,_0x1b66f3[_0x2086e9('0x1b')][_0x36a133]['type'])&&_0x1b66f3[_0x2086e9('0x1b')][_0x36a133][_0x2086e9('0x64')]&&_0x1b66f3['joins'][_0x36a133][_0x2086e9('0x88')]&&_0x1b66f3[_0x2086e9('0x1b')][_0x36a133]['foreignKey']&&_0x16860d[_0x1b66f3[_0x2086e9('0x1b')][_0x36a133][_0x2086e9('0x30')]](_0x1b66f3[_0x2086e9('0x1b')][_0x36a133][_0x2086e9('0x88')],null,util[_0x2086e9('0x3d')](_0x2086e9('0x7'),_0x1b66f3[_0x2086e9('0x82')],_0x1b66f3[_0x2086e9('0x1b')][_0x36a133][_0x2086e9('0x64')],_0x1b66f3['joins'][_0x36a133][_0x2086e9('0x88')],_0x1b66f3[_0x2086e9('0x1b')][_0x36a133][_0x2086e9('0x4a')]));}}return _0x1b66f3[_0x2086e9('0x72')]&&(_0x1b66f3[_0x2086e9('0x72')]=JSON[_0x2086e9('0x86')](_0x1b66f3[_0x2086e9('0x72')]),_0x16860d[_0x2086e9('0x27')](_0x37e544(_0x1b66f3[_0x2086e9('0x72')]['group']))),_0x3af72b=_0x16860d[_0x2086e9('0x29')](),_0x16860d['limit'](_0x2cfc28),_0x16860d['offset'](0x0),logger[_0x2086e9('0x19')](_0x2086e9('0x2d'),_0x16860d[_0x2086e9('0x45')]()),db[_0x2086e9('0x73')][_0x2086e9('0x4e')](_0x16860d[_0x2086e9('0x45')](),{'type':QueryTypes[_0x2086e9('0x7b')]});}})[_0xab1485('0x13')](function(){const _0x262fba=_0xab1485;return{'sql':_0x3af72b[_0x262fba('0x45')]()};})[_0xab1485('0x13')](respondWithResult(_0xa0d00,null))[_0xab1485('0x35')](handleError(_0xa0d00,null));};
\ No newline at end of file