Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 13893ab..29aefdd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb386=['attributes','intersection','length','hasOwnProperty','nolimit','order','sort','where','filters','merge','VIRTUAL','filter','includeAll','include','findAll','rows','catch','show','fields','options','find','create','body','user','role','Reports','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','preview','join','right_join','cross_join','SUM(%s)','MAX(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','value','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','MetricId','metric','function','replace','format','groupBy','orderBy','DESC','alias','joins','parse','parentKey','foreignTable','%s.%s\x20=\x20%s.%s','conditions','debug','toString','sequelize','QueryTypes','SELECT','left_join','COUNT(%s)','COUNT(DISTINCT\x20%s)','MIN(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','ROUND(%s)','IS\x20NULL','table','foreignKey','clone','output','%s-%s.%s','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','runReport','Limited\x20Query:','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','dbH','sendStatus','status','json','count','offset','limit','set','Content-Range','reject','update','then','destroy','get','DefaultReports','UserProfileResource','end','stack','name','send','map','AnalyticDefaultReport','rawAttributes','type','key','model','query','keys'];(function(_0x2130cc,_0x1abfd3){var _0x42a11a=function(_0x284933){while(--_0x284933){_0x2130cc['push'](_0x2130cc['shift']());}};_0x42a11a(++_0x1abfd3);}(_0xb386,0x111));var _0x6b38=function(_0x4b73a2,_0x40b5fe){_0x4b73a2=_0x4b73a2-0x0;var _0x383c66=_0xb386[_0x4b73a2];return _0x383c66;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x6b38('0x0'));var rimraf=require(_0x6b38('0x1'));var zipdir=require(_0x6b38('0x2'));var jsonpatch=require(_0x6b38('0x3'));var rp=require(_0x6b38('0x4'));var moment=require(_0x6b38('0x5'));var BPromise=require(_0x6b38('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0x6b38('0x7'));var sox=require(_0x6b38('0x8'));var csv=require(_0x6b38('0x9'));var ejs=require(_0x6b38('0xa'));var fs=require('fs');var _=require(_0x6b38('0xb'));var squel=require(_0x6b38('0xc'));var crypto=require('crypto');var jsforce=require(_0x6b38('0xd'));var deskjs=require(_0x6b38('0xe'));var toCsv=require(_0x6b38('0x9'));var querystring=require('querystring');var Papa=require(_0x6b38('0xf'));var Redis=require(_0x6b38('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x6b38('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6b38('0x12'));var logger=require(_0x6b38('0x13'))('api');var utils=require(_0x6b38('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x6b38('0x15'));var db=require('../../mysqldb')['db'];var dbH=require(_0x6b38('0x16'))[_0x6b38('0x17')];function respondWithStatusCode(_0x35bc2d,_0x521aba){_0x521aba=_0x521aba||0xcc;return function(_0x59161c){if(_0x59161c){return _0x35bc2d[_0x6b38('0x18')](_0x521aba);}return _0x35bc2d[_0x6b38('0x19')](_0x521aba)['end']();};}function respondWithResult(_0xa45d01,_0x15849d){_0x15849d=_0x15849d||0xc8;return function(_0x157b0e){if(_0x157b0e){return _0xa45d01['status'](_0x15849d)[_0x6b38('0x1a')](_0x157b0e);}};}function respondWithFilteredResult(_0x4948fe,_0x5c3a11){return function(_0x576676){if(_0x576676){var _0x59e092=_0x576676[_0x6b38('0x1b')],_0x472c57=_0x5c3a11[_0x6b38('0x1c')],_0x3db035=_0x5c3a11['offset']+_0x5c3a11[_0x6b38('0x1d')],_0x1e28af;if(_0x3db035>=_0x59e092){_0x3db035=_0x59e092;_0x1e28af=0xc8;}else{_0x1e28af=0xce;}_0x4948fe['status'](_0x1e28af);return _0x4948fe[_0x6b38('0x1e')](_0x6b38('0x1f'),_0x472c57+'-'+_0x3db035+'/'+_0x59e092)[_0x6b38('0x1a')](_0x576676);}return null;};}function patchUpdates(_0xd2009e){return function(_0x4c25b6){try{jsonpatch['apply'](_0x4c25b6,_0xd2009e,!![]);}catch(_0x275dec){return BPromise[_0x6b38('0x20')](_0x275dec);}return _0x4c25b6['save']();};}function saveUpdates(_0x529fc0,_0x15a287){return function(_0x1a8f58){if(_0x1a8f58){return _0x1a8f58[_0x6b38('0x21')](_0x529fc0)[_0x6b38('0x22')](function(_0x54eae7){return _0x54eae7;});}return null;};}function removeEntity(_0x124747,_0x38d29f){return function(_0x53a481){if(_0x53a481){return _0x53a481[_0x6b38('0x23')]()[_0x6b38('0x22')](function(){var _0x5d2b08=_0x53a481[_0x6b38('0x24')]({'plain':!![]});var _0x3a7e5d=_0x6b38('0x25');return db[_0x6b38('0x26')][_0x6b38('0x23')]({'where':{'type':_0x3a7e5d,'resourceId':_0x5d2b08['id']}})[_0x6b38('0x22')](function(){return _0x53a481;});})[_0x6b38('0x22')](function(){_0x124747[_0x6b38('0x19')](0xcc)[_0x6b38('0x27')]();});}};}function handleEntityNotFound(_0x46a82f,_0x527232){return function(_0x3dd353){if(!_0x3dd353){_0x46a82f['sendStatus'](0x194);}return _0x3dd353;};}function handleError(_0x2ba835,_0x3abc3b){_0x3abc3b=_0x3abc3b||0x1f4;return function(_0x227c46){logger['error'](_0x227c46[_0x6b38('0x28')]);if(_0x227c46[_0x6b38('0x29')]){delete _0x227c46[_0x6b38('0x29')];}_0x2ba835[_0x6b38('0x19')](_0x3abc3b)[_0x6b38('0x2a')](_0x227c46);};}exports['index']=function(_0x20fac0,_0x2e9737){var _0x5d9d37={},_0x3601da={},_0x373584={'count':0x0,'rows':[]};var _0x3c9996=_[_0x6b38('0x2b')](db[_0x6b38('0x2c')][_0x6b38('0x2d')],function(_0x4e0674){return{'name':_0x4e0674['fieldName'],'type':_0x4e0674[_0x6b38('0x2e')][_0x6b38('0x2f')]};});_0x3601da[_0x6b38('0x30')]=_['map'](_0x3c9996,_0x6b38('0x29'));_0x3601da[_0x6b38('0x31')]=_[_0x6b38('0x32')](_0x20fac0['query']);_0x3601da['filters']=_['intersection'](_0x3601da[_0x6b38('0x30')],_0x3601da[_0x6b38('0x31')]);_0x5d9d37[_0x6b38('0x33')]=_[_0x6b38('0x34')](_0x3601da[_0x6b38('0x30')],qs['fields'](_0x20fac0['query']['fields']));_0x5d9d37[_0x6b38('0x33')]=_0x5d9d37['attributes'][_0x6b38('0x35')]?_0x5d9d37[_0x6b38('0x33')]:_0x3601da[_0x6b38('0x30')];if(!_0x20fac0[_0x6b38('0x31')][_0x6b38('0x36')](_0x6b38('0x37'))){_0x5d9d37[_0x6b38('0x1d')]=qs[_0x6b38('0x1d')](_0x20fac0[_0x6b38('0x31')][_0x6b38('0x1d')]);_0x5d9d37[_0x6b38('0x1c')]=qs['offset'](_0x20fac0['query'][_0x6b38('0x1c')]);}_0x5d9d37[_0x6b38('0x38')]=qs['sort'](_0x20fac0['query'][_0x6b38('0x39')]);_0x5d9d37[_0x6b38('0x3a')]=qs[_0x6b38('0x3b')](_['pick'](_0x20fac0[_0x6b38('0x31')],_0x3601da[_0x6b38('0x3b')]),_0x3c9996);if(_0x20fac0[_0x6b38('0x31')]['filter']){_0x5d9d37[_0x6b38('0x3a')]=_[_0x6b38('0x3c')](_0x5d9d37['where'],{'$or':_['map'](_0x3c9996,function(_0x3acc5c){if(_0x3acc5c['type']!==_0x6b38('0x3d')){var _0x35bb8d={};_0x35bb8d[_0x3acc5c[_0x6b38('0x29')]]={'$like':'%'+_0x20fac0[_0x6b38('0x31')][_0x6b38('0x3e')]+'%'};return _0x35bb8d;}})});}_0x5d9d37=_[_0x6b38('0x3c')]({},_0x5d9d37,_0x20fac0['options']);var _0x3906b1={'where':_0x5d9d37[_0x6b38('0x3a')]};return db['AnalyticDefaultReport'][_0x6b38('0x1b')](_0x3906b1)[_0x6b38('0x22')](function(_0x1ffd7a){_0x373584[_0x6b38('0x1b')]=_0x1ffd7a;if(_0x20fac0[_0x6b38('0x31')][_0x6b38('0x3f')]){_0x5d9d37[_0x6b38('0x40')]=[{'all':!![]}];}return db[_0x6b38('0x2c')][_0x6b38('0x41')](_0x5d9d37);})[_0x6b38('0x22')](function(_0x58ec5a){_0x373584[_0x6b38('0x42')]=_0x58ec5a;return _0x373584;})[_0x6b38('0x22')](respondWithFilteredResult(_0x2e9737,_0x5d9d37))[_0x6b38('0x43')](handleError(_0x2e9737,null));};exports[_0x6b38('0x44')]=function(_0x262607,_0x40f099){var _0x4cc978={'raw':!![],'where':{'id':_0x262607['params']['id']}},_0x481881={};_0x481881[_0x6b38('0x30')]=_['keys'](db[_0x6b38('0x2c')][_0x6b38('0x2d')]);_0x481881['query']=_['keys'](_0x262607[_0x6b38('0x31')]);_0x481881[_0x6b38('0x3b')]=_['intersection'](_0x481881[_0x6b38('0x30')],_0x481881[_0x6b38('0x31')]);_0x4cc978[_0x6b38('0x33')]=_[_0x6b38('0x34')](_0x481881[_0x6b38('0x30')],qs[_0x6b38('0x45')](_0x262607[_0x6b38('0x31')][_0x6b38('0x45')]));_0x4cc978[_0x6b38('0x33')]=_0x4cc978[_0x6b38('0x33')][_0x6b38('0x35')]?_0x4cc978['attributes']:_0x481881['model'];if(_0x262607[_0x6b38('0x31')]['includeAll']){_0x4cc978[_0x6b38('0x40')]=[{'all':!![]}];}_0x4cc978=_[_0x6b38('0x3c')]({},_0x4cc978,_0x262607[_0x6b38('0x46')]);return db[_0x6b38('0x2c')][_0x6b38('0x47')](_0x4cc978)['then'](handleEntityNotFound(_0x40f099,null))[_0x6b38('0x22')](respondWithResult(_0x40f099,null))['catch'](handleError(_0x40f099,null));};exports[_0x6b38('0x48')]=function(_0x4fe14b,_0x586737){return db[_0x6b38('0x2c')]['create'](_0x4fe14b[_0x6b38('0x49')],{})[_0x6b38('0x22')](function(_0x1e862f){var _0x578b96=_0x4fe14b[_0x6b38('0x4a')][_0x6b38('0x24')]({'plain':!![]});if(!_0x578b96)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x578b96[_0x6b38('0x4b')]===_0x6b38('0x4a')){var _0x3e1d05=_0x1e862f[_0x6b38('0x24')]({'plain':!![]});var _0x225f56=_0x6b38('0x4c');return db['UserProfileSection']['find']({'where':{'name':_0x225f56,'userProfileId':_0x578b96['userProfileId']},'raw':!![]})[_0x6b38('0x22')](function(_0x2e54b4){if(_0x2e54b4&&_0x2e54b4[_0x6b38('0x4d')]===0x0){return db[_0x6b38('0x26')]['create']({'name':_0x3e1d05[_0x6b38('0x29')],'resourceId':_0x3e1d05['id'],'type':_0x6b38('0x25'),'sectionId':_0x2e54b4['id']},{})[_0x6b38('0x22')](function(){return _0x1e862f;});}else{return _0x1e862f;}})[_0x6b38('0x43')](function(_0x1a62fc){logger['error'](_0x6b38('0x4e'),_0x1a62fc);throw _0x1a62fc;});}return _0x1e862f;})['then'](respondWithResult(_0x586737,0xc9))[_0x6b38('0x43')](handleError(_0x586737,null));};exports[_0x6b38('0x21')]=function(_0x1b8580,_0x15afcd){if(_0x1b8580[_0x6b38('0x49')]['id']){delete _0x1b8580['body']['id'];}return db[_0x6b38('0x2c')]['find']({'where':{'id':_0x1b8580[_0x6b38('0x4f')]['id']}})[_0x6b38('0x22')](handleEntityNotFound(_0x15afcd,null))['then'](saveUpdates(_0x1b8580[_0x6b38('0x49')],null))[_0x6b38('0x22')](respondWithResult(_0x15afcd,null))[_0x6b38('0x43')](handleError(_0x15afcd,null));};exports['destroy']=function(_0x465b3a,_0x369bcb){return db[_0x6b38('0x2c')][_0x6b38('0x47')]({'where':{'id':_0x465b3a['params']['id']}})[_0x6b38('0x22')](handleEntityNotFound(_0x369bcb,null))[_0x6b38('0x22')](removeEntity(_0x369bcb,null))[_0x6b38('0x43')](handleError(_0x369bcb,null));};exports[_0x6b38('0x50')]=function(_0x1af520,_0x3e9670){var _0x485d93=0xa;var _0x572453=[_0x6b38('0x51'),'left_join',_0x6b38('0x52'),_0x6b38('0x53')];var _0x5a69a5={'SUM':_0x6b38('0x54'),'COUNT':'COUNT(%s)','COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x6b38('0x55'),'MIN':'MIN(%s)','AVG':_0x6b38('0x56'),'GROUP_CONCAT':_0x6b38('0x57'),'GROUP_CONCAT ASC':_0x6b38('0x58'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x2b9669={'SEC_TO_TIME':_0x6b38('0x59'),'DATE':_0x6b38('0x5a'),'HOUR':_0x6b38('0x5b'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x6b38('0x5c')};var _0x571e29=function(_0x40658b){return!_[_0x6b38('0x5d')](['IS\x20NULL',_0x6b38('0x5e'),_0x6b38('0x5f'),_0x6b38('0x60')],_0x40658b);};var _0x2d7ca8=function(_0x538df6){if(!_0x538df6||!_0x538df6[_0x6b38('0x61')][_0x6b38('0x35')]){return'';}for(var _0x4c682e='(',_0x3c1f24=0x0;_0x3c1f24<_0x538df6[_0x6b38('0x61')][_0x6b38('0x35')];_0x3c1f24+=0x1){_0x3c1f24>0x0&&(_0x4c682e+='\x20'+_0x538df6[_0x6b38('0x62')]+'\x20');_0x4c682e+=_0x538df6['rules'][_0x3c1f24][_0x6b38('0x63')]?_0x2d7ca8(_0x538df6[_0x6b38('0x61')][_0x3c1f24][_0x6b38('0x63')]):_0x538df6[_0x6b38('0x61')][_0x3c1f24][_0x6b38('0x64')]+'\x20'+_0x538df6[_0x6b38('0x61')][_0x3c1f24][_0x6b38('0x65')]+(_0x571e29(_0x538df6[_0x6b38('0x61')][_0x3c1f24]['condition'])?'\x20'+_0x538df6['rules'][_0x3c1f24][_0x6b38('0x66')]:'');}return _0x4c682e+')';};var _0x4e77bf={'where':{'id':_0x1af520[_0x6b38('0x4f')]['id']}},_0x1a50a6,_0x5e6624,_0xf7832f,_0x2035cb,_0x397356;_0x4e77bf=_[_0x6b38('0x3c')]({},_0x4e77bf,_0x1af520[_0x6b38('0x46')]);return db[_0x6b38('0x2c')][_0x6b38('0x47')](_0x4e77bf)[_0x6b38('0x22')](function(_0x19e557){if(_0x19e557){_0x1a50a6=_0x19e557;return _0x19e557[_0x6b38('0x67')]();}return null;})[_0x6b38('0x22')](function(_0x250175){if(_0x250175){if(!_0x250175['length']){throw new db[(_0x6b38('0x68'))][(_0x6b38('0x69'))](_0x6b38('0x6a'),0x193);}_0x5e6624=_0x250175;return db[_0x6b38('0x6b')][_0x6b38('0x41')]({'raw':!![]});}return null;})[_0x6b38('0x22')](function(_0x4ed868){if(_0x4ed868){_0xf7832f=_[_0x6b38('0x6c')](_0x4ed868,'id');var _0x5ee3ee;var _0x5ceca6=squel[_0x6b38('0x6d')]();_0x5ceca6[_0x6b38('0x6e')](_0x1a50a6['table']);for(var _0x319c08=0x0;_0x319c08<_0x5e6624[_0x6b38('0x35')];_0x319c08+=0x1){_0x5ee3ee=_0x5e6624[_0x319c08][_0x6b38('0x6f')]?_0xf7832f[_0x5e6624[_0x319c08]['MetricId']][_0x6b38('0x70')]:_0x5e6624[_0x319c08][_0x6b38('0x64')];_0x5ee3ee=_0x5e6624[_0x319c08][_0x6b38('0x71')]?_[_0x6b38('0x72')](_0x5a69a5[_0x5e6624[_0x319c08][_0x6b38('0x71')]],'%s',_0x5ee3ee):_0x5ee3ee;_0x5ee3ee=_0x5e6624[_0x319c08]['format']?_['replace'](_0x2b9669[_0x5e6624[_0x319c08][_0x6b38('0x73')]],'%s',_0x5ee3ee):_0x5ee3ee;if(_0x5e6624[_0x319c08][_0x6b38('0x74')]){_0x5ceca6[_0x6b38('0x63')](_0x5ee3ee);}_0x5e6624[_0x319c08][_0x6b38('0x75')]&&_0x5ceca6[_0x6b38('0x38')](_0x5ee3ee,_0x5e6624[_0x319c08][_0x6b38('0x75')]===_0x6b38('0x76')?![]:!![]);_0x5ceca6[_0x6b38('0x64')](_0x5ee3ee,_0x5e6624[_0x319c08][_0x6b38('0x77')]||_0x5ee3ee);}if(_0x1a50a6[_0x6b38('0x78')]){_0x1a50a6[_0x6b38('0x78')]=JSON[_0x6b38('0x79')](_0x1a50a6[_0x6b38('0x78')]);for(var _0x1fddb8=0x0;_0x1fddb8<_0x1a50a6['joins']['length'];_0x1fddb8+=0x1){if(_0x1a50a6[_0x6b38('0x78')][_0x1fddb8][_0x6b38('0x2e')]&&_[_0x6b38('0x5d')](_0x572453,_0x1a50a6[_0x6b38('0x78')][_0x1fddb8]['type'])&&_0x1a50a6['joins'][_0x1fddb8][_0x6b38('0x7a')]&&_0x1a50a6['joins'][_0x1fddb8][_0x6b38('0x7b')]&&_0x1a50a6[_0x6b38('0x78')][_0x1fddb8]['foreignKey']){_0x5ceca6[_0x1a50a6[_0x6b38('0x78')][_0x1fddb8][_0x6b38('0x2e')]](_0x1a50a6[_0x6b38('0x78')][_0x1fddb8][_0x6b38('0x7b')],null,util[_0x6b38('0x73')](_0x6b38('0x7c'),_0x1a50a6['table'],_0x1a50a6[_0x6b38('0x78')][_0x1fddb8]['parentKey'],_0x1a50a6['joins'][_0x1fddb8][_0x6b38('0x7b')],_0x1a50a6['joins'][_0x1fddb8]['foreignKey']));}}}if(_0x1a50a6['conditions']){_0x1a50a6[_0x6b38('0x7d')]=JSON[_0x6b38('0x79')](_0x1a50a6[_0x6b38('0x7d')]);_0x5ceca6[_0x6b38('0x3a')](_0x2d7ca8(_0x1a50a6[_0x6b38('0x7d')][_0x6b38('0x63')]));}_0x397356=_0x5ceca6['clone']();_0x5ceca6[_0x6b38('0x1d')](_0x485d93);_0x5ceca6['offset'](0x0);logger[_0x6b38('0x7e')]('Limited\x20Query:',_0x5ceca6[_0x6b38('0x7f')]());return dbH[_0x6b38('0x80')][_0x6b38('0x31')](_0x5ceca6[_0x6b38('0x7f')](),{'type':dbH[_0x6b38('0x80')][_0x6b38('0x81')][_0x6b38('0x82')]});}})[_0x6b38('0x22')](respondWithResult(_0x3e9670,null))['catch'](handleError(_0x3e9670,null));};function runReport(_0x24af9e,_0x287530,_0x515fd7){var _0x523b01=_0x287530['name'];var _0x38b088=0xa;var _0x1c2367=[_0x6b38('0x51'),_0x6b38('0x83'),_0x6b38('0x52'),_0x6b38('0x53')];var _0x5dcf09={'SUM':_0x6b38('0x54'),'COUNT':_0x6b38('0x84'),'COUNT DISTINCT':_0x6b38('0x85'),'MAX':_0x6b38('0x55'),'MIN':_0x6b38('0x86'),'AVG':_0x6b38('0x56'),'GROUP_CONCAT':_0x6b38('0x57'),'GROUP_CONCAT ASC':_0x6b38('0x58'),'GROUP_CONCAT DESC':_0x6b38('0x87')};var _0x4aa2ff={'SEC_TO_TIME':_0x6b38('0x59'),'DATE':_0x6b38('0x5a'),'HOUR':'HOUR(%s)','ROUND':_0x6b38('0x88'),'UNIX_TIMESTAMP':_0x6b38('0x5c')};var _0x4005e7=function(_0x39177e){return!_[_0x6b38('0x5d')]([_0x6b38('0x89'),'IS\x20NOT\x20NULL',_0x6b38('0x5f'),_0x6b38('0x60')],_0x39177e);};var _0x281ee7=function(_0x2902d8){if(!_0x2902d8||!_0x2902d8['rules'][_0x6b38('0x35')]){return'';}for(var _0x2a0cd4='(',_0xac8060=0x0;_0xac8060<_0x2902d8[_0x6b38('0x61')][_0x6b38('0x35')];_0xac8060+=0x1){_0xac8060>0x0&&(_0x2a0cd4+='\x20'+_0x2902d8[_0x6b38('0x62')]+'\x20');_0x2a0cd4+=_0x2902d8[_0x6b38('0x61')][_0xac8060]['group']?_0x281ee7(_0x2902d8[_0x6b38('0x61')][_0xac8060][_0x6b38('0x63')]):_0x2902d8[_0x6b38('0x61')][_0xac8060][_0x6b38('0x64')]+'\x20'+_0x2902d8['rules'][_0xac8060][_0x6b38('0x65')]+(_0x4005e7(_0x2902d8[_0x6b38('0x61')][_0xac8060][_0x6b38('0x65')])?'\x20'+_0x2902d8[_0x6b38('0x61')][_0xac8060]['value']:'');}return _0x2a0cd4+')';};var _0x4fde92={'where':{'id':_0x24af9e['id']}},_0x59b191,_0x4ddc06,_0x44c3bf,_0x50380c,_0x33ca78;_0x4fde92=_['merge']({},_0x4fde92,_0x515fd7);return db[_0x6b38('0x2c')][_0x6b38('0x47')](_0x4fde92)[_0x6b38('0x22')](function(_0x324a7d){if(_0x324a7d){_0x59b191=_0x324a7d;return _0x324a7d['getFields']();}return null;})[_0x6b38('0x22')](function(_0x26120a){if(_0x26120a){if(!_0x26120a[_0x6b38('0x35')]){throw new db[(_0x6b38('0x68'))][(_0x6b38('0x69'))](_0x6b38('0x6a'),0x193);}_0x4ddc06=_0x26120a;return db[_0x6b38('0x6b')][_0x6b38('0x41')]({'raw':!![]});}return null;})[_0x6b38('0x22')](function(_0x5cfc76){if(_0x5cfc76){_0x44c3bf=_[_0x6b38('0x6c')](_0x5cfc76,'id');var _0x5ec554;var _0x3a5aec=squel['select']();_0x3a5aec[_0x6b38('0x6e')](_0x59b191[_0x6b38('0x8a')]);for(var _0x40b329=0x0;_0x40b329<_0x4ddc06[_0x6b38('0x35')];_0x40b329+=0x1){_0x5ec554=_0x4ddc06[_0x40b329][_0x6b38('0x6f')]?_0x44c3bf[_0x4ddc06[_0x40b329]['MetricId']][_0x6b38('0x70')]:_0x4ddc06[_0x40b329][_0x6b38('0x64')];_0x5ec554=_0x4ddc06[_0x40b329][_0x6b38('0x71')]?_[_0x6b38('0x72')](_0x5dcf09[_0x4ddc06[_0x40b329][_0x6b38('0x71')]],'%s',_0x5ec554):_0x5ec554;_0x5ec554=_0x4ddc06[_0x40b329]['format']?_[_0x6b38('0x72')](_0x4aa2ff[_0x4ddc06[_0x40b329][_0x6b38('0x73')]],'%s',_0x5ec554):_0x5ec554;if(_0x4ddc06[_0x40b329]['groupBy']){_0x3a5aec[_0x6b38('0x63')](_0x5ec554);}_0x4ddc06[_0x40b329][_0x6b38('0x75')]&&_0x3a5aec['order'](_0x5ec554,_0x4ddc06[_0x40b329][_0x6b38('0x75')]===_0x6b38('0x76')?![]:!![]);_0x3a5aec[_0x6b38('0x64')](_0x5ec554,_0x4ddc06[_0x40b329][_0x6b38('0x77')]||_0x5ec554);}if(_0x59b191[_0x6b38('0x78')]){_0x59b191[_0x6b38('0x78')]=JSON[_0x6b38('0x79')](_0x59b191[_0x6b38('0x78')]);for(var _0x58552c=0x0;_0x58552c<_0x59b191[_0x6b38('0x78')][_0x6b38('0x35')];_0x58552c+=0x1){if(_0x59b191['joins'][_0x58552c]['type']&&_[_0x6b38('0x5d')](_0x1c2367,_0x59b191['joins'][_0x58552c][_0x6b38('0x2e')])&&_0x59b191[_0x6b38('0x78')][_0x58552c]['parentKey']&&_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x7b')]&&_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x8b')]){_0x3a5aec[_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x2e')]](_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x7b')],null,util['format'](_0x6b38('0x7c'),_0x59b191[_0x6b38('0x8a')],_0x59b191['joins'][_0x58552c][_0x6b38('0x7a')],_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x7b')],_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x8b')]));}}}if(_0x59b191['conditions']){_0x59b191[_0x6b38('0x7d')]=JSON[_0x6b38('0x79')](_0x59b191[_0x6b38('0x7d')]);_0x3a5aec['where'](_0x281ee7(_0x59b191[_0x6b38('0x7d')][_0x6b38('0x63')]));}_0x33ca78=_0x3a5aec[_0x6b38('0x8c')]();_0x3a5aec['limit'](_0x38b088);_0x3a5aec[_0x6b38('0x1c')](0x0);return;}})[_0x6b38('0x22')](function(){if(_0x287530[_0x6b38('0x8d')]==='web'){return null;}var _0x12da34=_[_0x6b38('0x3c')](_0x287530,{'name':_0x287530['fullPath']||_0x287530[_0x6b38('0x29')]||_0x59b191[_0x6b38('0x29')],'basename':_0x523b01,'savename':util[_0x6b38('0x73')](_0x6b38('0x8e'),_0x287530[_0x6b38('0x29')]||_0x59b191[_0x6b38('0x29')],require('randomstring')[_0x6b38('0x8f')](0x4),_0x287530[_0x6b38('0x8d')]||_0x6b38('0x90')),'reportId':_0x59b191['id'],'reportType':_0x6b38('0x91')});return db[_0x6b38('0x92')]['create'](_0x12da34,{'raw':!![]});})[_0x6b38('0x22')](function(_0x38ec52){if(_0x59b191[_0x6b38('0x8a')]===_0x6b38('0x93')){_0x33ca78[_0x6b38('0x3a')](_0x59b191[_0x6b38('0x8a')]+_0x6b38('0x94'),_0x287530['startDate'],_0x287530[_0x6b38('0x95')]);}else{_0x33ca78['where'](_0x59b191['table']+_0x6b38('0x96'),_0x287530['startDate'],_0x287530[_0x6b38('0x95')]);}if(_0x38ec52){logger[_0x6b38('0x97')](_0x6b38('0x98'),_0x33ca78[_0x6b38('0x7f')]());require(_0x6b38('0x99'))[_0x6b38('0x9a')](path[_0x6b38('0x51')](__dirname,_0x6b38('0x9b'),_0x38ec52['output']),[_0x38ec52['id'],_0x33ca78[_0x6b38('0x7f')](),path[_0x6b38('0x51')](__dirname,_0x6b38('0x9c'),_0x38ec52[_0x6b38('0x9d')]),_0x523b01]);return _0x38ec52;}else{var _0x2d5b08=squel[_0x6b38('0x6d')]();_0x2d5b08[_0x6b38('0x6e')]('('+_0x33ca78[_0x6b38('0x7f')]()+')',_0x6b38('0x9e'));_0x2d5b08[_0x6b38('0x64')](_0x6b38('0x9f'),_0x6b38('0x1b'));_0x33ca78[_0x6b38('0x1d')](_0x287530[_0x6b38('0x1d')]||_0x38b088);_0x33ca78[_0x6b38('0x1c')](_0x287530[_0x6b38('0x1c')]||0x0);return dbH['sequelize']['query'](_0x2d5b08[_0x6b38('0x7f')](),{'type':dbH['sequelize'][_0x6b38('0x81')][_0x6b38('0x82')]})[_0x6b38('0x22')](function(_0x36c6d0){if(!_0x36c6d0[_0x6b38('0x35')]){_0x50380c=0x0;}else{_0x50380c=_0x36c6d0[0x0][_0x6b38('0x1b')]||0x0;}return dbH[_0x6b38('0x80')]['query'](_0x33ca78['toString'](),{'type':dbH[_0x6b38('0x80')][_0x6b38('0x81')]['SELECT']});})[_0x6b38('0x22')](function(_0x26d5b2){return{'rows':_0x26d5b2||[],'count':_0x50380c};});}});}exports['run']=function(_0x44e9f7,_0x3cc91a){return runReport(_0x44e9f7[_0x6b38('0x4f')],_0x44e9f7[_0x6b38('0x31')],_0x44e9f7['options'])['then'](respondWithResult(_0x3cc91a,null))[_0x6b38('0x43')](handleError(_0x3cc91a,null));};exports[_0x6b38('0xa0')]=runReport;exports[_0x6b38('0x31')]=function(_0x1a1ce2,_0x743c7d){var _0x399053=0xa;var _0x218195=[_0x6b38('0x51'),'left_join','right_join','cross_join'];var _0xf3e3ed={'SUM':_0x6b38('0x54'),'COUNT':_0x6b38('0x84'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x6b38('0x55'),'MIN':'MIN(%s)','AVG':_0x6b38('0x56'),'GROUP_CONCAT':_0x6b38('0x57'),'GROUP_CONCAT ASC':_0x6b38('0x58'),'GROUP_CONCAT DESC':_0x6b38('0x87')};var _0x5080c0={'SEC_TO_TIME':_0x6b38('0x59'),'DATE':_0x6b38('0x5a'),'HOUR':_0x6b38('0x5b'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x6b38('0x5c')};var _0x4f3c6f=function(_0x477d65){return!_[_0x6b38('0x5d')]([_0x6b38('0x89'),'IS\x20NOT\x20NULL',_0x6b38('0x5f'),_0x6b38('0x60')],_0x477d65);};var _0x482de9=function(_0x6cc615){if(!_0x6cc615||!_0x6cc615[_0x6b38('0x61')][_0x6b38('0x35')]){return'';}for(var _0x4300f2='(',_0x4f3db2=0x0;_0x4f3db2<_0x6cc615['rules'][_0x6b38('0x35')];_0x4f3db2+=0x1){_0x4f3db2>0x0&&(_0x4300f2+='\x20'+_0x6cc615['operator']+'\x20');_0x4300f2+=_0x6cc615['rules'][_0x4f3db2][_0x6b38('0x63')]?_0x482de9(_0x6cc615[_0x6b38('0x61')][_0x4f3db2]['group']):_0x6cc615['rules'][_0x4f3db2][_0x6b38('0x64')]+'\x20'+_0x6cc615['rules'][_0x4f3db2][_0x6b38('0x65')]+(_0x4f3c6f(_0x6cc615[_0x6b38('0x61')][_0x4f3db2][_0x6b38('0x65')])?'\x20'+_0x6cc615['rules'][_0x4f3db2][_0x6b38('0x66')]:'');}return _0x4300f2+')';};var _0x2f8802={'where':{'id':_0x1a1ce2[_0x6b38('0x4f')]['id']}},_0x5ce487,_0x458c68,_0x1b9c4e,_0x4ce0a6,_0x22b76a;_0x2f8802=_[_0x6b38('0x3c')]({},_0x2f8802,_0x1a1ce2[_0x6b38('0x46')]);return db['AnalyticDefaultReport'][_0x6b38('0x47')](_0x2f8802)['then'](function(_0x4ac1bb){if(_0x4ac1bb){_0x5ce487=_0x4ac1bb;return _0x4ac1bb[_0x6b38('0x67')]();}return null;})[_0x6b38('0x22')](function(_0x14f99a){if(_0x14f99a){if(!_0x14f99a[_0x6b38('0x35')]){throw new db[(_0x6b38('0x68'))]['ValidationErrorItem'](_0x6b38('0x6a'),0x193);}_0x458c68=_0x14f99a;return db[_0x6b38('0x6b')][_0x6b38('0x41')]({'raw':!![]});}return null;})[_0x6b38('0x22')](function(_0xacd734){if(_0xacd734){_0x1b9c4e=_[_0x6b38('0x6c')](_0xacd734,'id');var _0x45153b;var _0x916df=squel[_0x6b38('0x6d')]();_0x916df[_0x6b38('0x6e')](_0x5ce487[_0x6b38('0x8a')]);for(var _0x2a8615=0x0;_0x2a8615<_0x458c68[_0x6b38('0x35')];_0x2a8615+=0x1){_0x45153b=_0x458c68[_0x2a8615]['MetricId']?_0x1b9c4e[_0x458c68[_0x2a8615]['MetricId']][_0x6b38('0x70')]:_0x458c68[_0x2a8615][_0x6b38('0x64')];_0x45153b=_0x458c68[_0x2a8615][_0x6b38('0x71')]?_[_0x6b38('0x72')](_0xf3e3ed[_0x458c68[_0x2a8615]['function']],'%s',_0x45153b):_0x45153b;_0x45153b=_0x458c68[_0x2a8615][_0x6b38('0x73')]?_[_0x6b38('0x72')](_0x5080c0[_0x458c68[_0x2a8615][_0x6b38('0x73')]],'%s',_0x45153b):_0x45153b;if(_0x458c68[_0x2a8615][_0x6b38('0x74')]){_0x916df['group'](_0x45153b);}_0x458c68[_0x2a8615]['orderBy']&&_0x916df[_0x6b38('0x38')](_0x45153b,_0x458c68[_0x2a8615][_0x6b38('0x75')]===_0x6b38('0x76')?![]:!![]);_0x916df[_0x6b38('0x64')](_0x45153b,_0x458c68[_0x2a8615][_0x6b38('0x77')]||_0x45153b);}if(_0x5ce487[_0x6b38('0x78')]){_0x5ce487[_0x6b38('0x78')]=JSON[_0x6b38('0x79')](_0x5ce487[_0x6b38('0x78')]);for(var _0x523ed0=0x0;_0x523ed0<_0x5ce487[_0x6b38('0x78')][_0x6b38('0x35')];_0x523ed0+=0x1){if(_0x5ce487[_0x6b38('0x78')][_0x523ed0]['type']&&_[_0x6b38('0x5d')](_0x218195,_0x5ce487[_0x6b38('0x78')][_0x523ed0][_0x6b38('0x2e')])&&_0x5ce487[_0x6b38('0x78')][_0x523ed0]['parentKey']&&_0x5ce487[_0x6b38('0x78')][_0x523ed0]['foreignTable']&&_0x5ce487['joins'][_0x523ed0][_0x6b38('0x8b')]){_0x916df[_0x5ce487[_0x6b38('0x78')][_0x523ed0]['type']](_0x5ce487[_0x6b38('0x78')][_0x523ed0][_0x6b38('0x7b')],null,util[_0x6b38('0x73')](_0x6b38('0x7c'),_0x5ce487['table'],_0x5ce487[_0x6b38('0x78')][_0x523ed0][_0x6b38('0x7a')],_0x5ce487[_0x6b38('0x78')][_0x523ed0][_0x6b38('0x7b')],_0x5ce487['joins'][_0x523ed0][_0x6b38('0x8b')]));}}}if(_0x5ce487[_0x6b38('0x7d')]){_0x5ce487['conditions']=JSON[_0x6b38('0x79')](_0x5ce487['conditions']);_0x916df[_0x6b38('0x3a')](_0x482de9(_0x5ce487['conditions'][_0x6b38('0x63')]));}_0x22b76a=_0x916df[_0x6b38('0x8c')]();_0x916df['limit'](_0x399053);_0x916df[_0x6b38('0x1c')](0x0);logger[_0x6b38('0x7e')](_0x6b38('0xa1'),_0x916df[_0x6b38('0x7f')]());return dbH[_0x6b38('0x80')]['query'](_0x916df[_0x6b38('0x7f')](),{'type':dbH['sequelize'][_0x6b38('0x81')][_0x6b38('0x82')]});}})[_0x6b38('0x22')](function(){return{'sql':_0x22b76a[_0x6b38('0x7f')]()};})[_0x6b38('0x22')](respondWithResult(_0x743c7d,null))[_0x6b38('0x43')](handleError(_0x743c7d,null));};
\ No newline at end of file
+var _0xf494=['name','send','index','map','AnalyticDefaultReport','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','catch','show','includeAll','find','create','body','user','Reports','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','join','left_join','cross_join','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NOT\x20NULL','IS\x20EMPTY','rules','group','field','value','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','table','MetricId','metric','function','replace','format','orderBy','DESC','alias','joins','parse','foreignTable','%s.%s\x20=\x20%s.%s','parentKey','foreignKey','conditions','debug','Limited\x20Query:','sequelize','toString','QueryTypes','right_join','SUM(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','ROUND(%s)','IS\x20NULL','operator','condition','getFields','groupBy','clone','output','fullPath','%s-%s.%s','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','endDate','info','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','SELECT','run','runReport','IS\x20NOT\x20EMPTY','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','reject','save','update','then','destroy','get','DefaultReports','error','stack'];(function(_0x306c0c,_0x184d7f){var _0x118365=function(_0x1fece1){while(--_0x1fece1){_0x306c0c['push'](_0x306c0c['shift']());}};_0x118365(++_0x184d7f);}(_0xf494,0x1c6));var _0x4f49=function(_0x1602c2,_0x47b449){_0x1602c2=_0x1602c2-0x0;var _0x182f40=_0xf494[_0x1602c2];return _0x182f40;};'use strict';var emlformat=require(_0x4f49('0x0'));var rimraf=require(_0x4f49('0x1'));var zipdir=require(_0x4f49('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x4f49('0x3'));var moment=require(_0x4f49('0x4'));var BPromise=require(_0x4f49('0x5'));var Mustache=require(_0x4f49('0x6'));var util=require(_0x4f49('0x7'));var path=require(_0x4f49('0x8'));var sox=require(_0x4f49('0x9'));var csv=require(_0x4f49('0xa'));var ejs=require(_0x4f49('0xb'));var fs=require('fs');var fs_extra=require(_0x4f49('0xc'));var _=require(_0x4f49('0xd'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x4f49('0xe'));var deskjs=require(_0x4f49('0xf'));var toCsv=require(_0x4f49('0xa'));var querystring=require(_0x4f49('0x10'));var Papa=require(_0x4f49('0x11'));var Redis=require(_0x4f49('0x12'));var authService=require(_0x4f49('0x13'));var qs=require(_0x4f49('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4f49('0x15'));var logger=require(_0x4f49('0x16'))('api');var utils=require(_0x4f49('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x4f49('0x18'))['db'];var dbH=require(_0x4f49('0x18'))['dbH'];function respondWithStatusCode(_0x1e1c37,_0x111a8b){_0x111a8b=_0x111a8b||0xcc;return function(_0x1b9145){if(_0x1b9145){return _0x1e1c37[_0x4f49('0x19')](_0x111a8b);}return _0x1e1c37[_0x4f49('0x1a')](_0x111a8b)[_0x4f49('0x1b')]();};}function respondWithResult(_0xfdb477,_0x5c373e){_0x5c373e=_0x5c373e||0xc8;return function(_0x515ace){if(_0x515ace){return _0xfdb477[_0x4f49('0x1a')](_0x5c373e)[_0x4f49('0x1c')](_0x515ace);}};}function respondWithFilteredResult(_0x5878f4,_0x5bdfaf){return function(_0x2f0a0d){if(_0x2f0a0d){var _0x2ecaaa=typeof _0x5bdfaf[_0x4f49('0x1d')]==='undefined'&&typeof _0x5bdfaf[_0x4f49('0x1e')]===_0x4f49('0x1f');var _0x4e85df=_0x2f0a0d['count'];var _0x5bb23b=_0x2ecaaa?0x0:_0x5bdfaf['offset'];var _0x47f1e8=_0x2ecaaa?_0x2f0a0d[_0x4f49('0x20')]:_0x5bdfaf[_0x4f49('0x1d')]+_0x5bdfaf[_0x4f49('0x1e')];var _0x407042;if(_0x47f1e8>=_0x4e85df){_0x47f1e8=_0x4e85df;_0x407042=0xc8;}else{_0x407042=0xce;}_0x5878f4['status'](_0x407042);return _0x5878f4[_0x4f49('0x21')](_0x4f49('0x22'),_0x5bb23b+'-'+_0x47f1e8+'/'+_0x4e85df)[_0x4f49('0x1c')](_0x2f0a0d);}return null;};}function patchUpdates(_0xaab5e7){return function(_0xea82f8){try{jsonpatch['apply'](_0xea82f8,_0xaab5e7,!![]);}catch(_0x3e7e28){return BPromise[_0x4f49('0x23')](_0x3e7e28);}return _0xea82f8[_0x4f49('0x24')]();};}function saveUpdates(_0x53b57d,_0x40755e){return function(_0x1d70a7){if(_0x1d70a7){return _0x1d70a7[_0x4f49('0x25')](_0x53b57d)[_0x4f49('0x26')](function(_0x9d30aa){return _0x9d30aa;});}return null;};}function removeEntity(_0x36187b,_0x559d98){return function(_0x4e9041){if(_0x4e9041){return _0x4e9041[_0x4f49('0x27')]()[_0x4f49('0x26')](function(){var _0x4fedbb=_0x4e9041[_0x4f49('0x28')]({'plain':!![]});var _0x2c1519=_0x4f49('0x29');return db['UserProfileResource'][_0x4f49('0x27')]({'where':{'type':_0x2c1519,'resourceId':_0x4fedbb['id']}})[_0x4f49('0x26')](function(){return _0x4e9041;});})[_0x4f49('0x26')](function(){_0x36187b[_0x4f49('0x1a')](0xcc)[_0x4f49('0x1b')]();});}};}function handleEntityNotFound(_0x122404,_0x4915af){return function(_0x50c571){if(!_0x50c571){_0x122404[_0x4f49('0x19')](0x194);}return _0x50c571;};}function handleError(_0x2c00ee,_0x605c91){_0x605c91=_0x605c91||0x1f4;return function(_0x560050){logger[_0x4f49('0x2a')](_0x560050[_0x4f49('0x2b')]);if(_0x560050[_0x4f49('0x2c')]){delete _0x560050['name'];}_0x2c00ee['status'](_0x605c91)[_0x4f49('0x2d')](_0x560050);};}exports[_0x4f49('0x2e')]=function(_0x7a6ea0,_0x5e7076){var _0x1eaac6={},_0x35aa33={},_0x173657={'count':0x0,'rows':[]};var _0x2ceda4=_[_0x4f49('0x2f')](db[_0x4f49('0x30')][_0x4f49('0x31')],function(_0x45ae19){return{'name':_0x45ae19[_0x4f49('0x32')],'type':_0x45ae19[_0x4f49('0x33')][_0x4f49('0x34')]};});_0x35aa33[_0x4f49('0x35')]=_[_0x4f49('0x2f')](_0x2ceda4,_0x4f49('0x2c'));_0x35aa33[_0x4f49('0x36')]=_[_0x4f49('0x37')](_0x7a6ea0[_0x4f49('0x36')]);_0x35aa33[_0x4f49('0x38')]=_[_0x4f49('0x39')](_0x35aa33['model'],_0x35aa33[_0x4f49('0x36')]);_0x1eaac6[_0x4f49('0x3a')]=_[_0x4f49('0x39')](_0x35aa33[_0x4f49('0x35')],qs[_0x4f49('0x3b')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x3b')]));_0x1eaac6[_0x4f49('0x3a')]=_0x1eaac6[_0x4f49('0x3a')][_0x4f49('0x3c')]?_0x1eaac6[_0x4f49('0x3a')]:_0x35aa33[_0x4f49('0x35')];if(!_0x7a6ea0[_0x4f49('0x36')]['hasOwnProperty'](_0x4f49('0x3d'))){_0x1eaac6[_0x4f49('0x1e')]=qs[_0x4f49('0x1e')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x1e')]);_0x1eaac6[_0x4f49('0x1d')]=qs[_0x4f49('0x1d')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x1d')]);}_0x1eaac6[_0x4f49('0x3e')]=qs[_0x4f49('0x3f')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x3f')]);_0x1eaac6[_0x4f49('0x40')]=qs['filters'](_[_0x4f49('0x41')](_0x7a6ea0[_0x4f49('0x36')],_0x35aa33['filters']),_0x2ceda4);if(_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x42')]){_0x1eaac6['where']=_[_0x4f49('0x43')](_0x1eaac6[_0x4f49('0x40')],{'$or':_[_0x4f49('0x2f')](_0x2ceda4,function(_0x200b1d){if(_0x200b1d[_0x4f49('0x33')]!==_0x4f49('0x44')){var _0x29e910={};_0x29e910[_0x200b1d['name']]={'$like':'%'+_0x7a6ea0['query']['filter']+'%'};return _0x29e910;}})});}_0x1eaac6=_[_0x4f49('0x43')]({},_0x1eaac6,_0x7a6ea0[_0x4f49('0x45')]);var _0x2e4355={'where':_0x1eaac6[_0x4f49('0x40')]};return db[_0x4f49('0x30')][_0x4f49('0x20')](_0x2e4355)[_0x4f49('0x26')](function(_0x23720a){_0x173657[_0x4f49('0x20')]=_0x23720a;if(_0x7a6ea0['query']['includeAll']){_0x1eaac6[_0x4f49('0x46')]=[{'all':!![]}];}return db[_0x4f49('0x30')][_0x4f49('0x47')](_0x1eaac6);})['then'](function(_0x2d6b56){_0x173657['rows']=_0x2d6b56;return _0x173657;})['then'](respondWithFilteredResult(_0x5e7076,_0x1eaac6))[_0x4f49('0x48')](handleError(_0x5e7076,null));};exports[_0x4f49('0x49')]=function(_0x40eadc,_0x497cb8){var _0x287781={'raw':!![],'where':{'id':_0x40eadc['params']['id']}},_0x11b4df={};_0x11b4df[_0x4f49('0x35')]=_['keys'](db[_0x4f49('0x30')][_0x4f49('0x31')]);_0x11b4df[_0x4f49('0x36')]=_['keys'](_0x40eadc[_0x4f49('0x36')]);_0x11b4df[_0x4f49('0x38')]=_[_0x4f49('0x39')](_0x11b4df[_0x4f49('0x35')],_0x11b4df[_0x4f49('0x36')]);_0x287781[_0x4f49('0x3a')]=_[_0x4f49('0x39')](_0x11b4df[_0x4f49('0x35')],qs[_0x4f49('0x3b')](_0x40eadc[_0x4f49('0x36')]['fields']));_0x287781[_0x4f49('0x3a')]=_0x287781[_0x4f49('0x3a')]['length']?_0x287781[_0x4f49('0x3a')]:_0x11b4df['model'];if(_0x40eadc[_0x4f49('0x36')][_0x4f49('0x4a')]){_0x287781[_0x4f49('0x46')]=[{'all':!![]}];}_0x287781=_[_0x4f49('0x43')]({},_0x287781,_0x40eadc['options']);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x287781)[_0x4f49('0x26')](handleEntityNotFound(_0x497cb8,null))[_0x4f49('0x26')](respondWithResult(_0x497cb8,null))[_0x4f49('0x48')](handleError(_0x497cb8,null));};exports[_0x4f49('0x4c')]=function(_0x37fdb7,_0xd282c){return db[_0x4f49('0x30')][_0x4f49('0x4c')](_0x37fdb7[_0x4f49('0x4d')],{})[_0x4f49('0x26')](function(_0x148031){var _0x2104d0=_0x37fdb7[_0x4f49('0x4e')][_0x4f49('0x28')]({'plain':!![]});if(!_0x2104d0)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2104d0['role']===_0x4f49('0x4e')){var _0x197670=_0x148031[_0x4f49('0x28')]({'plain':!![]});var _0xe46c90=_0x4f49('0x4f');return db[_0x4f49('0x50')][_0x4f49('0x4b')]({'where':{'name':_0xe46c90,'userProfileId':_0x2104d0['userProfileId']},'raw':!![]})[_0x4f49('0x26')](function(_0x4ff0a2){if(_0x4ff0a2&&_0x4ff0a2[_0x4f49('0x51')]===0x0){return db[_0x4f49('0x52')][_0x4f49('0x4c')]({'name':_0x197670[_0x4f49('0x2c')],'resourceId':_0x197670['id'],'type':'DefaultReports','sectionId':_0x4ff0a2['id']},{})[_0x4f49('0x26')](function(){return _0x148031;});}else{return _0x148031;}})['catch'](function(_0x52d18c){logger[_0x4f49('0x2a')](_0x4f49('0x53'),_0x52d18c);throw _0x52d18c;});}return _0x148031;})[_0x4f49('0x26')](respondWithResult(_0xd282c,0xc9))[_0x4f49('0x48')](handleError(_0xd282c,null));};exports['update']=function(_0x599c51,_0xd7f47b){if(_0x599c51[_0x4f49('0x4d')]['id']){delete _0x599c51['body']['id'];}return db[_0x4f49('0x30')]['find']({'where':{'id':_0x599c51['params']['id']}})[_0x4f49('0x26')](handleEntityNotFound(_0xd7f47b,null))['then'](saveUpdates(_0x599c51[_0x4f49('0x4d')],null))['then'](respondWithResult(_0xd7f47b,null))[_0x4f49('0x48')](handleError(_0xd7f47b,null));};exports[_0x4f49('0x27')]=function(_0x2472c9,_0x883408){return db[_0x4f49('0x30')][_0x4f49('0x4b')]({'where':{'id':_0x2472c9[_0x4f49('0x54')]['id']}})[_0x4f49('0x26')](handleEntityNotFound(_0x883408,null))['then'](removeEntity(_0x883408,null))[_0x4f49('0x48')](handleError(_0x883408,null));};exports['preview']=function(_0x213608,_0x1f640d){var _0xc4fc6b=0xa;var _0x467f12=[_0x4f49('0x55'),_0x4f49('0x56'),'right_join',_0x4f49('0x57')];var _0xd3689c={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':_0x4f49('0x59'),'MIN':_0x4f49('0x5a'),'AVG':_0x4f49('0x5b'),'GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0x564bf5={'SEC_TO_TIME':_0x4f49('0x5e'),'DATE':_0x4f49('0x5f'),'HOUR':_0x4f49('0x60'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x21807e=function(_0x265988){return!_[_0x4f49('0x62')](['IS\x20NULL',_0x4f49('0x63'),_0x4f49('0x64'),'IS\x20NOT\x20EMPTY'],_0x265988);};var _0x293839=function(_0x17b15){if(!_0x17b15||!_0x17b15[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x28ea73='(',_0x1b80f2=0x0;_0x1b80f2<_0x17b15[_0x4f49('0x65')][_0x4f49('0x3c')];_0x1b80f2+=0x1){_0x1b80f2>0x0&&(_0x28ea73+='\x20'+_0x17b15['operator']+'\x20');_0x28ea73+=_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x66')]?_0x293839(_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x66')]):_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x67')]+'\x20'+_0x17b15[_0x4f49('0x65')][_0x1b80f2]['condition']+(_0x21807e(_0x17b15[_0x4f49('0x65')][_0x1b80f2]['condition'])?'\x20'+_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x68')]:'');}return _0x28ea73+')';};var _0x4714c7={'where':{'id':_0x213608[_0x4f49('0x54')]['id']}},_0xf29378,_0xc7743e,_0x3f2f3f,_0x61a565,_0x297698;_0x4714c7=_[_0x4f49('0x43')]({},_0x4714c7,_0x213608['options']);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x4714c7)[_0x4f49('0x26')](function(_0x2cdaa4){if(_0x2cdaa4){_0xf29378=_0x2cdaa4;return _0x2cdaa4['getFields']();}return null;})['then'](function(_0x28e8ae){if(_0x28e8ae){if(!_0x28e8ae['length']){throw new db[(_0x4f49('0x69'))][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0xc7743e=_0x28e8ae;return db[_0x4f49('0x6c')][_0x4f49('0x47')]({'raw':!![]});}return null;})[_0x4f49('0x26')](function(_0x179431){if(_0x179431){_0x3f2f3f=_[_0x4f49('0x6d')](_0x179431,'id');var _0x3823f0;var _0x3e9b47=squel[_0x4f49('0x6e')]();_0x3e9b47[_0x4f49('0x6f')](_0xf29378[_0x4f49('0x70')]);for(var _0xd53de8=0x0;_0xd53de8<_0xc7743e[_0x4f49('0x3c')];_0xd53de8+=0x1){_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x71')]?_0x3f2f3f[_0xc7743e[_0xd53de8][_0x4f49('0x71')]][_0x4f49('0x72')]:_0xc7743e[_0xd53de8][_0x4f49('0x67')];_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x73')]?_[_0x4f49('0x74')](_0xd3689c[_0xc7743e[_0xd53de8][_0x4f49('0x73')]],'%s',_0x3823f0):_0x3823f0;_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0x564bf5[_0xc7743e[_0xd53de8][_0x4f49('0x75')]],'%s',_0x3823f0):_0x3823f0;if(_0xc7743e[_0xd53de8]['groupBy']){_0x3e9b47[_0x4f49('0x66')](_0x3823f0);}_0xc7743e[_0xd53de8]['orderBy']&&_0x3e9b47[_0x4f49('0x3e')](_0x3823f0,_0xc7743e[_0xd53de8][_0x4f49('0x76')]===_0x4f49('0x77')?![]:!![]);_0x3e9b47[_0x4f49('0x67')](_0x3823f0,_0xc7743e[_0xd53de8][_0x4f49('0x78')]||_0x3823f0);}if(_0xf29378[_0x4f49('0x79')]){_0xf29378[_0x4f49('0x79')]=JSON[_0x4f49('0x7a')](_0xf29378[_0x4f49('0x79')]);for(var _0x541ac6=0x0;_0x541ac6<_0xf29378['joins'][_0x4f49('0x3c')];_0x541ac6+=0x1){if(_0xf29378['joins'][_0x541ac6][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x467f12,_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x33')])&&_0xf29378[_0x4f49('0x79')][_0x541ac6]['parentKey']&&_0xf29378['joins'][_0x541ac6][_0x4f49('0x7b')]&&_0xf29378[_0x4f49('0x79')][_0x541ac6]['foreignKey']){_0x3e9b47[_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x33')]](_0xf29378['joins'][_0x541ac6][_0x4f49('0x7b')],null,util['format'](_0x4f49('0x7c'),_0xf29378[_0x4f49('0x70')],_0xf29378['joins'][_0x541ac6][_0x4f49('0x7d')],_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x7b')],_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x7e')]));}}}if(_0xf29378[_0x4f49('0x7f')]){_0xf29378['conditions']=JSON[_0x4f49('0x7a')](_0xf29378['conditions']);_0x3e9b47[_0x4f49('0x40')](_0x293839(_0xf29378['conditions'][_0x4f49('0x66')]));}_0x297698=_0x3e9b47['clone']();_0x3e9b47[_0x4f49('0x1e')](_0xc4fc6b);_0x3e9b47[_0x4f49('0x1d')](0x0);logger[_0x4f49('0x80')](_0x4f49('0x81'),_0x3e9b47['toString']());return dbH[_0x4f49('0x82')]['query'](_0x3e9b47[_0x4f49('0x83')](),{'type':dbH['sequelize'][_0x4f49('0x84')]['SELECT']});}})['then'](respondWithResult(_0x1f640d,null))[_0x4f49('0x48')](handleError(_0x1f640d,null));};function runReport(_0x20b2be,_0x16cb4d,_0x4c0e7a){var _0x289810=_0x16cb4d[_0x4f49('0x2c')];var _0x5c33c9=0xa;var _0x5d52ae=['join',_0x4f49('0x56'),_0x4f49('0x85'),_0x4f49('0x57')];var _0x87439={'SUM':_0x4f49('0x86'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':_0x4f49('0x59'),'MIN':_0x4f49('0x5a'),'AVG':'AVG(%s)','GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':_0x4f49('0x87'),'GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0x2902a1={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x4f49('0x5f'),'HOUR':_0x4f49('0x60'),'ROUND':_0x4f49('0x88'),'UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x389679=function(_0x5304c3){return!_[_0x4f49('0x62')]([_0x4f49('0x89'),'IS\x20NOT\x20NULL',_0x4f49('0x64'),'IS\x20NOT\x20EMPTY'],_0x5304c3);};var _0x351a33=function(_0x4d72a0){if(!_0x4d72a0||!_0x4d72a0[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x2ef19e='(',_0x6ad599=0x0;_0x6ad599<_0x4d72a0[_0x4f49('0x65')]['length'];_0x6ad599+=0x1){_0x6ad599>0x0&&(_0x2ef19e+='\x20'+_0x4d72a0[_0x4f49('0x8a')]+'\x20');_0x2ef19e+=_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x66')]?_0x351a33(_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['group']):_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['field']+'\x20'+_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['condition']+(_0x389679(_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x8b')])?'\x20'+_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x68')]:'');}return _0x2ef19e+')';};var _0x111e90={'where':{'id':_0x20b2be['id']}},_0xd253ed,_0x323a3a,_0xe0adc3,_0x3a26ff,_0x64f0ee;_0x111e90=_['merge']({},_0x111e90,_0x4c0e7a);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x111e90)[_0x4f49('0x26')](function(_0x299849){if(_0x299849){_0xd253ed=_0x299849;return _0x299849[_0x4f49('0x8c')]();}return null;})[_0x4f49('0x26')](function(_0x55b28b){if(_0x55b28b){if(!_0x55b28b[_0x4f49('0x3c')]){throw new db[(_0x4f49('0x69'))][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0x323a3a=_0x55b28b;return db['AnalyticMetric'][_0x4f49('0x47')]({'raw':!![]});}return null;})['then'](function(_0x3c4e88){if(_0x3c4e88){_0xe0adc3=_[_0x4f49('0x6d')](_0x3c4e88,'id');var _0x5c5d2;var _0xa880a2=squel['select']();_0xa880a2[_0x4f49('0x6f')](_0xd253ed[_0x4f49('0x70')]);for(var _0x11c0a0=0x0;_0x11c0a0<_0x323a3a[_0x4f49('0x3c')];_0x11c0a0+=0x1){_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x71')]?_0xe0adc3[_0x323a3a[_0x11c0a0][_0x4f49('0x71')]][_0x4f49('0x72')]:_0x323a3a[_0x11c0a0][_0x4f49('0x67')];_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x73')]?_[_0x4f49('0x74')](_0x87439[_0x323a3a[_0x11c0a0][_0x4f49('0x73')]],'%s',_0x5c5d2):_0x5c5d2;_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0x2902a1[_0x323a3a[_0x11c0a0][_0x4f49('0x75')]],'%s',_0x5c5d2):_0x5c5d2;if(_0x323a3a[_0x11c0a0][_0x4f49('0x8d')]){_0xa880a2[_0x4f49('0x66')](_0x5c5d2);}_0x323a3a[_0x11c0a0][_0x4f49('0x76')]&&_0xa880a2[_0x4f49('0x3e')](_0x5c5d2,_0x323a3a[_0x11c0a0]['orderBy']===_0x4f49('0x77')?![]:!![]);_0xa880a2[_0x4f49('0x67')](_0x5c5d2,_0x323a3a[_0x11c0a0][_0x4f49('0x78')]||_0x5c5d2);}if(_0xd253ed[_0x4f49('0x79')]){_0xd253ed['joins']=JSON[_0x4f49('0x7a')](_0xd253ed[_0x4f49('0x79')]);for(var _0x594460=0x0;_0x594460<_0xd253ed[_0x4f49('0x79')]['length'];_0x594460+=0x1){if(_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x5d52ae,_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x33')])&&_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7d')]&&_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7b')]&&_0xd253ed[_0x4f49('0x79')][_0x594460]['foreignKey']){_0xa880a2[_0xd253ed['joins'][_0x594460][_0x4f49('0x33')]](_0xd253ed['joins'][_0x594460][_0x4f49('0x7b')],null,util[_0x4f49('0x75')]('%s.%s\x20=\x20%s.%s',_0xd253ed['table'],_0xd253ed[_0x4f49('0x79')][_0x594460]['parentKey'],_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7b')],_0xd253ed[_0x4f49('0x79')][_0x594460]['foreignKey']));}}}if(_0xd253ed[_0x4f49('0x7f')]){_0xd253ed['conditions']=JSON[_0x4f49('0x7a')](_0xd253ed[_0x4f49('0x7f')]);_0xa880a2[_0x4f49('0x40')](_0x351a33(_0xd253ed['conditions'][_0x4f49('0x66')]));}_0x64f0ee=_0xa880a2[_0x4f49('0x8e')]();_0xa880a2[_0x4f49('0x1e')](_0x5c33c9);_0xa880a2['offset'](0x0);return;}})['then'](function(){if(_0x16cb4d[_0x4f49('0x8f')]==='web'){return null;}var _0x2bc9df=_[_0x4f49('0x43')](_0x16cb4d,{'name':_0x16cb4d[_0x4f49('0x90')]||_0x16cb4d['name']||_0xd253ed[_0x4f49('0x2c')],'basename':_0x289810,'savename':util['format'](_0x4f49('0x91'),_0x16cb4d[_0x4f49('0x2c')]||_0xd253ed[_0x4f49('0x2c')],require('randomstring')[_0x4f49('0x92')](0x4),_0x16cb4d[_0x4f49('0x8f')]||_0x4f49('0x93')),'reportId':_0xd253ed['id'],'reportType':_0x4f49('0x94')});return db[_0x4f49('0x95')][_0x4f49('0x4c')](_0x2bc9df,{'raw':!![]});})['then'](function(_0x5b6ac7){if(_0xd253ed[_0x4f49('0x70')]===_0x4f49('0x96')){_0x64f0ee[_0x4f49('0x40')](_0xd253ed[_0x4f49('0x70')]+_0x4f49('0x97'),_0x16cb4d[_0x4f49('0x98')],_0x16cb4d[_0x4f49('0x99')]);}else{_0x64f0ee[_0x4f49('0x40')](_0xd253ed[_0x4f49('0x70')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x16cb4d[_0x4f49('0x98')],_0x16cb4d[_0x4f49('0x99')]);}if(_0x5b6ac7){logger[_0x4f49('0x9a')]('Run\x20Query:',_0x64f0ee[_0x4f49('0x83')]());require(_0x4f49('0x9b'))[_0x4f49('0x9c')](path['join'](__dirname,_0x4f49('0x9d'),_0x5b6ac7[_0x4f49('0x8f')]),[_0x5b6ac7['id'],_0x64f0ee[_0x4f49('0x83')](),path['join'](__dirname,_0x4f49('0x9e'),_0x5b6ac7[_0x4f49('0x9f')]),_0x289810]);return _0x5b6ac7;}else{var _0x5efb11=squel['select']();_0x5efb11[_0x4f49('0x6f')]('('+_0x64f0ee[_0x4f49('0x83')]()+')',_0x4f49('0xa0'));_0x5efb11[_0x4f49('0x67')](_0x4f49('0xa1'),_0x4f49('0x20'));_0x64f0ee['limit'](_0x16cb4d['limit']||_0x5c33c9);_0x64f0ee['offset'](_0x16cb4d[_0x4f49('0x1d')]||0x0);return dbH[_0x4f49('0x82')]['query'](_0x5efb11[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')][_0x4f49('0x84')]['SELECT']})['then'](function(_0x3633b5){if(!_0x3633b5['length']){_0x3a26ff=0x0;}else{_0x3a26ff=_0x3633b5[0x0][_0x4f49('0x20')]||0x0;}return dbH[_0x4f49('0x82')][_0x4f49('0x36')](_0x64f0ee[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')]['QueryTypes'][_0x4f49('0xa2')]});})[_0x4f49('0x26')](function(_0x45c938){return{'rows':_0x45c938||[],'count':_0x3a26ff};});}});}exports[_0x4f49('0xa3')]=function(_0x4a4d75,_0x93e85d){return runReport(_0x4a4d75[_0x4f49('0x54')],_0x4a4d75['query'],_0x4a4d75[_0x4f49('0x45')])[_0x4f49('0x26')](respondWithResult(_0x93e85d,null))[_0x4f49('0x48')](handleError(_0x93e85d,null));};exports[_0x4f49('0xa4')]=runReport;exports[_0x4f49('0x36')]=function(_0x40991b,_0x56290f){var _0x4994b6=0xa;var _0x1c7d87=[_0x4f49('0x55'),_0x4f49('0x56'),_0x4f49('0x85'),_0x4f49('0x57')];var _0x5cd00a={'SUM':_0x4f49('0x86'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':'MAX(%s)','MIN':'MIN(%s)','AVG':_0x4f49('0x5b'),'GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':_0x4f49('0x87'),'GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0xd876f1={'SEC_TO_TIME':_0x4f49('0x5e'),'DATE':_0x4f49('0x5f'),'HOUR':'HOUR(%s)','ROUND':_0x4f49('0x88'),'UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x1ae2c9=function(_0x566634){return!_[_0x4f49('0x62')]([_0x4f49('0x89'),_0x4f49('0x63'),'IS\x20EMPTY',_0x4f49('0xa5')],_0x566634);};var _0x541dc2=function(_0x4061bf){if(!_0x4061bf||!_0x4061bf[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x1bc18d='(',_0x5e6103=0x0;_0x5e6103<_0x4061bf[_0x4f49('0x65')][_0x4f49('0x3c')];_0x5e6103+=0x1){_0x5e6103>0x0&&(_0x1bc18d+='\x20'+_0x4061bf[_0x4f49('0x8a')]+'\x20');_0x1bc18d+=_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x66')]?_0x541dc2(_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x66')]):_0x4061bf[_0x4f49('0x65')][_0x5e6103]['field']+'\x20'+_0x4061bf['rules'][_0x5e6103][_0x4f49('0x8b')]+(_0x1ae2c9(_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x8b')])?'\x20'+_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x68')]:'');}return _0x1bc18d+')';};var _0x29dbab={'where':{'id':_0x40991b[_0x4f49('0x54')]['id']}},_0x5f459b,_0x1d090f,_0x37d2f4,_0x5bcb36,_0x3f04fa;_0x29dbab=_[_0x4f49('0x43')]({},_0x29dbab,_0x40991b['options']);return db['AnalyticDefaultReport'][_0x4f49('0x4b')](_0x29dbab)[_0x4f49('0x26')](function(_0x200848){if(_0x200848){_0x5f459b=_0x200848;return _0x200848['getFields']();}return null;})[_0x4f49('0x26')](function(_0x48f4bc){if(_0x48f4bc){if(!_0x48f4bc[_0x4f49('0x3c')]){throw new db['Sequelize'][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0x1d090f=_0x48f4bc;return db['AnalyticMetric'][_0x4f49('0x47')]({'raw':!![]});}return null;})[_0x4f49('0x26')](function(_0x513bc9){if(_0x513bc9){_0x37d2f4=_[_0x4f49('0x6d')](_0x513bc9,'id');var _0x47567c;var _0x5f1538=squel[_0x4f49('0x6e')]();_0x5f1538[_0x4f49('0x6f')](_0x5f459b[_0x4f49('0x70')]);for(var _0xd91e48=0x0;_0xd91e48<_0x1d090f[_0x4f49('0x3c')];_0xd91e48+=0x1){_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x71')]?_0x37d2f4[_0x1d090f[_0xd91e48]['MetricId']][_0x4f49('0x72')]:_0x1d090f[_0xd91e48][_0x4f49('0x67')];_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x73')]?_['replace'](_0x5cd00a[_0x1d090f[_0xd91e48][_0x4f49('0x73')]],'%s',_0x47567c):_0x47567c;_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0xd876f1[_0x1d090f[_0xd91e48][_0x4f49('0x75')]],'%s',_0x47567c):_0x47567c;if(_0x1d090f[_0xd91e48][_0x4f49('0x8d')]){_0x5f1538[_0x4f49('0x66')](_0x47567c);}_0x1d090f[_0xd91e48][_0x4f49('0x76')]&&_0x5f1538['order'](_0x47567c,_0x1d090f[_0xd91e48][_0x4f49('0x76')]==='DESC'?![]:!![]);_0x5f1538['field'](_0x47567c,_0x1d090f[_0xd91e48][_0x4f49('0x78')]||_0x47567c);}if(_0x5f459b['joins']){_0x5f459b[_0x4f49('0x79')]=JSON[_0x4f49('0x7a')](_0x5f459b[_0x4f49('0x79')]);for(var _0x85eb3f=0x0;_0x85eb3f<_0x5f459b[_0x4f49('0x79')][_0x4f49('0x3c')];_0x85eb3f+=0x1){if(_0x5f459b['joins'][_0x85eb3f][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x1c7d87,_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x33')])&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7d')]&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f]['foreignTable']&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7e')]){_0x5f1538[_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x33')]](_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7b')],null,util[_0x4f49('0x75')](_0x4f49('0x7c'),_0x5f459b[_0x4f49('0x70')],_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7d')],_0x5f459b[_0x4f49('0x79')][_0x85eb3f]['foreignTable'],_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7e')]));}}}if(_0x5f459b['conditions']){_0x5f459b[_0x4f49('0x7f')]=JSON[_0x4f49('0x7a')](_0x5f459b[_0x4f49('0x7f')]);_0x5f1538[_0x4f49('0x40')](_0x541dc2(_0x5f459b[_0x4f49('0x7f')][_0x4f49('0x66')]));}_0x3f04fa=_0x5f1538['clone']();_0x5f1538['limit'](_0x4994b6);_0x5f1538['offset'](0x0);logger['debug'](_0x4f49('0x81'),_0x5f1538['toString']());return dbH[_0x4f49('0x82')][_0x4f49('0x36')](_0x5f1538[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')][_0x4f49('0x84')][_0x4f49('0xa2')]});}})['then'](function(){return{'sql':_0x3f04fa[_0x4f49('0x83')]()};})['then'](respondWithResult(_0x56290f,null))[_0x4f49('0x48')](handleError(_0x56290f,null));};
\ No newline at end of file