Built motion from commit 129fb4d95212661e48f0db455e75d668addbaddf. Version 3.0.0...
[motion-next.git] / server / api / analyticCustomReport / analyticCustomReport.controller.js
index 901af01..aa82c07 100644 (file)
@@ -1 +1 @@
-const a5_0x50a8=['create','%s.%s\x20=\x20%s.%s','info','from','sendStatus','Content-Range','dbH','joins','show','order','group','replace','randomstring','IS\x20NULL','endDate','type','sort','fullPath','countTable','foreignTable','startDate','findAll','parse','left_join','function','Limited\x20Query:','IS\x20NOT\x20EMPTY','table','intersection','includes','update','query','IS\x20NOT\x20NULL','conditions','runReport','destroy','fields','options','findOne','No\x20available\x20data','params','rules','SUM(%s)','metric','send','filter','sequelize','attributes','HOUR(%s)','cdr','operator','AVG(%s)','role','Please\x20insert\x20at\x20least\x20one\x20field','length','AnalyticCustomReport','COUNT(DISTINCT\x20%s)','name','AnalyticExtractedReport','debug','UserProfileResource','error','autoAssociation','SELECT','../../config/logger','get','body','MAX(%s)','keyBy','child_process','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','include','groupBy','clone','web','map','UserProfileSection','custom','status','end','generate','key','DATE(%s)','model','orderBy','CustomReports','util','field','UNIX_TIMESTAMP(%s)','select','Unable\x20to\x20retrieve\x20the\x20current\x20user','like','MIN(%s)','count','alias','join','user','MetricId','toString','filters','QueryTypes','IS\x20EMPTY','ROUND(%s)','csv','value','output','then','condition','squel','../../components/parsers/qs','limit','Run\x20Query:','undefined','set','where','SEC_TO_TIME(%s)','VIRTUAL','stack','../../mysqldb','Reports','right_join','COUNT(*)','json','parentKey','userProfileId','keys','api','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','rawAttributes','cross_join','format','foreignKey','path','merge','AnalyticMetric','catch','DESC','index','%s-%s.%s','offset','getFields','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s)','COUNT(%s)'];(function(_0x434339,_0x50a8cf){const _0x101f8d=function(_0x18bdf7){while(--_0x18bdf7){_0x434339['push'](_0x434339['shift']());}};_0x101f8d(++_0x50a8cf);}(a5_0x50a8,0x197));const a5_0x101f=function(_0x434339,_0x50a8cf){_0x434339=_0x434339-0x0;let _0x101f8d=a5_0x50a8[_0x434339];return _0x101f8d;};const _0x18fe05=a5_0x101f;'use strict';const util=require(_0x18fe05('0x6f')),path=require(_0x18fe05('0xd')),_=require('lodash'),squel=require(_0x18fe05('0x85')),qs=require(_0x18fe05('0x86')),logger=require(_0x18fe05('0x59'))(_0x18fe05('0x7')),db=require('../../mysqldb')['db'],dbH=require(_0x18fe05('0x8f'))[_0x18fe05('0x1f')],{Op,ValidationErrorItem,QueryTypes}=require(_0x18fe05('0x47'));function respondWithResult(_0x18bdf7,_0x127f93){return _0x127f93=_0x127f93||0xc8,function(_0xe9553e){const _0xaf4853=a5_0x101f;if(_0xe9553e)return _0x18bdf7[_0xaf4853('0x67')](_0x127f93)[_0xaf4853('0x3')](_0xe9553e);};}function respondWithFilteredResult(_0x2adeeb,_0x56d95a){return function(_0x39677e){const _0x1743aa=a5_0x101f;if(_0x39677e){const _0x3d1f5b=_0x39677e[_0x1743aa('0x76')],_0x5f1e75=_0x56d95a[_0x1743aa('0x14')];let _0x44d3a9=_0x56d95a['offset']+_0x56d95a['limit'],_0x3258d8;return _0x44d3a9>=_0x3d1f5b?(_0x44d3a9=_0x3d1f5b,_0x3258d8=0xc8):_0x3258d8=0xce,_0x2adeeb['status'](_0x3258d8),_0x2adeeb[_0x1743aa('0x8a')](_0x1743aa('0x1e'),_0x5f1e75+'-'+_0x44d3a9+'/'+_0x3d1f5b)[_0x1743aa('0x3')](_0x39677e);}return null;};}function saveUpdates(_0x44d8be){return function(_0x3d0769){const _0xcee1ea=a5_0x101f;if(_0x3d0769)return _0x3d0769[_0xcee1ea('0x37')](_0x44d8be)[_0xcee1ea('0x83')](function(_0x1adfce){return _0x1adfce;});return null;};}function removeEntity(_0x3cb19d){return function(_0x4ccaec){const _0x1618ea=a5_0x101f;if(_0x4ccaec)return _0x4ccaec[_0x1618ea('0x3c')]()[_0x1618ea('0x83')](function(){const _0x49e0ef=_0x1618ea,_0x299f95=_0x4ccaec['get']({'plain':!![]}),_0x3b364d='CustomReports';return db['UserProfileResource'][_0x49e0ef('0x3c')]({'where':{'type':_0x3b364d,'resourceId':_0x299f95['id']}})['then'](function(){return _0x4ccaec;});})[_0x1618ea('0x83')](function(){const _0x56d009=_0x1618ea;_0x3cb19d[_0x56d009('0x67')](0xcc)[_0x56d009('0x68')]();});};}function handleEntityNotFound(_0x1058bf){return function(_0x4bbf2a){const _0x518b32=a5_0x101f;return!_0x4bbf2a&&_0x1058bf[_0x518b32('0x1d')](0x194),_0x4bbf2a;};}function handleError(_0x3caf5a,_0x10b0f9){return _0x10b0f9=_0x10b0f9||0x1f4,function(_0x271707){const _0x5b1e0a=a5_0x101f;logger['error'](_0x271707[_0x5b1e0a('0x8e')]),_0x271707[_0x5b1e0a('0x52')]&&delete _0x271707['name'],_0x3caf5a[_0x5b1e0a('0x67')](_0x10b0f9)[_0x5b1e0a('0x45')](_0x271707);};}exports[_0x18fe05('0x12')]=function(_0x264b27,_0x400a22){const _0x5cfe0c=_0x18fe05;let _0x396af9={};const _0x517cbf={},_0x54491a={'count':0x0,'rows':[]},_0x2c3b06=_[_0x5cfe0c('0x64')](db[_0x5cfe0c('0x50')][_0x5cfe0c('0x9')],function(_0x5d33ff){const _0x5256e0=_0x5cfe0c;return{'name':_0x5d33ff['fieldName'],'type':_0x5d33ff[_0x5256e0('0x28')][_0x5256e0('0x6a')]};});_0x517cbf[_0x5cfe0c('0x6c')]=_[_0x5cfe0c('0x64')](_0x2c3b06,'name'),_0x517cbf['query']=_[_0x5cfe0c('0x6')](_0x264b27[_0x5cfe0c('0x38')]),_0x517cbf[_0x5cfe0c('0x7c')]=_[_0x5cfe0c('0x35')](_0x517cbf['model'],_0x517cbf['query']),_0x396af9[_0x5cfe0c('0x48')]=_[_0x5cfe0c('0x35')](_0x517cbf[_0x5cfe0c('0x6c')],qs[_0x5cfe0c('0x3d')](_0x264b27[_0x5cfe0c('0x38')][_0x5cfe0c('0x3d')])),_0x396af9['attributes']=_0x396af9[_0x5cfe0c('0x48')][_0x5cfe0c('0x4f')]?_0x396af9[_0x5cfe0c('0x48')]:_0x517cbf[_0x5cfe0c('0x6c')];typeof _0x264b27[_0x5cfe0c('0x38')]['nolimit']===_0x5cfe0c('0x89')&&(_0x396af9[_0x5cfe0c('0x87')]=qs[_0x5cfe0c('0x87')](_0x264b27['query'][_0x5cfe0c('0x87')]),_0x396af9[_0x5cfe0c('0x14')]=qs[_0x5cfe0c('0x14')](_0x264b27[_0x5cfe0c('0x38')][_0x5cfe0c('0x14')]));_0x396af9[_0x5cfe0c('0x22')]=qs[_0x5cfe0c('0x29')](_0x264b27[_0x5cfe0c('0x38')][_0x5cfe0c('0x29')]),_0x396af9[_0x5cfe0c('0x8b')]=qs[_0x5cfe0c('0x7c')](_['pick'](_0x264b27['query'],_0x517cbf[_0x5cfe0c('0x7c')]),_0x2c3b06);_0x264b27[_0x5cfe0c('0x38')][_0x5cfe0c('0x46')]&&(_0x396af9['where']=_[_0x5cfe0c('0xe')](_0x396af9[_0x5cfe0c('0x8b')],{[Op['or']]:_['map'](_0x2c3b06,function(_0x4af039){const _0x47b45a=_0x5cfe0c;if(_0x4af039[_0x47b45a('0x28')]!==_0x47b45a('0x8d')){const _0x422376={};return _0x422376[_0x4af039['name']]={[Op[_0x47b45a('0x74')]]:'%'+_0x264b27[_0x47b45a('0x38')][_0x47b45a('0x46')]+'%'},_0x422376;}})}));_0x396af9=_[_0x5cfe0c('0xe')]({},_0x396af9,_0x264b27[_0x5cfe0c('0x3e')]);const _0x2a7287={'where':_0x396af9[_0x5cfe0c('0x8b')]};return db[_0x5cfe0c('0x50')][_0x5cfe0c('0x76')](_0x2a7287)[_0x5cfe0c('0x83')](function(_0x4200a1){const _0x2b3e3e=_0x5cfe0c;return _0x54491a[_0x2b3e3e('0x76')]=_0x4200a1,_0x264b27[_0x2b3e3e('0x38')]['includeAll']&&(_0x396af9[_0x2b3e3e('0x60')]=[{'all':!![]}]),db[_0x2b3e3e('0x50')]['findAll'](_0x396af9);})['then'](function(_0x22e292){return _0x54491a['rows']=_0x22e292,_0x54491a;})[_0x5cfe0c('0x83')](respondWithFilteredResult(_0x400a22,_0x396af9))[_0x5cfe0c('0x10')](handleError(_0x400a22,null));},exports[_0x18fe05('0x21')]=function(_0x25c196,_0x3f225e){const _0x4ab251=_0x18fe05;let _0xa93a4f={'raw':![],'where':{'id':_0x25c196[_0x4ab251('0x41')]['id']}};const _0x583816={};return _0x583816[_0x4ab251('0x6c')]=_[_0x4ab251('0x6')](db[_0x4ab251('0x50')][_0x4ab251('0x9')]),_0x583816[_0x4ab251('0x38')]=_['keys'](_0x25c196[_0x4ab251('0x38')]),_0x583816[_0x4ab251('0x7c')]=_[_0x4ab251('0x35')](_0x583816[_0x4ab251('0x6c')],_0x583816['query']),_0xa93a4f[_0x4ab251('0x48')]=_[_0x4ab251('0x35')](_0x583816[_0x4ab251('0x6c')],qs['fields'](_0x25c196[_0x4ab251('0x38')][_0x4ab251('0x3d')])),_0xa93a4f[_0x4ab251('0x48')]=_0xa93a4f[_0x4ab251('0x48')][_0x4ab251('0x4f')]?_0xa93a4f['attributes']:_0x583816[_0x4ab251('0x6c')],_0x25c196[_0x4ab251('0x38')]['includeAll']&&(_0xa93a4f[_0x4ab251('0x60')]=[{'all':!![]}]),_0xa93a4f=_['merge']({},_0xa93a4f,_0x25c196[_0x4ab251('0x3e')]),db[_0x4ab251('0x50')][_0x4ab251('0x3f')](_0xa93a4f)[_0x4ab251('0x83')](handleEntityNotFound(_0x3f225e,null))[_0x4ab251('0x83')](respondWithResult(_0x3f225e,null))[_0x4ab251('0x10')](handleError(_0x3f225e,null));},exports['create']=function(_0xef9fe9,_0x1e0e26){const _0x3c6b6b=_0x18fe05;return db[_0x3c6b6b('0x50')][_0x3c6b6b('0x19')](_0xef9fe9[_0x3c6b6b('0x5b')],{})['then'](function(_0x50f254){const _0x1cf32c=_0x3c6b6b,_0x291f93=_0xef9fe9['user']['get']({'plain':!![]});if(!_0x291f93)throw new Error(_0x1cf32c('0x73'));if(_0x291f93[_0x1cf32c('0x4d')]===_0x1cf32c('0x79')){const _0x258b87=_0x50f254[_0x1cf32c('0x5a')]({'plain':!![]}),_0x2a6a0c=_0x1cf32c('0x0');return db[_0x1cf32c('0x65')][_0x1cf32c('0x3f')]({'where':{'name':_0x2a6a0c,'userProfileId':_0x291f93[_0x1cf32c('0x5')]},'raw':!![]})[_0x1cf32c('0x83')](function(_0x712fd7){const _0x5421d2=_0x1cf32c;return _0x712fd7&&_0x712fd7[_0x5421d2('0x57')]===0x0?db[_0x5421d2('0x55')][_0x5421d2('0x19')]({'name':_0x258b87[_0x5421d2('0x52')],'resourceId':_0x258b87['id'],'type':_0x5421d2('0x6e'),'sectionId':_0x712fd7['id']},{})[_0x5421d2('0x83')](function(){return _0x50f254;}):_0x50f254;})['catch'](function(_0x215a4){const _0x43b155=_0x1cf32c;logger[_0x43b155('0x56')](_0x43b155('0x8'),_0x215a4);throw _0x215a4;});}return _0x50f254;})['then'](respondWithResult(_0x1e0e26,0xc9))[_0x3c6b6b('0x10')](handleError(_0x1e0e26,null));},exports[_0x18fe05('0x37')]=function(_0x247594,_0x47cb21){const _0x492294=_0x18fe05;return _0x247594[_0x492294('0x5b')]['id']&&delete _0x247594[_0x492294('0x5b')]['id'],db[_0x492294('0x50')][_0x492294('0x3f')]({'where':{'id':_0x247594['params']['id']}})[_0x492294('0x83')](handleEntityNotFound(_0x47cb21,null))['then'](saveUpdates(_0x247594[_0x492294('0x5b')],null))['then'](respondWithResult(_0x47cb21,null))[_0x492294('0x10')](handleError(_0x47cb21,null));},exports[_0x18fe05('0x3c')]=function(_0x4b7eb1,_0x20b7ca){const _0x1a9cfd=_0x18fe05;return db[_0x1a9cfd('0x50')][_0x1a9cfd('0x3f')]({'where':{'id':_0x4b7eb1['params']['id']}})[_0x1a9cfd('0x83')](handleEntityNotFound(_0x20b7ca,null))[_0x1a9cfd('0x83')](removeEntity(_0x20b7ca,null))[_0x1a9cfd('0x10')](handleError(_0x20b7ca,null));},exports['preview']=function(_0x3d649d,_0x1ca32b){const _0x1207be=_0x18fe05,_0x2cfcb0=0xa,_0xbdb717=[_0x1207be('0x78'),'left_join',_0x1207be('0x1'),_0x1207be('0xa')],_0x2cdca0={'SUM':_0x1207be('0x43'),'COUNT':_0x1207be('0x18'),'COUNT\x20DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x1207be('0x5c'),'MIN':_0x1207be('0x75'),'AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT\x20ASC':_0x1207be('0x16'),'GROUP_CONCAT\x20DESC':_0x1207be('0x5f')},_0x12f578={'SEC_TO_TIME':_0x1207be('0x8c'),'DATE':'DATE(%s)','HOUR':_0x1207be('0x49'),'ROUND':_0x1207be('0x7f'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'},_0x456066=function(_0x112a41){const _0x17c28b=_0x1207be;return!_['includes']([_0x17c28b('0x26'),_0x17c28b('0x39'),_0x17c28b('0x7e'),_0x17c28b('0x33')],_0x112a41);},_0x412cf7=function(_0x48f1eb){const _0x21d25a=_0x1207be;if(!_0x48f1eb||!_0x48f1eb[_0x21d25a('0x42')][_0x21d25a('0x4f')])return'';let _0x5eebcc='(';for(let _0x13be5d=0x0;_0x13be5d<_0x48f1eb[_0x21d25a('0x42')][_0x21d25a('0x4f')];_0x13be5d+=0x1){_0x13be5d>0x0&&(_0x5eebcc+='\x20'+_0x48f1eb[_0x21d25a('0x4b')]+'\x20'),_0x5eebcc+=_0x48f1eb[_0x21d25a('0x42')][_0x13be5d][_0x21d25a('0x23')]?_0x412cf7(_0x48f1eb[_0x21d25a('0x42')][_0x13be5d][_0x21d25a('0x23')]):_0x48f1eb[_0x21d25a('0x42')][_0x13be5d][_0x21d25a('0x70')]+'\x20'+_0x48f1eb[_0x21d25a('0x42')][_0x13be5d][_0x21d25a('0x84')]+(_0x456066(_0x48f1eb[_0x21d25a('0x42')][_0x13be5d][_0x21d25a('0x84')])?'\x20'+_0x48f1eb[_0x21d25a('0x42')][_0x13be5d][_0x21d25a('0x81')]:'');}return _0x5eebcc+')';};let _0x578e4d={'where':{'id':_0x3d649d[_0x1207be('0x41')]['id']}},_0x684984,_0x1c2959,_0x2f0982;return _0x578e4d=_[_0x1207be('0xe')]({},_0x578e4d,_0x3d649d[_0x1207be('0x3e')]),db[_0x1207be('0x50')][_0x1207be('0x3f')](_0x578e4d)['then'](function(_0x4cdb4f){const _0x3e785c=_0x1207be;if(_0x4cdb4f)return _0x684984=_0x4cdb4f,_0x4cdb4f[_0x3e785c('0x15')]();return null;})[_0x1207be('0x83')](function(_0x19ce4a){const _0x42db14=_0x1207be;if(_0x19ce4a){if(!_0x19ce4a[_0x42db14('0x4f')])throw new ValidationErrorItem('Please\x20insert\x20at\x20least\x20one\x20field',0x193);return _0x1c2959=_0x19ce4a,db['AnalyticMetric'][_0x42db14('0x2e')]({'raw':!![]});}return null;})[_0x1207be('0x83')](function(_0x2c0525){const _0x30210f=_0x1207be;if(_0x2c0525){_0x2f0982=_[_0x30210f('0x5d')](_0x2c0525,'id');let _0x64124;const _0x381c01=squel[_0x30210f('0x72')]();_0x381c01[_0x30210f('0x1c')](_0x684984['table']);for(let _0x2fec04=0x0;_0x2fec04<_0x1c2959[_0x30210f('0x4f')];_0x2fec04+=0x1){_0x64124=_0x1c2959[_0x2fec04][_0x30210f('0x7a')]?_0x2f0982[_0x1c2959[_0x2fec04][_0x30210f('0x7a')]][_0x30210f('0x44')]:_0x1c2959[_0x2fec04][_0x30210f('0x70')],_0x64124=_0x1c2959[_0x2fec04]['function']?_['replace'](_0x2cdca0[_0x1c2959[_0x2fec04]['function']],'%s',_0x64124):_0x64124,_0x64124=_0x1c2959[_0x2fec04][_0x30210f('0xb')]?_['replace'](_0x12f578[_0x1c2959[_0x2fec04][_0x30210f('0xb')]],'%s',_0x64124):_0x64124,_0x1c2959[_0x2fec04][_0x30210f('0x61')]&&_0x381c01[_0x30210f('0x23')](_0x64124),_0x1c2959[_0x2fec04]['orderBy']&&_0x381c01['order'](_0x64124,_0x1c2959[_0x2fec04][_0x30210f('0x6d')]===_0x30210f('0x11')?![]:!![]),_0x381c01[_0x30210f('0x70')](_0x64124,_0x1c2959[_0x2fec04][_0x30210f('0x77')]||_0x64124);}if(_0x684984['joins']){_0x684984[_0x30210f('0x20')]=JSON[_0x30210f('0x2f')](_0x684984[_0x30210f('0x20')]);for(let _0x8ee4b3=0x0;_0x8ee4b3<_0x684984[_0x30210f('0x20')]['length'];_0x8ee4b3+=0x1){_0x684984[_0x30210f('0x20')][_0x8ee4b3][_0x30210f('0x28')]&&_[_0x30210f('0x36')](_0xbdb717,_0x684984[_0x30210f('0x20')][_0x8ee4b3][_0x30210f('0x28')])&&_0x684984[_0x30210f('0x20')][_0x8ee4b3][_0x30210f('0x4')]&&_0x684984[_0x30210f('0x20')][_0x8ee4b3][_0x30210f('0x2c')]&&_0x684984[_0x30210f('0x20')][_0x8ee4b3]['foreignKey']&&_0x381c01[_0x684984[_0x30210f('0x20')][_0x8ee4b3][_0x30210f('0x28')]](_0x684984['joins'][_0x8ee4b3][_0x30210f('0x2c')],null,util[_0x30210f('0xb')](_0x30210f('0x1a'),_0x684984[_0x30210f('0x34')],_0x684984[_0x30210f('0x20')][_0x8ee4b3][_0x30210f('0x4')],_0x684984[_0x30210f('0x20')][_0x8ee4b3]['foreignTable'],_0x684984[_0x30210f('0x20')][_0x8ee4b3]['foreignKey']));}}return _0x684984[_0x30210f('0x3a')]&&(_0x684984[_0x30210f('0x3a')]=JSON[_0x30210f('0x2f')](_0x684984[_0x30210f('0x3a')]),_0x381c01['where'](_0x412cf7(_0x684984[_0x30210f('0x3a')][_0x30210f('0x23')]))),_0x381c01[_0x30210f('0x87')](_0x2cfcb0),_0x381c01[_0x30210f('0x14')](0x0),logger['debug'](_0x30210f('0x32'),_0x381c01[_0x30210f('0x7b')]()),db[_0x30210f('0x47')][_0x30210f('0x38')](_0x381c01['toString'](),{'type':QueryTypes[_0x30210f('0x58')]});}})[_0x1207be('0x83')](respondWithResult(_0x1ca32b,null))[_0x1207be('0x10')](handleError(_0x1ca32b,null));};function runReport(_0x442262,_0x28ac28,_0x314de8){const _0x122e10=_0x18fe05,_0x236c5a=_0x28ac28[_0x122e10('0x52')],_0x40b913=0xa,_0x47d0c6=[_0x122e10('0x78'),_0x122e10('0x30'),'right_join',_0x122e10('0xa')],_0x5c5baf={'SUM':'SUM(%s)','COUNT':_0x122e10('0x18'),'COUNT\x20DISTINCT':_0x122e10('0x51'),'MAX':_0x122e10('0x5c'),'MIN':'MIN(%s)','AVG':_0x122e10('0x4c'),'GROUP_CONCAT':_0x122e10('0x17'),'GROUP_CONCAT\x20ASC':_0x122e10('0x16'),'GROUP_CONCAT\x20DESC':_0x122e10('0x5f')},_0x4e8fa9={'SEC_TO_TIME':_0x122e10('0x8c'),'DATE':_0x122e10('0x6b'),'HOUR':_0x122e10('0x49'),'ROUND':_0x122e10('0x7f'),'UNIX_TIMESTAMP':_0x122e10('0x71')},_0x564bec=function(_0x55cba9){const _0x1cfa05=_0x122e10;return!_['includes'](['IS\x20NULL','IS\x20NOT\x20NULL',_0x1cfa05('0x7e'),_0x1cfa05('0x33')],_0x55cba9);},_0x4982c9=function(_0x5815bb){const _0x11cf83=_0x122e10;if(!_0x5815bb||!_0x5815bb[_0x11cf83('0x42')][_0x11cf83('0x4f')])return'';let _0x2b3fa6='(';for(let _0x5c380e=0x0;_0x5c380e<_0x5815bb['rules']['length'];_0x5c380e+=0x1){_0x5c380e>0x0&&(_0x2b3fa6+='\x20'+_0x5815bb[_0x11cf83('0x4b')]+'\x20'),_0x2b3fa6+=_0x5815bb[_0x11cf83('0x42')][_0x5c380e][_0x11cf83('0x23')]?_0x4982c9(_0x5815bb[_0x11cf83('0x42')][_0x5c380e][_0x11cf83('0x23')]):_0x5815bb[_0x11cf83('0x42')][_0x5c380e]['field']+'\x20'+_0x5815bb[_0x11cf83('0x42')][_0x5c380e][_0x11cf83('0x84')]+(_0x564bec(_0x5815bb[_0x11cf83('0x42')][_0x5c380e][_0x11cf83('0x84')])?'\x20'+_0x5815bb[_0x11cf83('0x42')][_0x5c380e]['value']:'');}return _0x2b3fa6+')';};let _0x3a7b15={'where':{'id':_0x442262['id']}},_0xe4e00a,_0x34df7f,_0xed0531,_0x34e20d,_0x2009ea;return _0x3a7b15=_[_0x122e10('0xe')]({},_0x3a7b15,_0x314de8),db[_0x122e10('0x50')][_0x122e10('0x3f')](_0x3a7b15)['then'](function(_0x5a3c19){const _0x3222bb=_0x122e10;if(_0x5a3c19)return _0xe4e00a=_0x5a3c19,_0x5a3c19[_0x3222bb('0x15')]();return null;})['then'](function(_0x37f3b1){const _0xe2643c=_0x122e10;if(_0x37f3b1){if(!_0x37f3b1['length'])throw new ValidationErrorItem(_0xe2643c('0x4e'),0x193);return _0x34df7f=_0x37f3b1,db[_0xe2643c('0xf')][_0xe2643c('0x2e')]({'raw':!![]});}return null;})[_0x122e10('0x83')](function(_0x271fe1){const _0xf05792=_0x122e10;if(_0x271fe1){_0xed0531=_[_0xf05792('0x5d')](_0x271fe1,'id');let _0x87af0e;const _0x254ea2=squel[_0xf05792('0x72')]();_0x254ea2[_0xf05792('0x1c')](_0xe4e00a[_0xf05792('0x34')]);for(let _0x121dd5=0x0;_0x121dd5<_0x34df7f[_0xf05792('0x4f')];_0x121dd5+=0x1){_0x87af0e=_0x34df7f[_0x121dd5]['MetricId']?_0xed0531[_0x34df7f[_0x121dd5][_0xf05792('0x7a')]][_0xf05792('0x44')]:_0x34df7f[_0x121dd5][_0xf05792('0x70')],_0x87af0e=_0x34df7f[_0x121dd5][_0xf05792('0x31')]?_[_0xf05792('0x24')](_0x5c5baf[_0x34df7f[_0x121dd5][_0xf05792('0x31')]],'%s',_0x87af0e):_0x87af0e,_0x87af0e=_0x34df7f[_0x121dd5][_0xf05792('0xb')]?_[_0xf05792('0x24')](_0x4e8fa9[_0x34df7f[_0x121dd5][_0xf05792('0xb')]],'%s',_0x87af0e):_0x87af0e,_0x34df7f[_0x121dd5][_0xf05792('0x61')]&&_0x254ea2[_0xf05792('0x23')](_0x87af0e),_0x34df7f[_0x121dd5][_0xf05792('0x6d')]&&_0x254ea2[_0xf05792('0x22')](_0x87af0e,_0x34df7f[_0x121dd5]['orderBy']===_0xf05792('0x11')?![]:!![]),_0x254ea2[_0xf05792('0x70')](_0x87af0e,_0x34df7f[_0x121dd5][_0xf05792('0x77')]||_0x87af0e);}if(_0xe4e00a[_0xf05792('0x20')]){_0xe4e00a[_0xf05792('0x20')]=JSON[_0xf05792('0x2f')](_0xe4e00a[_0xf05792('0x20')]);for(let _0x44c58f=0x0;_0x44c58f<_0xe4e00a[_0xf05792('0x20')][_0xf05792('0x4f')];_0x44c58f+=0x1){_0xe4e00a[_0xf05792('0x20')][_0x44c58f][_0xf05792('0x28')]&&_['includes'](_0x47d0c6,_0xe4e00a[_0xf05792('0x20')][_0x44c58f][_0xf05792('0x28')])&&_0xe4e00a[_0xf05792('0x20')][_0x44c58f][_0xf05792('0x4')]&&_0xe4e00a[_0xf05792('0x20')][_0x44c58f][_0xf05792('0x2c')]&&_0xe4e00a[_0xf05792('0x20')][_0x44c58f]['foreignKey']&&_0x254ea2[_0xe4e00a[_0xf05792('0x20')][_0x44c58f][_0xf05792('0x28')]](_0xe4e00a['joins'][_0x44c58f][_0xf05792('0x2c')],null,util['format'](_0xf05792('0x1a'),_0xe4e00a[_0xf05792('0x34')],_0xe4e00a[_0xf05792('0x20')][_0x44c58f]['parentKey'],_0xe4e00a[_0xf05792('0x20')][_0x44c58f][_0xf05792('0x2c')],_0xe4e00a[_0xf05792('0x20')][_0x44c58f][_0xf05792('0xc')]));}}return _0xe4e00a[_0xf05792('0x3a')]&&(_0xe4e00a[_0xf05792('0x3a')]=JSON[_0xf05792('0x2f')](_0xe4e00a[_0xf05792('0x3a')]),_0x254ea2[_0xf05792('0x8b')](_0x4982c9(_0xe4e00a[_0xf05792('0x3a')][_0xf05792('0x23')]))),_0x2009ea=_0x254ea2[_0xf05792('0x62')](),_0x254ea2['limit'](_0x40b913),_0x254ea2[_0xf05792('0x14')](0x0),logger[_0xf05792('0x54')](_0xf05792('0x32'),_0x254ea2[_0xf05792('0x7b')]()),db[_0xf05792('0x47')]['query'](_0x254ea2[_0xf05792('0x7b')](),{'type':QueryTypes['SELECT']});}})[_0x122e10('0x83')](function(_0x2f980c){const _0x3f229a=_0x122e10;if(!_0x2f980c[_0x3f229a('0x4f')])throw new ValidationErrorItem(_0x3f229a('0x40'),0xcc);if(_0x28ac28[_0x3f229a('0x82')]===_0x3f229a('0x63'))return null;const _0xcf4d0e=_['merge'](_0x28ac28,{'name':_0x28ac28[_0x3f229a('0x2a')]||_0x28ac28[_0x3f229a('0x52')]||_0xe4e00a[_0x3f229a('0x52')],'basename':_0x236c5a,'savename':util[_0x3f229a('0xb')](_0x3f229a('0x13'),_0x28ac28[_0x3f229a('0x52')]||_0xe4e00a[_0x3f229a('0x52')],require(_0x3f229a('0x25'))[_0x3f229a('0x69')](0x4),_0x28ac28['output']||_0x3f229a('0x80')),'reportId':_0xe4e00a['id'],'reportType':_0x3f229a('0x66')});return db[_0x3f229a('0x53')][_0x3f229a('0x19')](_0xcf4d0e,{'raw':!![]});})[_0x122e10('0x83')](function(_0xabfa0e){const _0x40e2b2=_0x122e10;_0xe4e00a[_0x40e2b2('0x34')]===_0x40e2b2('0x4a')?_0x2009ea[_0x40e2b2('0x8b')](_0xe4e00a['table']+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x28ac28[_0x40e2b2('0x2d')],_0x28ac28[_0x40e2b2('0x27')]):_0x2009ea[_0x40e2b2('0x8b')](_0xe4e00a[_0x40e2b2('0x34')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x28ac28[_0x40e2b2('0x2d')],_0x28ac28[_0x40e2b2('0x27')]);if(_0xabfa0e)return logger[_0x40e2b2('0x1b')](_0x40e2b2('0x88'),_0x2009ea['toString']()),require(_0x40e2b2('0x5e'))['fork'](path['join'](__dirname,'../../components/export/',_0xabfa0e[_0x40e2b2('0x82')]),[_0xabfa0e['id'],_0x2009ea[_0x40e2b2('0x7b')](),path[_0x40e2b2('0x78')](__dirname,'../../files/reports',_0xabfa0e['savename']),_0x236c5a]),_0xabfa0e;else{const _0x1d546d=squel['select']();return _0x1d546d['from']('('+_0x2009ea['toString']()+')',_0x40e2b2('0x2b')),_0x1d546d[_0x40e2b2('0x70')](_0x40e2b2('0x2'),'count'),_0x2009ea[_0x40e2b2('0x87')](_0x28ac28[_0x40e2b2('0x87')]||_0x40b913),_0x2009ea[_0x40e2b2('0x14')](_0x28ac28[_0x40e2b2('0x14')]||0x0),dbH[_0x40e2b2('0x47')][_0x40e2b2('0x38')](_0x1d546d[_0x40e2b2('0x7b')](),{'type':dbH[_0x40e2b2('0x47')][_0x40e2b2('0x7d')][_0x40e2b2('0x58')]})[_0x40e2b2('0x83')](function(_0x12d5e1){const _0xa4cce8=_0x40e2b2;return!_0x12d5e1['length']?_0x34e20d=0x0:_0x34e20d=_0x12d5e1[0x0][_0xa4cce8('0x76')]||0x0,dbH['sequelize'][_0xa4cce8('0x38')](_0x2009ea[_0xa4cce8('0x7b')](),{'type':dbH[_0xa4cce8('0x47')]['QueryTypes'][_0xa4cce8('0x58')]});})[_0x40e2b2('0x83')](function(_0x1bedb2){return{'rows':_0x1bedb2||[],'count':_0x34e20d};});}});}exports['run']=function(_0x7e76b5,_0x4b6103){const _0x6c10ae=_0x18fe05;return runReport(_0x7e76b5[_0x6c10ae('0x41')],_0x7e76b5[_0x6c10ae('0x38')],_0x7e76b5['options'])[_0x6c10ae('0x83')](respondWithResult(_0x4b6103,null))[_0x6c10ae('0x10')](handleError(_0x4b6103,null));},exports[_0x18fe05('0x3b')]=runReport,exports['query']=function(_0x3afc05,_0x4838fc){const _0x11ab41=_0x18fe05,_0x9ce1be=0xa,_0xd69b27=[_0x11ab41('0x78'),_0x11ab41('0x30'),_0x11ab41('0x1'),'cross_join'],_0x352e5a={'SUM':'SUM(%s)','COUNT':_0x11ab41('0x18'),'COUNT\x20DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x11ab41('0x5c'),'MIN':_0x11ab41('0x75'),'AVG':'AVG(%s)','GROUP_CONCAT':_0x11ab41('0x17'),'GROUP_CONCAT\x20ASC':_0x11ab41('0x16'),'GROUP_CONCAT\x20DESC':_0x11ab41('0x5f')},_0x58b88d={'SEC_TO_TIME':_0x11ab41('0x8c'),'DATE':_0x11ab41('0x6b'),'HOUR':_0x11ab41('0x49'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x11ab41('0x71')},_0x84e92c=function(_0x2f2e51){const _0x23f4ac=_0x11ab41;return!_[_0x23f4ac('0x36')](['IS\x20NULL',_0x23f4ac('0x39'),_0x23f4ac('0x7e'),_0x23f4ac('0x33')],_0x2f2e51);},_0x3475c5=function(_0x124e0e){const _0x4e0efc=_0x11ab41;if(!_0x124e0e||!_0x124e0e[_0x4e0efc('0x42')][_0x4e0efc('0x4f')])return'';let _0xb0e7eb='(';for(let _0x1223a2=0x0;_0x1223a2<_0x124e0e[_0x4e0efc('0x42')]['length'];_0x1223a2+=0x1){_0x1223a2>0x0&&(_0xb0e7eb+='\x20'+_0x124e0e[_0x4e0efc('0x4b')]+'\x20'),_0xb0e7eb+=_0x124e0e[_0x4e0efc('0x42')][_0x1223a2]['group']?_0x3475c5(_0x124e0e[_0x4e0efc('0x42')][_0x1223a2][_0x4e0efc('0x23')]):_0x124e0e['rules'][_0x1223a2][_0x4e0efc('0x70')]+'\x20'+_0x124e0e[_0x4e0efc('0x42')][_0x1223a2][_0x4e0efc('0x84')]+(_0x84e92c(_0x124e0e[_0x4e0efc('0x42')][_0x1223a2][_0x4e0efc('0x84')])?'\x20'+_0x124e0e[_0x4e0efc('0x42')][_0x1223a2]['value']:'');}return _0xb0e7eb+')';};let _0x12d7c4={'where':{'id':_0x3afc05[_0x11ab41('0x41')]['id']}},_0x29e777,_0x3e89a4,_0x28541e,_0x80cf3e;return _0x12d7c4=_['merge']({},_0x12d7c4,_0x3afc05[_0x11ab41('0x3e')]),db[_0x11ab41('0x50')][_0x11ab41('0x3f')](_0x12d7c4)['then'](function(_0x1a988b){if(_0x1a988b)return _0x29e777=_0x1a988b,_0x1a988b['getFields']();return null;})[_0x11ab41('0x83')](function(_0x179080){const _0x147c33=_0x11ab41;if(_0x179080){if(!_0x179080[_0x147c33('0x4f')])throw new ValidationErrorItem(_0x147c33('0x4e'),0x193);return _0x3e89a4=_0x179080,db[_0x147c33('0xf')]['findAll']({'raw':!![]});}return null;})['then'](function(_0xc1ca78){const _0x2c982e=_0x11ab41;if(_0xc1ca78){_0x28541e=_['keyBy'](_0xc1ca78,'id');let _0x178d2e;const _0x3ee0c5=squel['select']();_0x3ee0c5['from'](_0x29e777[_0x2c982e('0x34')]);for(let _0x522cc1=0x0;_0x522cc1<_0x3e89a4['length'];_0x522cc1+=0x1){_0x178d2e=_0x3e89a4[_0x522cc1][_0x2c982e('0x7a')]?_0x28541e[_0x3e89a4[_0x522cc1]['MetricId']][_0x2c982e('0x44')]:_0x3e89a4[_0x522cc1][_0x2c982e('0x70')],_0x178d2e=_0x3e89a4[_0x522cc1][_0x2c982e('0x31')]?_['replace'](_0x352e5a[_0x3e89a4[_0x522cc1][_0x2c982e('0x31')]],'%s',_0x178d2e):_0x178d2e,_0x178d2e=_0x3e89a4[_0x522cc1][_0x2c982e('0xb')]?_[_0x2c982e('0x24')](_0x58b88d[_0x3e89a4[_0x522cc1]['format']],'%s',_0x178d2e):_0x178d2e,_0x3e89a4[_0x522cc1][_0x2c982e('0x61')]&&_0x3ee0c5[_0x2c982e('0x23')](_0x178d2e),_0x3e89a4[_0x522cc1][_0x2c982e('0x6d')]&&_0x3ee0c5[_0x2c982e('0x22')](_0x178d2e,_0x3e89a4[_0x522cc1][_0x2c982e('0x6d')]===_0x2c982e('0x11')?![]:!![]),_0x3ee0c5['field'](_0x178d2e,_0x3e89a4[_0x522cc1][_0x2c982e('0x77')]||_0x178d2e);}if(_0x29e777[_0x2c982e('0x20')]){_0x29e777['joins']=JSON[_0x2c982e('0x2f')](_0x29e777[_0x2c982e('0x20')]);for(let _0x3dcd2f=0x0;_0x3dcd2f<_0x29e777[_0x2c982e('0x20')]['length'];_0x3dcd2f+=0x1){_0x29e777['joins'][_0x3dcd2f][_0x2c982e('0x28')]&&_['includes'](_0xd69b27,_0x29e777[_0x2c982e('0x20')][_0x3dcd2f][_0x2c982e('0x28')])&&_0x29e777[_0x2c982e('0x20')][_0x3dcd2f][_0x2c982e('0x4')]&&_0x29e777[_0x2c982e('0x20')][_0x3dcd2f][_0x2c982e('0x2c')]&&_0x29e777[_0x2c982e('0x20')][_0x3dcd2f][_0x2c982e('0xc')]&&_0x3ee0c5[_0x29e777[_0x2c982e('0x20')][_0x3dcd2f][_0x2c982e('0x28')]](_0x29e777[_0x2c982e('0x20')][_0x3dcd2f]['foreignTable'],null,util[_0x2c982e('0xb')](_0x2c982e('0x1a'),_0x29e777[_0x2c982e('0x34')],_0x29e777[_0x2c982e('0x20')][_0x3dcd2f]['parentKey'],_0x29e777[_0x2c982e('0x20')][_0x3dcd2f][_0x2c982e('0x2c')],_0x29e777[_0x2c982e('0x20')][_0x3dcd2f]['foreignKey']));}}return _0x29e777[_0x2c982e('0x3a')]&&(_0x29e777[_0x2c982e('0x3a')]=JSON[_0x2c982e('0x2f')](_0x29e777['conditions']),_0x3ee0c5[_0x2c982e('0x8b')](_0x3475c5(_0x29e777[_0x2c982e('0x3a')][_0x2c982e('0x23')]))),_0x80cf3e=_0x3ee0c5['clone'](),_0x3ee0c5[_0x2c982e('0x87')](_0x9ce1be),_0x3ee0c5[_0x2c982e('0x14')](0x0),logger[_0x2c982e('0x54')](_0x2c982e('0x32'),_0x3ee0c5['toString']()),db[_0x2c982e('0x47')][_0x2c982e('0x38')](_0x3ee0c5['toString'](),{'type':QueryTypes['SELECT']});}})[_0x11ab41('0x83')](function(){const _0x314e10=_0x11ab41;return{'sql':_0x80cf3e[_0x314e10('0x7b')]()};})['then'](respondWithResult(_0x4838fc,null))[_0x11ab41('0x10')](handleError(_0x4838fc,null));};
\ No newline at end of file
+const a6_0x47a3=['DESC','catch','UNIX_TIMESTAMP(%s)','AnalyticCustomReport','COUNT(*)','findOne','Reports','countTable','../../config/logger','userProfileId','IS\x20NULL','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','index','key','count','nolimit','metric','Run\x20Query:','function','get','cross_join','autoAssociation','fork','then','AVG(%s)','filters','MAX(%s)','right_join','sequelize','output','map','cdr','replace','type','toString','COUNT(%s)','condition','rows','length','alias','AnalyticMetric','name','foreignKey','joins','ROUND(%s)','create','fullPath','UserProfileResource','attributes','GROUP_CONCAT(%s)','custom','UserProfileSection','show','destroy','SUM(%s)','MetricId','user','Please\x20insert\x20at\x20least\x20one\x20field','stack','query','../../components/export/','run','IS\x20EMPTY','sendStatus','keyBy','squel','status','dbH','table','SELECT','MIN(%s)','runReport','json','group','format','merge','operator','savename','error','IS\x20NOT\x20EMPTY','params','endDate','%s.%s\x20=\x20%s.%s','left_join','Unable\x20to\x20retrieve\x20the\x20current\x20user','model','from','options','groupBy','include','Limited\x20Query:','fieldName','field','rawAttributes','startDate','like','COUNT(DISTINCT\x20%s)','preview','Content-Range','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','join','value','path','order','getFields','clone','set','.calldate\x20BETWEEN\x20?\x20AND\x20?','where','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','rules','randomstring','CustomReports','filter','offset','intersection','includes','end','debug','limit','lodash','parentKey','parse','orderBy','HOUR(%s)','body','info','includeAll','conditions','child_process','SEC_TO_TIME(%s)','fields','api','QueryTypes','util','keys','../../mysqldb','DATE(%s)','AnalyticExtractedReport','IS\x20NOT\x20NULL','foreignTable','send','select','findAll','web'];(function(_0x19bcf3,_0x2ceebe){const _0x47a363=function(_0x58d6a2){while(--_0x58d6a2){_0x19bcf3['push'](_0x19bcf3['shift']());}};_0x47a363(++_0x2ceebe);}(a6_0x47a3,0xf4));const a6_0x58d6=function(_0x19bcf3,_0x2ceebe){_0x19bcf3=_0x19bcf3-0xc8;let _0x47a363=a6_0x47a3[_0x19bcf3];return _0x47a363;};const a6_0x3930aa=a6_0x58d6;'use strict';const util=require(a6_0x3930aa(0xed)),path=require(a6_0x3930aa(0xcc)),_=require(a6_0x3930aa(0xdf)),squel=require(a6_0x3930aa(0x139)),qs=require('../../components/parsers/qs'),logger=require(a6_0x3930aa(0x100))(a6_0x3930aa(0xeb)),{db}=require(a6_0x3930aa(0xef)),dbH=require(a6_0x3930aa(0xef))[a6_0x3930aa(0x13b)],{Op,ValidationErrorItem,QueryTypes}=require(a6_0x3930aa(0x114));function respondWithResult(_0x335f74,_0x4f6ea9){return _0x4f6ea9=_0x4f6ea9||0xc8,function(_0x270ea3){const _0x31fc2b=a6_0x58d6;if(_0x270ea3)return _0x335f74[_0x31fc2b(0x13a)](_0x4f6ea9)['json'](_0x270ea3);};}function respondWithFilteredResult(_0xcbb96b,_0x5ebf73){return function(_0x2208c8){const _0x3bc87c=a6_0x58d6;if(_0x2208c8){const _0x46be39=_0x2208c8[_0x3bc87c(0x106)],_0x53b07a=_0x5ebf73[_0x3bc87c(0xd9)];let _0x4a52ef=_0x5ebf73['offset']+_0x5ebf73[_0x3bc87c(0xde)],_0xb94545;return _0x4a52ef>=_0x46be39?(_0x4a52ef=_0x46be39,_0xb94545=0xc8):_0xb94545=0xce,_0xcbb96b['status'](_0xb94545),_0xcbb96b[_0x3bc87c(0xd0)](_0x3bc87c(0xc8),_0x53b07a+'-'+_0x4a52ef+'/'+_0x46be39)[_0x3bc87c(0x140)](_0x2208c8);}return null;};}function saveUpdates(_0x39e6ae){return function(_0x4ab098){const _0x497c88=a6_0x58d6;if(_0x4ab098)return _0x4ab098[_0x497c88(0xd4)](_0x39e6ae)['then'](function(_0x2c94cf){return _0x2c94cf;});return null;};}function removeEntity(_0x4a901f){return function(_0x5900a0){const _0x176d3e=a6_0x58d6;if(_0x5900a0)return _0x5900a0['destroy']()[_0x176d3e(0x10f)](function(){const _0x584831=_0x176d3e,_0x444477=_0x5900a0[_0x584831(0x10b)]({'plain':!![]}),_0x6d326d='CustomReports';return db[_0x584831(0x127)][_0x584831(0x12d)]({'where':{'type':_0x6d326d,'resourceId':_0x444477['id']}})[_0x584831(0x10f)](function(){return _0x5900a0;});})[_0x176d3e(0x10f)](function(){const _0x4d7044=_0x176d3e;_0x4a901f[_0x4d7044(0x13a)](0xcc)[_0x4d7044(0xdc)]();});};}function handleEntityNotFound(_0x2285bc){return function(_0x3cb59f){const _0x1d8d85=a6_0x58d6;return!_0x3cb59f&&_0x2285bc[_0x1d8d85(0x137)](0x194),_0x3cb59f;};}function handleError(_0x569e7f,_0x29ebda){return _0x29ebda=_0x29ebda||0x1f4,function(_0x37097c){const _0x217d5e=a6_0x58d6;logger[_0x217d5e(0x146)](_0x37097c[_0x217d5e(0x132)]),_0x37097c[_0x217d5e(0x121)]&&delete _0x37097c['name'],_0x569e7f[_0x217d5e(0x13a)](_0x29ebda)[_0x217d5e(0xf4)](_0x37097c);};}exports[a6_0x3930aa(0x104)]=function(_0x4bb0a6,_0x54b721){const _0x5b689e=a6_0x3930aa;let _0x2b1d69={};const _0x228e9={},_0x93c09={'count':0x0,'rows':[]},_0x4eebab=_[_0x5b689e(0x116)](db['AnalyticCustomReport'][_0x5b689e(0x155)],function(_0x461a0b){const _0x1acce4=_0x5b689e;return{'name':_0x461a0b[_0x1acce4(0x153)],'type':_0x461a0b[_0x1acce4(0x119)][_0x1acce4(0x105)]};});_0x228e9[_0x5b689e(0x14d)]=_[_0x5b689e(0x116)](_0x4eebab,_0x5b689e(0x121)),_0x228e9[_0x5b689e(0x133)]=_[_0x5b689e(0xee)](_0x4bb0a6['query']),_0x228e9[_0x5b689e(0x111)]=_['intersection'](_0x228e9['model'],_0x228e9[_0x5b689e(0x133)]),_0x2b1d69[_0x5b689e(0x128)]=_[_0x5b689e(0xda)](_0x228e9['model'],qs[_0x5b689e(0xea)](_0x4bb0a6[_0x5b689e(0x133)]['fields'])),_0x2b1d69['attributes']=_0x2b1d69[_0x5b689e(0x128)][_0x5b689e(0x11e)]?_0x2b1d69[_0x5b689e(0x128)]:_0x228e9[_0x5b689e(0x14d)];typeof _0x4bb0a6['query'][_0x5b689e(0x107)]==='undefined'&&(_0x2b1d69[_0x5b689e(0xde)]=qs[_0x5b689e(0xde)](_0x4bb0a6[_0x5b689e(0x133)][_0x5b689e(0xde)]),_0x2b1d69[_0x5b689e(0xd9)]=qs[_0x5b689e(0xd9)](_0x4bb0a6[_0x5b689e(0x133)][_0x5b689e(0xd9)]));_0x2b1d69[_0x5b689e(0xcd)]=qs['sort'](_0x4bb0a6[_0x5b689e(0x133)]['sort']),_0x2b1d69[_0x5b689e(0xd2)]=qs[_0x5b689e(0x111)](_['pick'](_0x4bb0a6[_0x5b689e(0x133)],_0x228e9[_0x5b689e(0x111)]),_0x4eebab);_0x4bb0a6[_0x5b689e(0x133)][_0x5b689e(0xd8)]&&(_0x2b1d69['where']=_[_0x5b689e(0x143)](_0x2b1d69[_0x5b689e(0xd2)],{[Op['or']]:_[_0x5b689e(0x116)](_0x4eebab,function(_0x36cb87){const _0x4ca92b=_0x5b689e;if(_0x36cb87[_0x4ca92b(0x119)]!=='VIRTUAL'){const _0x4a5f90={};return _0x4a5f90[_0x36cb87[_0x4ca92b(0x121)]]={[Op[_0x4ca92b(0x157)]]:'%'+_0x4bb0a6[_0x4ca92b(0x133)]['filter']+'%'},_0x4a5f90;}})}));_0x2b1d69=_['merge']({},_0x2b1d69,_0x4bb0a6[_0x5b689e(0x14f)]);const _0x15f662={'where':_0x2b1d69['where']};return db['AnalyticCustomReport']['count'](_0x15f662)['then'](function(_0x1af252){const _0x3d7da5=_0x5b689e;return _0x93c09[_0x3d7da5(0x106)]=_0x1af252,_0x4bb0a6[_0x3d7da5(0x133)]['includeAll']&&(_0x2b1d69['include']=[{'all':!![]}]),db[_0x3d7da5(0xfb)][_0x3d7da5(0xf6)](_0x2b1d69);})[_0x5b689e(0x10f)](function(_0x131b7e){const _0x15f540=_0x5b689e;return _0x93c09[_0x15f540(0x11d)]=_0x131b7e,_0x93c09;})[_0x5b689e(0x10f)](respondWithFilteredResult(_0x54b721,_0x2b1d69))[_0x5b689e(0xf9)](handleError(_0x54b721,null));},exports[a6_0x3930aa(0x12c)]=function(_0x31bb1a,_0x3fd92f){const _0x805859=a6_0x3930aa;let _0x1e7871={'raw':![],'where':{'id':_0x31bb1a[_0x805859(0x148)]['id']}};const _0x55a2c1={};return _0x55a2c1[_0x805859(0x14d)]=_[_0x805859(0xee)](db[_0x805859(0xfb)][_0x805859(0x155)]),_0x55a2c1[_0x805859(0x133)]=_[_0x805859(0xee)](_0x31bb1a['query']),_0x55a2c1[_0x805859(0x111)]=_['intersection'](_0x55a2c1[_0x805859(0x14d)],_0x55a2c1[_0x805859(0x133)]),_0x1e7871[_0x805859(0x128)]=_['intersection'](_0x55a2c1[_0x805859(0x14d)],qs[_0x805859(0xea)](_0x31bb1a[_0x805859(0x133)][_0x805859(0xea)])),_0x1e7871[_0x805859(0x128)]=_0x1e7871[_0x805859(0x128)]['length']?_0x1e7871[_0x805859(0x128)]:_0x55a2c1[_0x805859(0x14d)],_0x31bb1a['query'][_0x805859(0xe6)]&&(_0x1e7871[_0x805859(0x151)]=[{'all':!![]}]),_0x1e7871=_[_0x805859(0x143)]({},_0x1e7871,_0x31bb1a[_0x805859(0x14f)]),db['AnalyticCustomReport'][_0x805859(0xfd)](_0x1e7871)['then'](handleEntityNotFound(_0x3fd92f,null))[_0x805859(0x10f)](respondWithResult(_0x3fd92f,null))[_0x805859(0xf9)](handleError(_0x3fd92f,null));},exports[a6_0x3930aa(0x125)]=function(_0x4cbbf6,_0x3a6147){const _0x52e035=a6_0x3930aa;return db[_0x52e035(0xfb)][_0x52e035(0x125)](_0x4cbbf6[_0x52e035(0xe4)],{})[_0x52e035(0x10f)](function(_0x389c72){const _0xe4d453=_0x52e035,_0x5ca64a=_0x4cbbf6[_0xe4d453(0x130)][_0xe4d453(0x10b)]({'plain':!![]});if(!_0x5ca64a)throw new Error(_0xe4d453(0x14c));if(_0x5ca64a['role']===_0xe4d453(0x130)){const _0x22fab5=_0x389c72[_0xe4d453(0x10b)]({'plain':!![]}),_0x421467=_0xe4d453(0xfe);return db[_0xe4d453(0x12b)]['findOne']({'where':{'name':_0x421467,'userProfileId':_0x5ca64a[_0xe4d453(0x101)]},'raw':!![]})[_0xe4d453(0x10f)](function(_0x394a81){const _0x1dbe58=_0xe4d453;return _0x394a81&&_0x394a81[_0x1dbe58(0x10d)]===0x0?db['UserProfileResource'][_0x1dbe58(0x125)]({'name':_0x22fab5['name'],'resourceId':_0x22fab5['id'],'type':_0x1dbe58(0xd7),'sectionId':_0x394a81['id']},{})[_0x1dbe58(0x10f)](function(){return _0x389c72;}):_0x389c72;})[_0xe4d453(0xf9)](function(_0x4013fe){const _0x4da1df=_0xe4d453;logger[_0x4da1df(0x146)](_0x4da1df(0xd3),_0x4013fe);throw _0x4013fe;});}return _0x389c72;})[_0x52e035(0x10f)](respondWithResult(_0x3a6147,0xc9))[_0x52e035(0xf9)](handleError(_0x3a6147,null));},exports[a6_0x3930aa(0xd4)]=function(_0xf1516f,_0x276f12){const _0x25851f=a6_0x3930aa;return _0xf1516f[_0x25851f(0xe4)]['id']&&delete _0xf1516f['body']['id'],db[_0x25851f(0xfb)][_0x25851f(0xfd)]({'where':{'id':_0xf1516f[_0x25851f(0x148)]['id']}})[_0x25851f(0x10f)](handleEntityNotFound(_0x276f12,null))['then'](saveUpdates(_0xf1516f['body'],null))[_0x25851f(0x10f)](respondWithResult(_0x276f12,null))[_0x25851f(0xf9)](handleError(_0x276f12,null));},exports[a6_0x3930aa(0x12d)]=function(_0x4cfcd4,_0x37dca7){const _0x1f89f1=a6_0x3930aa;return db[_0x1f89f1(0xfb)][_0x1f89f1(0xfd)]({'where':{'id':_0x4cfcd4[_0x1f89f1(0x148)]['id']}})[_0x1f89f1(0x10f)](handleEntityNotFound(_0x37dca7,null))[_0x1f89f1(0x10f)](removeEntity(_0x37dca7,null))[_0x1f89f1(0xf9)](handleError(_0x37dca7,null));},exports[a6_0x3930aa(0x159)]=function(_0x2e9d0c,_0x4ef869){const _0x556b78=a6_0x3930aa,_0x4d9826=0xa,_0x2b568c=[_0x556b78(0xca),_0x556b78(0x14b),_0x556b78(0x113),_0x556b78(0x10c)],_0x5caafc={'SUM':_0x556b78(0x12e),'COUNT':_0x556b78(0x11b),'COUNT\x20DISTINCT':_0x556b78(0x158),'MAX':_0x556b78(0x112),'MIN':_0x556b78(0x13e),'AVG':_0x556b78(0x110),'GROUP_CONCAT':_0x556b78(0x129),'GROUP_CONCAT\x20ASC':_0x556b78(0xc9),'GROUP_CONCAT\x20DESC':_0x556b78(0x103)},_0x22b84f={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':'DATE(%s)','HOUR':_0x556b78(0xe3),'ROUND':_0x556b78(0x124),'UNIX_TIMESTAMP':_0x556b78(0xfa)},_0x41b161=function(_0x47df57){const _0x173af9=_0x556b78;return!_[_0x173af9(0xdb)]([_0x173af9(0x102),'IS\x20NOT\x20NULL',_0x173af9(0x136),'IS\x20NOT\x20EMPTY'],_0x47df57);},_0x98a7cb=function(_0x431ff3){const _0xe8cc7d=_0x556b78;if(!_0x431ff3||!_0x431ff3[_0xe8cc7d(0xd5)][_0xe8cc7d(0x11e)])return'';let _0x1387c5='(';for(let _0x4f5ccd=0x0;_0x4f5ccd<_0x431ff3[_0xe8cc7d(0xd5)]['length'];_0x4f5ccd+=0x1){_0x4f5ccd>0x0&&(_0x1387c5+='\x20'+_0x431ff3['operator']+'\x20'),_0x1387c5+=_0x431ff3[_0xe8cc7d(0xd5)][_0x4f5ccd][_0xe8cc7d(0x141)]?_0x98a7cb(_0x431ff3[_0xe8cc7d(0xd5)][_0x4f5ccd][_0xe8cc7d(0x141)]):_0x431ff3['rules'][_0x4f5ccd]['field']+'\x20'+_0x431ff3[_0xe8cc7d(0xd5)][_0x4f5ccd][_0xe8cc7d(0x11c)]+(_0x41b161(_0x431ff3[_0xe8cc7d(0xd5)][_0x4f5ccd][_0xe8cc7d(0x11c)])?'\x20'+_0x431ff3[_0xe8cc7d(0xd5)][_0x4f5ccd][_0xe8cc7d(0xcb)]:'');}return _0x1387c5+')';};let _0xdebc01={'where':{'id':_0x2e9d0c[_0x556b78(0x148)]['id']}},_0x4beb23,_0x478cc0,_0x2f6d6c;return _0xdebc01=_[_0x556b78(0x143)]({},_0xdebc01,_0x2e9d0c[_0x556b78(0x14f)]),db[_0x556b78(0xfb)]['findOne'](_0xdebc01)[_0x556b78(0x10f)](function(_0x1e4bc9){if(_0x1e4bc9)return _0x4beb23=_0x1e4bc9,_0x1e4bc9['getFields']();return null;})[_0x556b78(0x10f)](function(_0x286c17){const _0x54bd4=_0x556b78;if(_0x286c17){if(!_0x286c17['length'])throw new ValidationErrorItem('Please\x20insert\x20at\x20least\x20one\x20field',0x193);return _0x478cc0=_0x286c17,db[_0x54bd4(0x120)]['findAll']({'raw':!![]});}return null;})[_0x556b78(0x10f)](function(_0x4f6c3c){const _0x45dc94=_0x556b78;if(_0x4f6c3c){_0x2f6d6c=_[_0x45dc94(0x138)](_0x4f6c3c,'id');let _0x5947d0;const _0x1895a4=squel[_0x45dc94(0xf5)]();_0x1895a4[_0x45dc94(0x14e)](_0x4beb23['table']);for(let _0x4b01fb=0x0;_0x4b01fb<_0x478cc0['length'];_0x4b01fb+=0x1){_0x5947d0=_0x478cc0[_0x4b01fb][_0x45dc94(0x12f)]?_0x2f6d6c[_0x478cc0[_0x4b01fb]['MetricId']]['metric']:_0x478cc0[_0x4b01fb][_0x45dc94(0x154)],_0x5947d0=_0x478cc0[_0x4b01fb]['function']?_[_0x45dc94(0x118)](_0x5caafc[_0x478cc0[_0x4b01fb][_0x45dc94(0x10a)]],'%s',_0x5947d0):_0x5947d0,_0x5947d0=_0x478cc0[_0x4b01fb][_0x45dc94(0x142)]?_[_0x45dc94(0x118)](_0x22b84f[_0x478cc0[_0x4b01fb][_0x45dc94(0x142)]],'%s',_0x5947d0):_0x5947d0,_0x478cc0[_0x4b01fb][_0x45dc94(0x150)]&&_0x1895a4[_0x45dc94(0x141)](_0x5947d0),_0x478cc0[_0x4b01fb][_0x45dc94(0xe2)]&&_0x1895a4['order'](_0x5947d0,_0x478cc0[_0x4b01fb][_0x45dc94(0xe2)]===_0x45dc94(0xf8)?![]:!![]),_0x1895a4[_0x45dc94(0x154)](_0x5947d0,_0x478cc0[_0x4b01fb]['alias']||_0x5947d0);}if(_0x4beb23[_0x45dc94(0x123)]){_0x4beb23[_0x45dc94(0x123)]=JSON[_0x45dc94(0xe1)](_0x4beb23[_0x45dc94(0x123)]);for(let _0x2968a4=0x0;_0x2968a4<_0x4beb23[_0x45dc94(0x123)][_0x45dc94(0x11e)];_0x2968a4+=0x1){_0x4beb23['joins'][_0x2968a4]['type']&&_['includes'](_0x2b568c,_0x4beb23['joins'][_0x2968a4][_0x45dc94(0x119)])&&_0x4beb23[_0x45dc94(0x123)][_0x2968a4][_0x45dc94(0xe0)]&&_0x4beb23[_0x45dc94(0x123)][_0x2968a4]['foreignTable']&&_0x4beb23[_0x45dc94(0x123)][_0x2968a4][_0x45dc94(0x122)]&&_0x1895a4[_0x4beb23[_0x45dc94(0x123)][_0x2968a4][_0x45dc94(0x119)]](_0x4beb23[_0x45dc94(0x123)][_0x2968a4]['foreignTable'],null,util['format'](_0x45dc94(0x14a),_0x4beb23[_0x45dc94(0x13c)],_0x4beb23['joins'][_0x2968a4][_0x45dc94(0xe0)],_0x4beb23['joins'][_0x2968a4][_0x45dc94(0xf3)],_0x4beb23[_0x45dc94(0x123)][_0x2968a4]['foreignKey']));}}return _0x4beb23[_0x45dc94(0xe7)]&&(_0x4beb23[_0x45dc94(0xe7)]=JSON['parse'](_0x4beb23[_0x45dc94(0xe7)]),_0x1895a4[_0x45dc94(0xd2)](_0x98a7cb(_0x4beb23[_0x45dc94(0xe7)]['group']))),_0x1895a4[_0x45dc94(0xde)](_0x4d9826),_0x1895a4[_0x45dc94(0xd9)](0x0),logger[_0x45dc94(0xdd)](_0x45dc94(0x152),_0x1895a4[_0x45dc94(0x11a)]()),db['sequelize'][_0x45dc94(0x133)](_0x1895a4['toString'](),{'type':QueryTypes[_0x45dc94(0x13d)]});}})[_0x556b78(0x10f)](respondWithResult(_0x4ef869,null))['catch'](handleError(_0x4ef869,null));};function runReport(_0x5deaf3,_0x3cf512,_0x31b688){const _0x18a160=a6_0x3930aa,_0x29c042=_0x3cf512[_0x18a160(0x121)],_0x1facc0=0xa,_0x46924b=[_0x18a160(0xca),'left_join','right_join',_0x18a160(0x10c)],_0x1ac723={'SUM':_0x18a160(0x12e),'COUNT':_0x18a160(0x11b),'COUNT\x20DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':'MAX(%s)','MIN':'MIN(%s)','AVG':_0x18a160(0x110),'GROUP_CONCAT':_0x18a160(0x129),'GROUP_CONCAT\x20ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT\x20DESC':_0x18a160(0x103)},_0x3431b1={'SEC_TO_TIME':_0x18a160(0xe9),'DATE':_0x18a160(0xf0),'HOUR':'HOUR(%s)','ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x18a160(0xfa)},_0x3d5472=function(_0x3d97f5){const _0x3c8d3b=_0x18a160;return!_[_0x3c8d3b(0xdb)]([_0x3c8d3b(0x102),_0x3c8d3b(0xf2),_0x3c8d3b(0x136),_0x3c8d3b(0x147)],_0x3d97f5);},_0x5dc5c4=function(_0x193e81){const _0x1bf16e=_0x18a160;if(!_0x193e81||!_0x193e81['rules'][_0x1bf16e(0x11e)])return'';let _0x4e7ce1='(';for(let _0x1805e0=0x0;_0x1805e0<_0x193e81[_0x1bf16e(0xd5)]['length'];_0x1805e0+=0x1){_0x1805e0>0x0&&(_0x4e7ce1+='\x20'+_0x193e81[_0x1bf16e(0x144)]+'\x20'),_0x4e7ce1+=_0x193e81[_0x1bf16e(0xd5)][_0x1805e0][_0x1bf16e(0x141)]?_0x5dc5c4(_0x193e81['rules'][_0x1805e0][_0x1bf16e(0x141)]):_0x193e81['rules'][_0x1805e0][_0x1bf16e(0x154)]+'\x20'+_0x193e81[_0x1bf16e(0xd5)][_0x1805e0]['condition']+(_0x3d5472(_0x193e81[_0x1bf16e(0xd5)][_0x1805e0][_0x1bf16e(0x11c)])?'\x20'+_0x193e81[_0x1bf16e(0xd5)][_0x1805e0]['value']:'');}return _0x4e7ce1+')';};let _0x5318b1={'where':{'id':_0x5deaf3['id']}},_0x6e23c8,_0x4c5dbb,_0x4f9b2f,_0x418d2c,_0x4e533a;return _0x5318b1=_[_0x18a160(0x143)]({},_0x5318b1,_0x31b688),db[_0x18a160(0xfb)]['findOne'](_0x5318b1)['then'](function(_0x438edf){const _0x82daa2=_0x18a160;if(_0x438edf)return _0x6e23c8=_0x438edf,_0x438edf[_0x82daa2(0xce)]();return null;})[_0x18a160(0x10f)](function(_0x390d80){const _0x5aa7d4=_0x18a160;if(_0x390d80){if(!_0x390d80[_0x5aa7d4(0x11e)])throw new ValidationErrorItem(_0x5aa7d4(0x131),0x193);return _0x4c5dbb=_0x390d80,db['AnalyticMetric'][_0x5aa7d4(0xf6)]({'raw':!![]});}return null;})[_0x18a160(0x10f)](function(_0x4981e4){const _0x4559b9=_0x18a160;if(_0x4981e4){_0x4f9b2f=_['keyBy'](_0x4981e4,'id');let _0x7f66fa;const _0x322b9e=squel[_0x4559b9(0xf5)]();_0x322b9e[_0x4559b9(0x14e)](_0x6e23c8[_0x4559b9(0x13c)]);for(let _0x23d7ea=0x0;_0x23d7ea<_0x4c5dbb[_0x4559b9(0x11e)];_0x23d7ea+=0x1){_0x7f66fa=_0x4c5dbb[_0x23d7ea][_0x4559b9(0x12f)]?_0x4f9b2f[_0x4c5dbb[_0x23d7ea][_0x4559b9(0x12f)]][_0x4559b9(0x108)]:_0x4c5dbb[_0x23d7ea][_0x4559b9(0x154)],_0x7f66fa=_0x4c5dbb[_0x23d7ea]['function']?_[_0x4559b9(0x118)](_0x1ac723[_0x4c5dbb[_0x23d7ea]['function']],'%s',_0x7f66fa):_0x7f66fa,_0x7f66fa=_0x4c5dbb[_0x23d7ea][_0x4559b9(0x142)]?_[_0x4559b9(0x118)](_0x3431b1[_0x4c5dbb[_0x23d7ea]['format']],'%s',_0x7f66fa):_0x7f66fa,_0x4c5dbb[_0x23d7ea]['groupBy']&&_0x322b9e[_0x4559b9(0x141)](_0x7f66fa),_0x4c5dbb[_0x23d7ea][_0x4559b9(0xe2)]&&_0x322b9e[_0x4559b9(0xcd)](_0x7f66fa,_0x4c5dbb[_0x23d7ea][_0x4559b9(0xe2)]===_0x4559b9(0xf8)?![]:!![]),_0x322b9e[_0x4559b9(0x154)](_0x7f66fa,_0x4c5dbb[_0x23d7ea][_0x4559b9(0x11f)]||_0x7f66fa);}if(_0x6e23c8[_0x4559b9(0x123)]){_0x6e23c8[_0x4559b9(0x123)]=JSON[_0x4559b9(0xe1)](_0x6e23c8[_0x4559b9(0x123)]);for(let _0x41d7b0=0x0;_0x41d7b0<_0x6e23c8[_0x4559b9(0x123)]['length'];_0x41d7b0+=0x1){_0x6e23c8['joins'][_0x41d7b0]['type']&&_[_0x4559b9(0xdb)](_0x46924b,_0x6e23c8[_0x4559b9(0x123)][_0x41d7b0][_0x4559b9(0x119)])&&_0x6e23c8[_0x4559b9(0x123)][_0x41d7b0][_0x4559b9(0xe0)]&&_0x6e23c8['joins'][_0x41d7b0][_0x4559b9(0xf3)]&&_0x6e23c8[_0x4559b9(0x123)][_0x41d7b0][_0x4559b9(0x122)]&&_0x322b9e[_0x6e23c8[_0x4559b9(0x123)][_0x41d7b0][_0x4559b9(0x119)]](_0x6e23c8[_0x4559b9(0x123)][_0x41d7b0][_0x4559b9(0xf3)],null,util[_0x4559b9(0x142)]('%s.%s\x20=\x20%s.%s',_0x6e23c8['table'],_0x6e23c8[_0x4559b9(0x123)][_0x41d7b0]['parentKey'],_0x6e23c8[_0x4559b9(0x123)][_0x41d7b0]['foreignTable'],_0x6e23c8[_0x4559b9(0x123)][_0x41d7b0][_0x4559b9(0x122)]));}}return _0x6e23c8['conditions']&&(_0x6e23c8[_0x4559b9(0xe7)]=JSON[_0x4559b9(0xe1)](_0x6e23c8[_0x4559b9(0xe7)]),_0x322b9e[_0x4559b9(0xd2)](_0x5dc5c4(_0x6e23c8['conditions'][_0x4559b9(0x141)]))),_0x4e533a=_0x322b9e[_0x4559b9(0xcf)](),_0x322b9e[_0x4559b9(0xde)](_0x1facc0),_0x322b9e[_0x4559b9(0xd9)](0x0),logger[_0x4559b9(0xdd)](_0x4559b9(0x152),_0x322b9e['toString']()),db[_0x4559b9(0x114)]['query'](_0x322b9e[_0x4559b9(0x11a)](),{'type':QueryTypes[_0x4559b9(0x13d)]});}})['then'](function(_0x47e156){const _0x2110dc=_0x18a160;if(!_0x47e156[_0x2110dc(0x11e)])throw new ValidationErrorItem('No\x20available\x20data',0xcc);if(_0x3cf512[_0x2110dc(0x115)]===_0x2110dc(0xf7))return null;const _0x47b51e=_[_0x2110dc(0x143)](_0x3cf512,{'name':_0x3cf512[_0x2110dc(0x126)]||_0x3cf512[_0x2110dc(0x121)]||_0x6e23c8[_0x2110dc(0x121)],'basename':_0x29c042,'savename':util['format']('%s-%s.%s',_0x3cf512[_0x2110dc(0x121)]||_0x6e23c8['name'],require(_0x2110dc(0xd6))['generate'](0x4),_0x3cf512['output']||'csv'),'reportId':_0x6e23c8['id'],'reportType':_0x2110dc(0x12a)});return db[_0x2110dc(0xf1)][_0x2110dc(0x125)](_0x47b51e,{'raw':!![]});})[_0x18a160(0x10f)](function(_0x269c2a){const _0x342ec5=_0x18a160;_0x6e23c8[_0x342ec5(0x13c)]===_0x342ec5(0x117)?_0x4e533a[_0x342ec5(0xd2)](_0x6e23c8[_0x342ec5(0x13c)]+_0x342ec5(0xd1),_0x3cf512[_0x342ec5(0x156)],_0x3cf512['endDate']):_0x4e533a[_0x342ec5(0xd2)](_0x6e23c8['table']+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x3cf512[_0x342ec5(0x156)],_0x3cf512[_0x342ec5(0x149)]);if(_0x269c2a)return logger[_0x342ec5(0xe5)](_0x342ec5(0x109),_0x4e533a[_0x342ec5(0x11a)]()),require(_0x342ec5(0xe8))[_0x342ec5(0x10e)](path[_0x342ec5(0xca)](__dirname,_0x342ec5(0x134),_0x269c2a['output']),[_0x269c2a['id'],_0x4e533a[_0x342ec5(0x11a)](),path[_0x342ec5(0xca)](__dirname,'../../files/reports',_0x269c2a[_0x342ec5(0x145)]),_0x29c042]),_0x269c2a;else{const _0xb4873f=squel[_0x342ec5(0xf5)]();return _0xb4873f[_0x342ec5(0x14e)]('('+_0x4e533a[_0x342ec5(0x11a)]()+')',_0x342ec5(0xff)),_0xb4873f['field'](_0x342ec5(0xfc),_0x342ec5(0x106)),_0x4e533a[_0x342ec5(0xde)](_0x3cf512[_0x342ec5(0xde)]||_0x1facc0),_0x4e533a[_0x342ec5(0xd9)](_0x3cf512[_0x342ec5(0xd9)]||0x0),dbH[_0x342ec5(0x114)][_0x342ec5(0x133)](_0xb4873f[_0x342ec5(0x11a)](),{'type':dbH[_0x342ec5(0x114)][_0x342ec5(0xec)][_0x342ec5(0x13d)]})['then'](function(_0x580d6b){const _0x16eece=_0x342ec5;return!_0x580d6b[_0x16eece(0x11e)]?_0x418d2c=0x0:_0x418d2c=_0x580d6b[0x0][_0x16eece(0x106)]||0x0,dbH['sequelize'][_0x16eece(0x133)](_0x4e533a[_0x16eece(0x11a)](),{'type':dbH[_0x16eece(0x114)][_0x16eece(0xec)][_0x16eece(0x13d)]});})[_0x342ec5(0x10f)](function(_0x46ba4f){return{'rows':_0x46ba4f||[],'count':_0x418d2c};});}});}exports[a6_0x3930aa(0x135)]=function(_0x4c701f,_0x3ff846){const _0xd9e154=a6_0x3930aa;return runReport(_0x4c701f[_0xd9e154(0x148)],_0x4c701f[_0xd9e154(0x133)],_0x4c701f[_0xd9e154(0x14f)])[_0xd9e154(0x10f)](respondWithResult(_0x3ff846,null))[_0xd9e154(0xf9)](handleError(_0x3ff846,null));},exports[a6_0x3930aa(0x13f)]=runReport,exports[a6_0x3930aa(0x133)]=function(_0x355797,_0x131d64){const _0x1df751=a6_0x3930aa,_0x141c37=0xa,_0x40cd42=[_0x1df751(0xca),'left_join',_0x1df751(0x113),'cross_join'],_0xb64185={'SUM':_0x1df751(0x12e),'COUNT':_0x1df751(0x11b),'COUNT\x20DISTINCT':_0x1df751(0x158),'MAX':_0x1df751(0x112),'MIN':_0x1df751(0x13e),'AVG':_0x1df751(0x110),'GROUP_CONCAT':_0x1df751(0x129),'GROUP_CONCAT\x20ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT\x20DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'},_0x390a42={'SEC_TO_TIME':_0x1df751(0xe9),'DATE':_0x1df751(0xf0),'HOUR':_0x1df751(0xe3),'ROUND':_0x1df751(0x124),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'},_0x30a90f=function(_0x10a7a4){const _0x40ee3c=_0x1df751;return!_[_0x40ee3c(0xdb)]([_0x40ee3c(0x102),_0x40ee3c(0xf2),_0x40ee3c(0x136),_0x40ee3c(0x147)],_0x10a7a4);},_0x38694e=function(_0x29ccec){const _0x375e42=_0x1df751;if(!_0x29ccec||!_0x29ccec[_0x375e42(0xd5)][_0x375e42(0x11e)])return'';let _0x2e74f2='(';for(let _0x4d31c9=0x0;_0x4d31c9<_0x29ccec[_0x375e42(0xd5)][_0x375e42(0x11e)];_0x4d31c9+=0x1){_0x4d31c9>0x0&&(_0x2e74f2+='\x20'+_0x29ccec[_0x375e42(0x144)]+'\x20'),_0x2e74f2+=_0x29ccec['rules'][_0x4d31c9][_0x375e42(0x141)]?_0x38694e(_0x29ccec[_0x375e42(0xd5)][_0x4d31c9][_0x375e42(0x141)]):_0x29ccec[_0x375e42(0xd5)][_0x4d31c9]['field']+'\x20'+_0x29ccec[_0x375e42(0xd5)][_0x4d31c9][_0x375e42(0x11c)]+(_0x30a90f(_0x29ccec[_0x375e42(0xd5)][_0x4d31c9][_0x375e42(0x11c)])?'\x20'+_0x29ccec[_0x375e42(0xd5)][_0x4d31c9][_0x375e42(0xcb)]:'');}return _0x2e74f2+')';};let _0x373ba0={'where':{'id':_0x355797['params']['id']}},_0x2e1660,_0x3b0e5d,_0x39a42c,_0x13c674;return _0x373ba0=_[_0x1df751(0x143)]({},_0x373ba0,_0x355797[_0x1df751(0x14f)]),db[_0x1df751(0xfb)][_0x1df751(0xfd)](_0x373ba0)[_0x1df751(0x10f)](function(_0x3fd60b){const _0x59ed36=_0x1df751;if(_0x3fd60b)return _0x2e1660=_0x3fd60b,_0x3fd60b[_0x59ed36(0xce)]();return null;})['then'](function(_0x45afca){const _0x4652c1=_0x1df751;if(_0x45afca){if(!_0x45afca[_0x4652c1(0x11e)])throw new ValidationErrorItem(_0x4652c1(0x131),0x193);return _0x3b0e5d=_0x45afca,db[_0x4652c1(0x120)][_0x4652c1(0xf6)]({'raw':!![]});}return null;})[_0x1df751(0x10f)](function(_0x4a04a7){const _0x560037=_0x1df751;if(_0x4a04a7){_0x39a42c=_[_0x560037(0x138)](_0x4a04a7,'id');let _0x73f599;const _0x5a7980=squel['select']();_0x5a7980['from'](_0x2e1660[_0x560037(0x13c)]);for(let _0x3a03be=0x0;_0x3a03be<_0x3b0e5d[_0x560037(0x11e)];_0x3a03be+=0x1){_0x73f599=_0x3b0e5d[_0x3a03be][_0x560037(0x12f)]?_0x39a42c[_0x3b0e5d[_0x3a03be][_0x560037(0x12f)]]['metric']:_0x3b0e5d[_0x3a03be][_0x560037(0x154)],_0x73f599=_0x3b0e5d[_0x3a03be][_0x560037(0x10a)]?_[_0x560037(0x118)](_0xb64185[_0x3b0e5d[_0x3a03be][_0x560037(0x10a)]],'%s',_0x73f599):_0x73f599,_0x73f599=_0x3b0e5d[_0x3a03be]['format']?_[_0x560037(0x118)](_0x390a42[_0x3b0e5d[_0x3a03be][_0x560037(0x142)]],'%s',_0x73f599):_0x73f599,_0x3b0e5d[_0x3a03be][_0x560037(0x150)]&&_0x5a7980[_0x560037(0x141)](_0x73f599),_0x3b0e5d[_0x3a03be][_0x560037(0xe2)]&&_0x5a7980[_0x560037(0xcd)](_0x73f599,_0x3b0e5d[_0x3a03be][_0x560037(0xe2)]==='DESC'?![]:!![]),_0x5a7980[_0x560037(0x154)](_0x73f599,_0x3b0e5d[_0x3a03be]['alias']||_0x73f599);}if(_0x2e1660[_0x560037(0x123)]){_0x2e1660[_0x560037(0x123)]=JSON[_0x560037(0xe1)](_0x2e1660[_0x560037(0x123)]);for(let _0x2ad9d2=0x0;_0x2ad9d2<_0x2e1660[_0x560037(0x123)]['length'];_0x2ad9d2+=0x1){_0x2e1660[_0x560037(0x123)][_0x2ad9d2][_0x560037(0x119)]&&_['includes'](_0x40cd42,_0x2e1660[_0x560037(0x123)][_0x2ad9d2]['type'])&&_0x2e1660['joins'][_0x2ad9d2]['parentKey']&&_0x2e1660[_0x560037(0x123)][_0x2ad9d2]['foreignTable']&&_0x2e1660['joins'][_0x2ad9d2]['foreignKey']&&_0x5a7980[_0x2e1660[_0x560037(0x123)][_0x2ad9d2][_0x560037(0x119)]](_0x2e1660[_0x560037(0x123)][_0x2ad9d2][_0x560037(0xf3)],null,util[_0x560037(0x142)](_0x560037(0x14a),_0x2e1660[_0x560037(0x13c)],_0x2e1660[_0x560037(0x123)][_0x2ad9d2]['parentKey'],_0x2e1660[_0x560037(0x123)][_0x2ad9d2][_0x560037(0xf3)],_0x2e1660[_0x560037(0x123)][_0x2ad9d2]['foreignKey']));}}return _0x2e1660[_0x560037(0xe7)]&&(_0x2e1660[_0x560037(0xe7)]=JSON[_0x560037(0xe1)](_0x2e1660[_0x560037(0xe7)]),_0x5a7980['where'](_0x38694e(_0x2e1660[_0x560037(0xe7)][_0x560037(0x141)]))),_0x13c674=_0x5a7980['clone'](),_0x5a7980[_0x560037(0xde)](_0x141c37),_0x5a7980[_0x560037(0xd9)](0x0),logger['debug'](_0x560037(0x152),_0x5a7980[_0x560037(0x11a)]()),db['sequelize']['query'](_0x5a7980['toString'](),{'type':QueryTypes[_0x560037(0x13d)]});}})[_0x1df751(0x10f)](function(){return{'sql':_0x13c674['toString']()};})[_0x1df751(0x10f)](respondWithResult(_0x131d64,null))[_0x1df751(0xf9)](handleError(_0x131d64,null));};
\ No newline at end of file