Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 0c3a7d3..98559e9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfcdf=['includes','IS\x20NULL','IS\x20NOT\x20NULL','rules','operator','group','condition','value','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','select','from','table','MetricId','metric','field','function','replace','format','groupBy','orderBy','DESC','alias','joins','parse','parentKey','foreignKey','foreignTable','conditions','clone','debug','Limited\x20Query:','toString','sequelize','SELECT','left_join','right_join','COUNT(DISTINCT\x20%s)','MIN(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','IS\x20EMPTY','IS\x20NOT\x20EMPTY','keyBy','output','web','fullPath','randomstring','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','endDate','startDate','info','Run\x20Query:','child_process','../../components/export/','savename','countTable','COUNT(*)','runReport','QueryTypes','html-pdf','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','dbH','status','end','json','count','offset','set','Content-Range','reject','save','update','then','get','DefaultReports','UserProfileResource','destroy','sendStatus','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','AnalyticDefaultReport','include','findAll','catch','show','keys','includeAll','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','preview','join','cross_join','SUM(%s)','COUNT(%s)','MAX(%s)','AVG(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)'];(function(_0x5d465b,_0x394249){var _0x5516c7=function(_0x3af0ab){while(--_0x3af0ab){_0x5d465b['push'](_0x5d465b['shift']());}};_0x5516c7(++_0x394249);}(_0xfcdf,0x192));var _0xffcd=function(_0x17e2b6,_0x66bf5a){_0x17e2b6=_0x17e2b6-0x0;var _0x24a738=_0xfcdf[_0x17e2b6];return _0x24a738;};'use strict';var pdf=require(_0xffcd('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xffcd('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xffcd('0x2'));var rp=require('request-promise');var moment=require(_0xffcd('0x3'));var BPromise=require(_0xffcd('0x4'));var Mustache=require(_0xffcd('0x5'));var util=require(_0xffcd('0x6'));var path=require(_0xffcd('0x7'));var sox=require(_0xffcd('0x8'));var csv=require(_0xffcd('0x9'));var ejs=require(_0xffcd('0xa'));var fs=require('fs');var _=require(_0xffcd('0xb'));var squel=require('squel');var crypto=require(_0xffcd('0xc'));var jsforce=require(_0xffcd('0xd'));var deskjs=require(_0xffcd('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xffcd('0xf'));var qs=require(_0xffcd('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xffcd('0x11'));var logger=require(_0xffcd('0x12'))(_0xffcd('0x13'));var utils=require('../../config/utils');var config=require(_0xffcd('0x14'));var licenseUtil=require(_0xffcd('0x15'));var db=require(_0xffcd('0x16'))['db'];var dbH=require(_0xffcd('0x16'))[_0xffcd('0x17')];function respondWithStatusCode(_0x3ab11c,_0x2d19d9){_0x2d19d9=_0x2d19d9||0xcc;return function(_0x163891){if(_0x163891){return _0x3ab11c['sendStatus'](_0x2d19d9);}return _0x3ab11c[_0xffcd('0x18')](_0x2d19d9)[_0xffcd('0x19')]();};}function respondWithResult(_0x567a8f,_0xc4c46a){_0xc4c46a=_0xc4c46a||0xc8;return function(_0x1ad5a0){if(_0x1ad5a0){return _0x567a8f[_0xffcd('0x18')](_0xc4c46a)[_0xffcd('0x1a')](_0x1ad5a0);}};}function respondWithFilteredResult(_0x523b27,_0x5b7b88){return function(_0x7d383c){if(_0x7d383c){var _0x3482e3=_0x7d383c[_0xffcd('0x1b')],_0x5ddee1=_0x5b7b88['offset'],_0x3f1346=_0x5b7b88[_0xffcd('0x1c')]+_0x5b7b88['limit'],_0x5bc45d;if(_0x3f1346>=_0x3482e3){_0x3f1346=_0x3482e3;_0x5bc45d=0xc8;}else{_0x5bc45d=0xce;}_0x523b27[_0xffcd('0x18')](_0x5bc45d);return _0x523b27[_0xffcd('0x1d')](_0xffcd('0x1e'),_0x5ddee1+'-'+_0x3f1346+'/'+_0x3482e3)[_0xffcd('0x1a')](_0x7d383c);}return null;};}function patchUpdates(_0x15ac36){return function(_0x27cde7){try{jsonpatch['apply'](_0x27cde7,_0x15ac36,!![]);}catch(_0x341b5e){return BPromise[_0xffcd('0x1f')](_0x341b5e);}return _0x27cde7[_0xffcd('0x20')]();};}function saveUpdates(_0x41c939,_0x307ec5){return function(_0x16035d){if(_0x16035d){return _0x16035d[_0xffcd('0x21')](_0x41c939)[_0xffcd('0x22')](function(_0x58ba96){return _0x58ba96;});}return null;};}function removeEntity(_0x394fea,_0x5e6d2c){return function(_0x5dfbde){if(_0x5dfbde){return _0x5dfbde['destroy']()[_0xffcd('0x22')](function(){var _0x5df0a1=_0x5dfbde[_0xffcd('0x23')]({'plain':!![]});var _0x457cd5=_0xffcd('0x24');return db[_0xffcd('0x25')][_0xffcd('0x26')]({'where':{'type':_0x457cd5,'resourceId':_0x5df0a1['id']}})['then'](function(){return _0x5dfbde;});})[_0xffcd('0x22')](function(){_0x394fea[_0xffcd('0x18')](0xcc)[_0xffcd('0x19')]();});}};}function handleEntityNotFound(_0x17d1c2,_0x352404){return function(_0xdd3098){if(!_0xdd3098){_0x17d1c2[_0xffcd('0x27')](0x194);}return _0xdd3098;};}function handleError(_0x40a177,_0x2eadb0){_0x2eadb0=_0x2eadb0||0x1f4;return function(_0xddfe9d){logger[_0xffcd('0x28')](_0xddfe9d[_0xffcd('0x29')]);if(_0xddfe9d[_0xffcd('0x2a')]){delete _0xddfe9d[_0xffcd('0x2a')];}_0x40a177[_0xffcd('0x18')](_0x2eadb0)[_0xffcd('0x2b')](_0xddfe9d);};}exports[_0xffcd('0x2c')]=function(_0x3e6f4e,_0x5c9f40){var _0x57626d={},_0x5daf52={},_0xe5f3c8={'count':0x0,'rows':[]};var _0x2dd4a2=_[_0xffcd('0x2d')](db['AnalyticDefaultReport'][_0xffcd('0x2e')],function(_0x491633){return{'name':_0x491633[_0xffcd('0x2f')],'type':_0x491633[_0xffcd('0x30')][_0xffcd('0x31')]};});_0x5daf52[_0xffcd('0x32')]=_['map'](_0x2dd4a2,_0xffcd('0x2a'));_0x5daf52[_0xffcd('0x33')]=_['keys'](_0x3e6f4e[_0xffcd('0x33')]);_0x5daf52[_0xffcd('0x34')]=_['intersection'](_0x5daf52['model'],_0x5daf52[_0xffcd('0x33')]);_0x57626d[_0xffcd('0x35')]=_[_0xffcd('0x36')](_0x5daf52[_0xffcd('0x32')],qs[_0xffcd('0x37')](_0x3e6f4e['query'][_0xffcd('0x37')]));_0x57626d[_0xffcd('0x35')]=_0x57626d[_0xffcd('0x35')][_0xffcd('0x38')]?_0x57626d[_0xffcd('0x35')]:_0x5daf52[_0xffcd('0x32')];if(!_0x3e6f4e['query'][_0xffcd('0x39')](_0xffcd('0x3a'))){_0x57626d[_0xffcd('0x3b')]=qs['limit'](_0x3e6f4e[_0xffcd('0x33')][_0xffcd('0x3b')]);_0x57626d['offset']=qs[_0xffcd('0x1c')](_0x3e6f4e[_0xffcd('0x33')][_0xffcd('0x1c')]);}_0x57626d[_0xffcd('0x3c')]=qs[_0xffcd('0x3d')](_0x3e6f4e[_0xffcd('0x33')][_0xffcd('0x3d')]);_0x57626d[_0xffcd('0x3e')]=qs[_0xffcd('0x34')](_[_0xffcd('0x3f')](_0x3e6f4e[_0xffcd('0x33')],_0x5daf52[_0xffcd('0x34')]),_0x2dd4a2);if(_0x3e6f4e[_0xffcd('0x33')][_0xffcd('0x40')]){_0x57626d[_0xffcd('0x3e')]=_[_0xffcd('0x41')](_0x57626d['where'],{'$or':_[_0xffcd('0x2d')](_0x2dd4a2,function(_0x3cf3af){if(_0x3cf3af[_0xffcd('0x30')]!==_0xffcd('0x42')){var _0xece42f={};_0xece42f[_0x3cf3af[_0xffcd('0x2a')]]={'$like':'%'+_0x3e6f4e[_0xffcd('0x33')][_0xffcd('0x40')]+'%'};return _0xece42f;}})});}_0x57626d=_['merge']({},_0x57626d,_0x3e6f4e[_0xffcd('0x43')]);var _0x2d8d6e={'where':_0x57626d[_0xffcd('0x3e')]};return db[_0xffcd('0x44')][_0xffcd('0x1b')](_0x2d8d6e)[_0xffcd('0x22')](function(_0x3af9ea){_0xe5f3c8[_0xffcd('0x1b')]=_0x3af9ea;if(_0x3e6f4e[_0xffcd('0x33')]['includeAll']){_0x57626d[_0xffcd('0x45')]=[{'all':!![]}];}return db[_0xffcd('0x44')][_0xffcd('0x46')](_0x57626d);})[_0xffcd('0x22')](function(_0x5c8729){_0xe5f3c8['rows']=_0x5c8729;return _0xe5f3c8;})[_0xffcd('0x22')](respondWithFilteredResult(_0x5c9f40,_0x57626d))[_0xffcd('0x47')](handleError(_0x5c9f40,null));};exports[_0xffcd('0x48')]=function(_0x245b17,_0x43f8be){var _0x54cfd9={'raw':!![],'where':{'id':_0x245b17['params']['id']}},_0x3a8c06={};_0x3a8c06[_0xffcd('0x32')]=_[_0xffcd('0x49')](db[_0xffcd('0x44')][_0xffcd('0x2e')]);_0x3a8c06[_0xffcd('0x33')]=_[_0xffcd('0x49')](_0x245b17[_0xffcd('0x33')]);_0x3a8c06['filters']=_[_0xffcd('0x36')](_0x3a8c06[_0xffcd('0x32')],_0x3a8c06[_0xffcd('0x33')]);_0x54cfd9['attributes']=_[_0xffcd('0x36')](_0x3a8c06['model'],qs[_0xffcd('0x37')](_0x245b17['query'][_0xffcd('0x37')]));_0x54cfd9['attributes']=_0x54cfd9[_0xffcd('0x35')]['length']?_0x54cfd9[_0xffcd('0x35')]:_0x3a8c06['model'];if(_0x245b17[_0xffcd('0x33')][_0xffcd('0x4a')]){_0x54cfd9[_0xffcd('0x45')]=[{'all':!![]}];}_0x54cfd9=_[_0xffcd('0x41')]({},_0x54cfd9,_0x245b17[_0xffcd('0x43')]);return db['AnalyticDefaultReport'][_0xffcd('0x4b')](_0x54cfd9)[_0xffcd('0x22')](handleEntityNotFound(_0x43f8be,null))[_0xffcd('0x22')](respondWithResult(_0x43f8be,null))[_0xffcd('0x47')](handleError(_0x43f8be,null));};exports[_0xffcd('0x4c')]=function(_0x75a687,_0x31f9a8){return db[_0xffcd('0x44')][_0xffcd('0x4c')](_0x75a687['body'],{})['then'](function(_0x29f3a1){var _0x4f7484=_0x75a687[_0xffcd('0x4d')][_0xffcd('0x23')]({'plain':!![]});if(!_0x4f7484)throw new Error(_0xffcd('0x4e'));if(_0x4f7484[_0xffcd('0x4f')]===_0xffcd('0x4d')){var _0x3a16ff=_0x29f3a1[_0xffcd('0x23')]({'plain':!![]});var _0x4d85c6='Reports';return db[_0xffcd('0x50')][_0xffcd('0x4b')]({'where':{'name':_0x4d85c6,'userProfileId':_0x4f7484[_0xffcd('0x51')]},'raw':!![]})[_0xffcd('0x22')](function(_0x2eed6e){if(_0x2eed6e&&_0x2eed6e[_0xffcd('0x52')]===0x0){return db['UserProfileResource'][_0xffcd('0x4c')]({'name':_0x3a16ff[_0xffcd('0x2a')],'resourceId':_0x3a16ff['id'],'type':_0xffcd('0x24'),'sectionId':_0x2eed6e['id']},{})[_0xffcd('0x22')](function(){return _0x29f3a1;});}else{return _0x29f3a1;}})[_0xffcd('0x47')](function(_0x1d9879){logger[_0xffcd('0x28')](_0xffcd('0x53'),_0x1d9879);throw _0x1d9879;});}return _0x29f3a1;})[_0xffcd('0x22')](respondWithResult(_0x31f9a8,0xc9))[_0xffcd('0x47')](handleError(_0x31f9a8,null));};exports[_0xffcd('0x21')]=function(_0x5f2b9f,_0x51e12b){if(_0x5f2b9f[_0xffcd('0x54')]['id']){delete _0x5f2b9f[_0xffcd('0x54')]['id'];}return db[_0xffcd('0x44')]['find']({'where':{'id':_0x5f2b9f[_0xffcd('0x55')]['id']}})[_0xffcd('0x22')](handleEntityNotFound(_0x51e12b,null))['then'](saveUpdates(_0x5f2b9f['body'],null))[_0xffcd('0x22')](respondWithResult(_0x51e12b,null))[_0xffcd('0x47')](handleError(_0x51e12b,null));};exports[_0xffcd('0x26')]=function(_0x481f2a,_0x1f6b05){return db[_0xffcd('0x44')][_0xffcd('0x4b')]({'where':{'id':_0x481f2a[_0xffcd('0x55')]['id']}})[_0xffcd('0x22')](handleEntityNotFound(_0x1f6b05,null))[_0xffcd('0x22')](removeEntity(_0x1f6b05,null))[_0xffcd('0x47')](handleError(_0x1f6b05,null));};exports[_0xffcd('0x56')]=function(_0x56fba7,_0x3e17eb){var _0x55a432=0xa;var _0x40bcd2=[_0xffcd('0x57'),'left_join','right_join',_0xffcd('0x58')];var _0x17e650={'SUM':_0xffcd('0x59'),'COUNT':_0xffcd('0x5a'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xffcd('0x5b'),'MIN':'MIN(%s)','AVG':_0xffcd('0x5c'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xffcd('0x5d'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x26fa60={'SEC_TO_TIME':_0xffcd('0x5e'),'DATE':_0xffcd('0x5f'),'HOUR':_0xffcd('0x60'),'ROUND':_0xffcd('0x61'),'UNIX_TIMESTAMP':_0xffcd('0x62')};var _0x547508=function(_0x4a99e1){return!_[_0xffcd('0x63')]([_0xffcd('0x64'),_0xffcd('0x65'),'IS\x20EMPTY','IS\x20NOT\x20EMPTY'],_0x4a99e1);};var _0x1c4704=function(_0xc61fcd){if(!_0xc61fcd||!_0xc61fcd['rules'][_0xffcd('0x38')]){return'';}for(var _0x19cdc6='(',_0x3acf82=0x0;_0x3acf82<_0xc61fcd[_0xffcd('0x66')][_0xffcd('0x38')];_0x3acf82+=0x1){_0x3acf82>0x0&&(_0x19cdc6+='\x20'+_0xc61fcd[_0xffcd('0x67')]+'\x20');_0x19cdc6+=_0xc61fcd[_0xffcd('0x66')][_0x3acf82]['group']?_0x1c4704(_0xc61fcd[_0xffcd('0x66')][_0x3acf82][_0xffcd('0x68')]):_0xc61fcd['rules'][_0x3acf82]['field']+'\x20'+_0xc61fcd[_0xffcd('0x66')][_0x3acf82][_0xffcd('0x69')]+(_0x547508(_0xc61fcd[_0xffcd('0x66')][_0x3acf82][_0xffcd('0x69')])?'\x20'+_0xc61fcd[_0xffcd('0x66')][_0x3acf82][_0xffcd('0x6a')]:'');}return _0x19cdc6+')';};var _0x68fb1b={'where':{'id':_0x56fba7['params']['id']}},_0x51b965,_0xc5e96b,_0xf86a2d,_0x585063,_0x5d71a1;_0x68fb1b=_['merge']({},_0x68fb1b,_0x56fba7[_0xffcd('0x43')]);return db['AnalyticDefaultReport']['find'](_0x68fb1b)[_0xffcd('0x22')](function(_0x422c46){if(_0x422c46){_0x51b965=_0x422c46;return _0x422c46[_0xffcd('0x6b')]();}return null;})[_0xffcd('0x22')](function(_0x419372){if(_0x419372){if(!_0x419372[_0xffcd('0x38')]){throw new db[(_0xffcd('0x6c'))][(_0xffcd('0x6d'))](_0xffcd('0x6e'),0x193);}_0xc5e96b=_0x419372;return db[_0xffcd('0x6f')][_0xffcd('0x46')]({'raw':!![]});}return null;})[_0xffcd('0x22')](function(_0x1aa9b1){if(_0x1aa9b1){_0xf86a2d=_['keyBy'](_0x1aa9b1,'id');var _0x3b8db6;var _0x208933=squel[_0xffcd('0x70')]();_0x208933[_0xffcd('0x71')](_0x51b965[_0xffcd('0x72')]);for(var _0x27bebe=0x0;_0x27bebe<_0xc5e96b[_0xffcd('0x38')];_0x27bebe+=0x1){_0x3b8db6=_0xc5e96b[_0x27bebe]['MetricId']?_0xf86a2d[_0xc5e96b[_0x27bebe][_0xffcd('0x73')]][_0xffcd('0x74')]:_0xc5e96b[_0x27bebe][_0xffcd('0x75')];_0x3b8db6=_0xc5e96b[_0x27bebe][_0xffcd('0x76')]?_[_0xffcd('0x77')](_0x17e650[_0xc5e96b[_0x27bebe][_0xffcd('0x76')]],'%s',_0x3b8db6):_0x3b8db6;_0x3b8db6=_0xc5e96b[_0x27bebe][_0xffcd('0x78')]?_[_0xffcd('0x77')](_0x26fa60[_0xc5e96b[_0x27bebe][_0xffcd('0x78')]],'%s',_0x3b8db6):_0x3b8db6;if(_0xc5e96b[_0x27bebe][_0xffcd('0x79')]){_0x208933['group'](_0x3b8db6);}_0xc5e96b[_0x27bebe]['orderBy']&&_0x208933[_0xffcd('0x3c')](_0x3b8db6,_0xc5e96b[_0x27bebe][_0xffcd('0x7a')]===_0xffcd('0x7b')?![]:!![]);_0x208933[_0xffcd('0x75')](_0x3b8db6,_0xc5e96b[_0x27bebe][_0xffcd('0x7c')]||_0x3b8db6);}if(_0x51b965[_0xffcd('0x7d')]){_0x51b965[_0xffcd('0x7d')]=JSON[_0xffcd('0x7e')](_0x51b965['joins']);for(var _0x1da839=0x0;_0x1da839<_0x51b965[_0xffcd('0x7d')][_0xffcd('0x38')];_0x1da839+=0x1){if(_0x51b965[_0xffcd('0x7d')][_0x1da839][_0xffcd('0x30')]&&_[_0xffcd('0x63')](_0x40bcd2,_0x51b965[_0xffcd('0x7d')][_0x1da839][_0xffcd('0x30')])&&_0x51b965[_0xffcd('0x7d')][_0x1da839][_0xffcd('0x7f')]&&_0x51b965[_0xffcd('0x7d')][_0x1da839]['foreignTable']&&_0x51b965[_0xffcd('0x7d')][_0x1da839][_0xffcd('0x80')]){_0x208933[_0x51b965['joins'][_0x1da839][_0xffcd('0x30')]](_0x51b965[_0xffcd('0x7d')][_0x1da839][_0xffcd('0x81')],null,util[_0xffcd('0x78')]('%s.%s\x20=\x20%s.%s',_0x51b965['table'],_0x51b965['joins'][_0x1da839][_0xffcd('0x7f')],_0x51b965[_0xffcd('0x7d')][_0x1da839][_0xffcd('0x81')],_0x51b965[_0xffcd('0x7d')][_0x1da839][_0xffcd('0x80')]));}}}if(_0x51b965[_0xffcd('0x82')]){_0x51b965['conditions']=JSON['parse'](_0x51b965[_0xffcd('0x82')]);_0x208933[_0xffcd('0x3e')](_0x1c4704(_0x51b965[_0xffcd('0x82')][_0xffcd('0x68')]));}_0x5d71a1=_0x208933[_0xffcd('0x83')]();_0x208933[_0xffcd('0x3b')](_0x55a432);_0x208933[_0xffcd('0x1c')](0x0);logger[_0xffcd('0x84')](_0xffcd('0x85'),_0x208933[_0xffcd('0x86')]());return dbH[_0xffcd('0x87')][_0xffcd('0x33')](_0x208933[_0xffcd('0x86')](),{'type':dbH[_0xffcd('0x87')]['QueryTypes'][_0xffcd('0x88')]});}})[_0xffcd('0x22')](respondWithResult(_0x3e17eb,null))['catch'](handleError(_0x3e17eb,null));};function runReport(_0x417a83,_0x1ed400,_0x9ae824){var _0x167f71=_0x1ed400['name'];var _0x3ecc9=0xa;var _0x31cf29=[_0xffcd('0x57'),_0xffcd('0x89'),_0xffcd('0x8a'),_0xffcd('0x58')];var _0x31006d={'SUM':'SUM(%s)','COUNT':_0xffcd('0x5a'),'COUNT DISTINCT':_0xffcd('0x8b'),'MAX':'MAX(%s)','MIN':_0xffcd('0x8c'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xffcd('0x8d'),'GROUP_CONCAT ASC':_0xffcd('0x5d'),'GROUP_CONCAT DESC':_0xffcd('0x8e')};var _0xde7729={'SEC_TO_TIME':_0xffcd('0x5e'),'DATE':_0xffcd('0x5f'),'HOUR':_0xffcd('0x60'),'ROUND':_0xffcd('0x61'),'UNIX_TIMESTAMP':_0xffcd('0x62')};var _0x5a045f=function(_0x6307da){return!_['includes'](['IS\x20NULL',_0xffcd('0x65'),_0xffcd('0x8f'),_0xffcd('0x90')],_0x6307da);};var _0x3f7317=function(_0x42c300){if(!_0x42c300||!_0x42c300[_0xffcd('0x66')][_0xffcd('0x38')]){return'';}for(var _0x3a60d4='(',_0x5326f8=0x0;_0x5326f8<_0x42c300[_0xffcd('0x66')][_0xffcd('0x38')];_0x5326f8+=0x1){_0x5326f8>0x0&&(_0x3a60d4+='\x20'+_0x42c300[_0xffcd('0x67')]+'\x20');_0x3a60d4+=_0x42c300[_0xffcd('0x66')][_0x5326f8][_0xffcd('0x68')]?_0x3f7317(_0x42c300['rules'][_0x5326f8][_0xffcd('0x68')]):_0x42c300[_0xffcd('0x66')][_0x5326f8]['field']+'\x20'+_0x42c300['rules'][_0x5326f8]['condition']+(_0x5a045f(_0x42c300['rules'][_0x5326f8]['condition'])?'\x20'+_0x42c300[_0xffcd('0x66')][_0x5326f8][_0xffcd('0x6a')]:'');}return _0x3a60d4+')';};var _0x2a88b4={'where':{'id':_0x417a83['id']}},_0x19f4f1,_0xfee257,_0xa55949,_0x54048f,_0x557357;_0x2a88b4=_[_0xffcd('0x41')]({},_0x2a88b4,_0x9ae824);return db[_0xffcd('0x44')][_0xffcd('0x4b')](_0x2a88b4)[_0xffcd('0x22')](function(_0x2612ed){if(_0x2612ed){_0x19f4f1=_0x2612ed;return _0x2612ed[_0xffcd('0x6b')]();}return null;})[_0xffcd('0x22')](function(_0x3d43ce){if(_0x3d43ce){if(!_0x3d43ce[_0xffcd('0x38')]){throw new db[(_0xffcd('0x6c'))][(_0xffcd('0x6d'))](_0xffcd('0x6e'),0x193);}_0xfee257=_0x3d43ce;return db[_0xffcd('0x6f')][_0xffcd('0x46')]({'raw':!![]});}return null;})[_0xffcd('0x22')](function(_0x21d1c){if(_0x21d1c){_0xa55949=_[_0xffcd('0x91')](_0x21d1c,'id');var _0x4e779d;var _0x4f5465=squel[_0xffcd('0x70')]();_0x4f5465['from'](_0x19f4f1[_0xffcd('0x72')]);for(var _0x3fb79c=0x0;_0x3fb79c<_0xfee257['length'];_0x3fb79c+=0x1){_0x4e779d=_0xfee257[_0x3fb79c]['MetricId']?_0xa55949[_0xfee257[_0x3fb79c][_0xffcd('0x73')]]['metric']:_0xfee257[_0x3fb79c][_0xffcd('0x75')];_0x4e779d=_0xfee257[_0x3fb79c][_0xffcd('0x76')]?_[_0xffcd('0x77')](_0x31006d[_0xfee257[_0x3fb79c][_0xffcd('0x76')]],'%s',_0x4e779d):_0x4e779d;_0x4e779d=_0xfee257[_0x3fb79c][_0xffcd('0x78')]?_[_0xffcd('0x77')](_0xde7729[_0xfee257[_0x3fb79c][_0xffcd('0x78')]],'%s',_0x4e779d):_0x4e779d;if(_0xfee257[_0x3fb79c][_0xffcd('0x79')]){_0x4f5465['group'](_0x4e779d);}_0xfee257[_0x3fb79c][_0xffcd('0x7a')]&&_0x4f5465['order'](_0x4e779d,_0xfee257[_0x3fb79c][_0xffcd('0x7a')]==='DESC'?![]:!![]);_0x4f5465[_0xffcd('0x75')](_0x4e779d,_0xfee257[_0x3fb79c][_0xffcd('0x7c')]||_0x4e779d);}if(_0x19f4f1[_0xffcd('0x7d')]){_0x19f4f1['joins']=JSON['parse'](_0x19f4f1[_0xffcd('0x7d')]);for(var _0x13f727=0x0;_0x13f727<_0x19f4f1[_0xffcd('0x7d')]['length'];_0x13f727+=0x1){if(_0x19f4f1['joins'][_0x13f727][_0xffcd('0x30')]&&_[_0xffcd('0x63')](_0x31cf29,_0x19f4f1[_0xffcd('0x7d')][_0x13f727][_0xffcd('0x30')])&&_0x19f4f1[_0xffcd('0x7d')][_0x13f727][_0xffcd('0x7f')]&&_0x19f4f1[_0xffcd('0x7d')][_0x13f727][_0xffcd('0x81')]&&_0x19f4f1[_0xffcd('0x7d')][_0x13f727][_0xffcd('0x80')]){_0x4f5465[_0x19f4f1[_0xffcd('0x7d')][_0x13f727][_0xffcd('0x30')]](_0x19f4f1[_0xffcd('0x7d')][_0x13f727]['foreignTable'],null,util['format']('%s.%s\x20=\x20%s.%s',_0x19f4f1[_0xffcd('0x72')],_0x19f4f1[_0xffcd('0x7d')][_0x13f727]['parentKey'],_0x19f4f1['joins'][_0x13f727][_0xffcd('0x81')],_0x19f4f1['joins'][_0x13f727][_0xffcd('0x80')]));}}}if(_0x19f4f1[_0xffcd('0x82')]){_0x19f4f1['conditions']=JSON[_0xffcd('0x7e')](_0x19f4f1[_0xffcd('0x82')]);_0x4f5465[_0xffcd('0x3e')](_0x3f7317(_0x19f4f1[_0xffcd('0x82')][_0xffcd('0x68')]));}_0x557357=_0x4f5465[_0xffcd('0x83')]();_0x4f5465['limit'](_0x3ecc9);_0x4f5465[_0xffcd('0x1c')](0x0);return;}})[_0xffcd('0x22')](function(){if(_0x1ed400[_0xffcd('0x92')]===_0xffcd('0x93')){return null;}var _0x222147=_['merge'](_0x1ed400,{'name':_0x1ed400[_0xffcd('0x94')]||_0x1ed400[_0xffcd('0x2a')]||_0x19f4f1[_0xffcd('0x2a')],'basename':_0x167f71,'savename':util[_0xffcd('0x78')]('%s-%s.%s',_0x1ed400[_0xffcd('0x2a')]||_0x19f4f1[_0xffcd('0x2a')],require(_0xffcd('0x95'))[_0xffcd('0x96')](0x4),_0x1ed400['output']||_0xffcd('0x97')),'reportId':_0x19f4f1['id'],'reportType':_0xffcd('0x98')});return db[_0xffcd('0x99')][_0xffcd('0x4c')](_0x222147,{'raw':!![]});})['then'](function(_0x423dcf){if(_0x19f4f1['table']===_0xffcd('0x9a')){_0x557357[_0xffcd('0x3e')](_0x19f4f1[_0xffcd('0x72')]+_0xffcd('0x9b'),_0x1ed400['startDate'],_0x1ed400[_0xffcd('0x9c')]);}else{_0x557357['where'](_0x19f4f1[_0xffcd('0x72')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x1ed400[_0xffcd('0x9d')],_0x1ed400[_0xffcd('0x9c')]);}if(_0x423dcf){logger[_0xffcd('0x9e')](_0xffcd('0x9f'),_0x557357['toString']());require(_0xffcd('0xa0'))['fork'](path[_0xffcd('0x57')](__dirname,_0xffcd('0xa1'),_0x423dcf['output']),[_0x423dcf['id'],_0x557357[_0xffcd('0x86')](),path['join'](__dirname,'../../files/reports',_0x423dcf[_0xffcd('0xa2')]),_0x167f71]);return _0x423dcf;}else{var _0x51bfd2=squel[_0xffcd('0x70')]();_0x51bfd2['from']('('+_0x557357[_0xffcd('0x86')]()+')',_0xffcd('0xa3'));_0x51bfd2[_0xffcd('0x75')](_0xffcd('0xa4'),_0xffcd('0x1b'));_0x557357[_0xffcd('0x3b')](_0x1ed400[_0xffcd('0x3b')]||_0x3ecc9);_0x557357['offset'](_0x1ed400[_0xffcd('0x1c')]||0x0);return dbH[_0xffcd('0x87')][_0xffcd('0x33')](_0x51bfd2['toString'](),{'type':dbH[_0xffcd('0x87')]['QueryTypes'][_0xffcd('0x88')]})[_0xffcd('0x22')](function(_0x418704){if(!_0x418704[_0xffcd('0x38')]){_0x54048f=0x0;}else{_0x54048f=_0x418704[0x0][_0xffcd('0x1b')]||0x0;}return dbH[_0xffcd('0x87')][_0xffcd('0x33')](_0x557357['toString'](),{'type':dbH['sequelize']['QueryTypes'][_0xffcd('0x88')]});})[_0xffcd('0x22')](function(_0xcc628e){return{'rows':_0xcc628e||[],'count':_0x54048f};});}});}exports['run']=function(_0x3c460f,_0xbcc5ba){return runReport(_0x3c460f[_0xffcd('0x55')],_0x3c460f[_0xffcd('0x33')],_0x3c460f['options'])[_0xffcd('0x22')](respondWithResult(_0xbcc5ba,null))[_0xffcd('0x47')](handleError(_0xbcc5ba,null));};exports[_0xffcd('0xa5')]=runReport;exports[_0xffcd('0x33')]=function(_0x2b54c5,_0x4241bb){var _0x2d6594=0xa;var _0x3f6a4a=[_0xffcd('0x57'),_0xffcd('0x89'),_0xffcd('0x8a'),'cross_join'];var _0x13dd6f={'SUM':'SUM(%s)','COUNT':_0xffcd('0x5a'),'COUNT DISTINCT':_0xffcd('0x8b'),'MAX':_0xffcd('0x5b'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xffcd('0x8d'),'GROUP_CONCAT ASC':_0xffcd('0x5d'),'GROUP_CONCAT DESC':_0xffcd('0x8e')};var _0xcc788f={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':'DATE(%s)','HOUR':'HOUR(%s)','ROUND':_0xffcd('0x61'),'UNIX_TIMESTAMP':_0xffcd('0x62')};var _0x2eaff8=function(_0x2ef3ea){return!_[_0xffcd('0x63')]([_0xffcd('0x64'),_0xffcd('0x65'),_0xffcd('0x8f'),_0xffcd('0x90')],_0x2ef3ea);};var _0x2ed880=function(_0x1ab19d){if(!_0x1ab19d||!_0x1ab19d['rules']['length']){return'';}for(var _0xd60e35='(',_0x5f2d16=0x0;_0x5f2d16<_0x1ab19d[_0xffcd('0x66')][_0xffcd('0x38')];_0x5f2d16+=0x1){_0x5f2d16>0x0&&(_0xd60e35+='\x20'+_0x1ab19d['operator']+'\x20');_0xd60e35+=_0x1ab19d[_0xffcd('0x66')][_0x5f2d16][_0xffcd('0x68')]?_0x2ed880(_0x1ab19d[_0xffcd('0x66')][_0x5f2d16][_0xffcd('0x68')]):_0x1ab19d[_0xffcd('0x66')][_0x5f2d16][_0xffcd('0x75')]+'\x20'+_0x1ab19d['rules'][_0x5f2d16][_0xffcd('0x69')]+(_0x2eaff8(_0x1ab19d['rules'][_0x5f2d16][_0xffcd('0x69')])?'\x20'+_0x1ab19d[_0xffcd('0x66')][_0x5f2d16][_0xffcd('0x6a')]:'');}return _0xd60e35+')';};var _0x3c9117={'where':{'id':_0x2b54c5[_0xffcd('0x55')]['id']}},_0x1d9366,_0x1c8e32,_0x1df2a9,_0x5434b8,_0x5f506f;_0x3c9117=_[_0xffcd('0x41')]({},_0x3c9117,_0x2b54c5[_0xffcd('0x43')]);return db['AnalyticDefaultReport'][_0xffcd('0x4b')](_0x3c9117)['then'](function(_0x367ec6){if(_0x367ec6){_0x1d9366=_0x367ec6;return _0x367ec6[_0xffcd('0x6b')]();}return null;})[_0xffcd('0x22')](function(_0x2d4a28){if(_0x2d4a28){if(!_0x2d4a28[_0xffcd('0x38')]){throw new db[(_0xffcd('0x6c'))][(_0xffcd('0x6d'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x1c8e32=_0x2d4a28;return db[_0xffcd('0x6f')]['findAll']({'raw':!![]});}return null;})[_0xffcd('0x22')](function(_0x578846){if(_0x578846){_0x1df2a9=_[_0xffcd('0x91')](_0x578846,'id');var _0x582381;var _0x2b9b89=squel[_0xffcd('0x70')]();_0x2b9b89[_0xffcd('0x71')](_0x1d9366['table']);for(var _0x2145c6=0x0;_0x2145c6<_0x1c8e32['length'];_0x2145c6+=0x1){_0x582381=_0x1c8e32[_0x2145c6][_0xffcd('0x73')]?_0x1df2a9[_0x1c8e32[_0x2145c6][_0xffcd('0x73')]][_0xffcd('0x74')]:_0x1c8e32[_0x2145c6][_0xffcd('0x75')];_0x582381=_0x1c8e32[_0x2145c6][_0xffcd('0x76')]?_['replace'](_0x13dd6f[_0x1c8e32[_0x2145c6][_0xffcd('0x76')]],'%s',_0x582381):_0x582381;_0x582381=_0x1c8e32[_0x2145c6][_0xffcd('0x78')]?_[_0xffcd('0x77')](_0xcc788f[_0x1c8e32[_0x2145c6]['format']],'%s',_0x582381):_0x582381;if(_0x1c8e32[_0x2145c6][_0xffcd('0x79')]){_0x2b9b89[_0xffcd('0x68')](_0x582381);}_0x1c8e32[_0x2145c6][_0xffcd('0x7a')]&&_0x2b9b89[_0xffcd('0x3c')](_0x582381,_0x1c8e32[_0x2145c6]['orderBy']===_0xffcd('0x7b')?![]:!![]);_0x2b9b89[_0xffcd('0x75')](_0x582381,_0x1c8e32[_0x2145c6][_0xffcd('0x7c')]||_0x582381);}if(_0x1d9366[_0xffcd('0x7d')]){_0x1d9366[_0xffcd('0x7d')]=JSON[_0xffcd('0x7e')](_0x1d9366[_0xffcd('0x7d')]);for(var _0x270e04=0x0;_0x270e04<_0x1d9366['joins'][_0xffcd('0x38')];_0x270e04+=0x1){if(_0x1d9366[_0xffcd('0x7d')][_0x270e04][_0xffcd('0x30')]&&_[_0xffcd('0x63')](_0x3f6a4a,_0x1d9366[_0xffcd('0x7d')][_0x270e04][_0xffcd('0x30')])&&_0x1d9366['joins'][_0x270e04][_0xffcd('0x7f')]&&_0x1d9366[_0xffcd('0x7d')][_0x270e04]['foreignTable']&&_0x1d9366['joins'][_0x270e04][_0xffcd('0x80')]){_0x2b9b89[_0x1d9366[_0xffcd('0x7d')][_0x270e04]['type']](_0x1d9366[_0xffcd('0x7d')][_0x270e04][_0xffcd('0x81')],null,util[_0xffcd('0x78')]('%s.%s\x20=\x20%s.%s',_0x1d9366[_0xffcd('0x72')],_0x1d9366['joins'][_0x270e04]['parentKey'],_0x1d9366[_0xffcd('0x7d')][_0x270e04]['foreignTable'],_0x1d9366[_0xffcd('0x7d')][_0x270e04][_0xffcd('0x80')]));}}}if(_0x1d9366[_0xffcd('0x82')]){_0x1d9366[_0xffcd('0x82')]=JSON[_0xffcd('0x7e')](_0x1d9366[_0xffcd('0x82')]);_0x2b9b89[_0xffcd('0x3e')](_0x2ed880(_0x1d9366[_0xffcd('0x82')][_0xffcd('0x68')]));}_0x5f506f=_0x2b9b89[_0xffcd('0x83')]();_0x2b9b89[_0xffcd('0x3b')](_0x2d6594);_0x2b9b89['offset'](0x0);logger[_0xffcd('0x84')](_0xffcd('0x85'),_0x2b9b89['toString']());return dbH[_0xffcd('0x87')][_0xffcd('0x33')](_0x2b9b89[_0xffcd('0x86')](),{'type':dbH['sequelize'][_0xffcd('0xa6')]['SELECT']});}})['then'](function(){return{'sql':_0x5f506f[_0xffcd('0x86')]()};})[_0xffcd('0x22')](respondWithResult(_0x4241bb,null))['catch'](handleError(_0x4241bb,null));};
\ No newline at end of file
+var _0xabce=['where','findAll','show','includeAll','options','find','catch','create','body','user','role','Reports','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','preview','join','left_join','right_join','cross_join','SUM(%s)','COUNT(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','DATE(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','condition','value','getFields','Please\x20insert\x20at\x20least\x20one\x20field','table','MetricId','field','function','replace','format','groupBy','orderBy','joins','parse','includes','parentKey','foreignTable','%s.%s\x20=\x20%s.%s','conditions','debug','Limited\x20Query:','toString','SELECT','COUNT(DISTINCT\x20%s)','MAX(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','ValidationErrorItem','AnalyticMetric','keyBy','select','metric','DESC','foreignKey','output','web','%s-%s.%s','default','cdr','startDate','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','from','countTable','COUNT(*)','sequelize','QueryTypes','run','runReport','Sequelize','alias','clone','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','status','offset','limit','undefined','count','set','json','apply','save','update','then','get','DefaultReports','UserProfileResource','destroy','error','stack','name','send','index','map','AnalyticDefaultReport','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','filter','merge'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xabce,0x103));var _0xeabc=function(_0x1035c1,_0x2d8583){_0x1035c1=_0x1035c1-0x0;var _0x308d67=_0xabce[_0x1035c1];return _0x308d67;};'use strict';var emlformat=require(_0xeabc('0x0'));var rimraf=require(_0xeabc('0x1'));var zipdir=require(_0xeabc('0x2'));var jsonpatch=require(_0xeabc('0x3'));var rp=require(_0xeabc('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xeabc('0x5'));var util=require(_0xeabc('0x6'));var path=require(_0xeabc('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xeabc('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xeabc('0x9'));var squel=require('squel');var crypto=require(_0xeabc('0xa'));var jsforce=require(_0xeabc('0xb'));var deskjs=require(_0xeabc('0xc'));var toCsv=require('to-csv');var querystring=require(_0xeabc('0xd'));var Papa=require(_0xeabc('0xe'));var Redis=require(_0xeabc('0xf'));var authService=require(_0xeabc('0x10'));var qs=require(_0xeabc('0x11'));var as=require(_0xeabc('0x12'));var hardwareService=require(_0xeabc('0x13'));var logger=require(_0xeabc('0x14'))(_0xeabc('0x15'));var utils=require(_0xeabc('0x16'));var config=require(_0xeabc('0x17'));var licenseUtil=require(_0xeabc('0x18'));var db=require(_0xeabc('0x19'))['db'];var dbH=require(_0xeabc('0x19'))[_0xeabc('0x1a')];function respondWithStatusCode(_0xcfbf06,_0x53df9c){_0x53df9c=_0x53df9c||0xcc;return function(_0x235c2d){if(_0x235c2d){return _0xcfbf06[_0xeabc('0x1b')](_0x53df9c);}return _0xcfbf06[_0xeabc('0x1c')](_0x53df9c)['end']();};}function respondWithResult(_0x5f4ee8,_0x3170ea){_0x3170ea=_0x3170ea||0xc8;return function(_0x3ae954){if(_0x3ae954){return _0x5f4ee8[_0xeabc('0x1c')](_0x3170ea)['json'](_0x3ae954);}};}function respondWithFilteredResult(_0xf913d7,_0x638976){return function(_0x49f2d8){if(_0x49f2d8){var _0x53fe28=typeof _0x638976[_0xeabc('0x1d')]==='undefined'&&typeof _0x638976[_0xeabc('0x1e')]===_0xeabc('0x1f');var _0x58a3c0=_0x49f2d8[_0xeabc('0x20')];var _0x31dd53=_0x53fe28?0x0:_0x638976[_0xeabc('0x1d')];var _0x384be5=_0x53fe28?_0x49f2d8[_0xeabc('0x20')]:_0x638976['offset']+_0x638976[_0xeabc('0x1e')];var _0x4d68ea;if(_0x384be5>=_0x58a3c0){_0x384be5=_0x58a3c0;_0x4d68ea=0xc8;}else{_0x4d68ea=0xce;}_0xf913d7[_0xeabc('0x1c')](_0x4d68ea);return _0xf913d7[_0xeabc('0x21')]('Content-Range',_0x31dd53+'-'+_0x384be5+'/'+_0x58a3c0)[_0xeabc('0x22')](_0x49f2d8);}return null;};}function patchUpdates(_0x41d67a){return function(_0x254590){try{jsonpatch[_0xeabc('0x23')](_0x254590,_0x41d67a,!![]);}catch(_0x3c9611){return BPromise['reject'](_0x3c9611);}return _0x254590[_0xeabc('0x24')]();};}function saveUpdates(_0x10c675,_0x91ab00){return function(_0x5bdd57){if(_0x5bdd57){return _0x5bdd57[_0xeabc('0x25')](_0x10c675)[_0xeabc('0x26')](function(_0x214953){return _0x214953;});}return null;};}function removeEntity(_0x319119,_0x5b8838){return function(_0x109e1d){if(_0x109e1d){return _0x109e1d['destroy']()[_0xeabc('0x26')](function(){var _0x4d4e29=_0x109e1d[_0xeabc('0x27')]({'plain':!![]});var _0x12acbd=_0xeabc('0x28');return db[_0xeabc('0x29')][_0xeabc('0x2a')]({'where':{'type':_0x12acbd,'resourceId':_0x4d4e29['id']}})[_0xeabc('0x26')](function(){return _0x109e1d;});})[_0xeabc('0x26')](function(){_0x319119['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x459c8a,_0x5bf8f2){return function(_0x3c1b5b){if(!_0x3c1b5b){_0x459c8a[_0xeabc('0x1b')](0x194);}return _0x3c1b5b;};}function handleError(_0x48fb52,_0x2163e6){_0x2163e6=_0x2163e6||0x1f4;return function(_0x38572d){logger[_0xeabc('0x2b')](_0x38572d[_0xeabc('0x2c')]);if(_0x38572d[_0xeabc('0x2d')]){delete _0x38572d[_0xeabc('0x2d')];}_0x48fb52[_0xeabc('0x1c')](_0x2163e6)[_0xeabc('0x2e')](_0x38572d);};}exports[_0xeabc('0x2f')]=function(_0x5ebb86,_0x5b34dd){var _0x5bb1f1={},_0x2f03e8={},_0x2d027e={'count':0x0,'rows':[]};var _0x98b445=_[_0xeabc('0x30')](db[_0xeabc('0x31')][_0xeabc('0x32')],function(_0x61c0af){return{'name':_0x61c0af['fieldName'],'type':_0x61c0af[_0xeabc('0x33')][_0xeabc('0x34')]};});_0x2f03e8[_0xeabc('0x35')]=_['map'](_0x98b445,_0xeabc('0x2d'));_0x2f03e8[_0xeabc('0x36')]=_[_0xeabc('0x37')](_0x5ebb86['query']);_0x2f03e8[_0xeabc('0x38')]=_[_0xeabc('0x39')](_0x2f03e8[_0xeabc('0x35')],_0x2f03e8['query']);_0x5bb1f1[_0xeabc('0x3a')]=_[_0xeabc('0x39')](_0x2f03e8['model'],qs['fields'](_0x5ebb86[_0xeabc('0x36')][_0xeabc('0x3b')]));_0x5bb1f1['attributes']=_0x5bb1f1[_0xeabc('0x3a')][_0xeabc('0x3c')]?_0x5bb1f1[_0xeabc('0x3a')]:_0x2f03e8[_0xeabc('0x35')];if(!_0x5ebb86[_0xeabc('0x36')]['hasOwnProperty'](_0xeabc('0x3d'))){_0x5bb1f1['limit']=qs[_0xeabc('0x1e')](_0x5ebb86[_0xeabc('0x36')][_0xeabc('0x1e')]);_0x5bb1f1['offset']=qs['offset'](_0x5ebb86[_0xeabc('0x36')]['offset']);}_0x5bb1f1[_0xeabc('0x3e')]=qs['sort'](_0x5ebb86['query']['sort']);_0x5bb1f1['where']=qs[_0xeabc('0x38')](_['pick'](_0x5ebb86[_0xeabc('0x36')],_0x2f03e8[_0xeabc('0x38')]),_0x98b445);if(_0x5ebb86['query'][_0xeabc('0x3f')]){_0x5bb1f1['where']=_[_0xeabc('0x40')](_0x5bb1f1['where'],{'$or':_[_0xeabc('0x30')](_0x98b445,function(_0xf1b7ef){if(_0xf1b7ef[_0xeabc('0x33')]!=='VIRTUAL'){var _0x5a00d0={};_0x5a00d0[_0xf1b7ef['name']]={'$like':'%'+_0x5ebb86[_0xeabc('0x36')][_0xeabc('0x3f')]+'%'};return _0x5a00d0;}})});}_0x5bb1f1=_[_0xeabc('0x40')]({},_0x5bb1f1,_0x5ebb86['options']);var _0x4f1897={'where':_0x5bb1f1[_0xeabc('0x41')]};return db[_0xeabc('0x31')]['count'](_0x4f1897)[_0xeabc('0x26')](function(_0x5e0b78){_0x2d027e[_0xeabc('0x20')]=_0x5e0b78;if(_0x5ebb86['query']['includeAll']){_0x5bb1f1['include']=[{'all':!![]}];}return db[_0xeabc('0x31')][_0xeabc('0x42')](_0x5bb1f1);})[_0xeabc('0x26')](function(_0x3eeeb5){_0x2d027e['rows']=_0x3eeeb5;return _0x2d027e;})[_0xeabc('0x26')](respondWithFilteredResult(_0x5b34dd,_0x5bb1f1))['catch'](handleError(_0x5b34dd,null));};exports[_0xeabc('0x43')]=function(_0x1a4bbe,_0x3a7807){var _0x17a0df={'raw':!![],'where':{'id':_0x1a4bbe['params']['id']}},_0xc849c9={};_0xc849c9['model']=_[_0xeabc('0x37')](db['AnalyticDefaultReport'][_0xeabc('0x32')]);_0xc849c9[_0xeabc('0x36')]=_['keys'](_0x1a4bbe[_0xeabc('0x36')]);_0xc849c9[_0xeabc('0x38')]=_[_0xeabc('0x39')](_0xc849c9[_0xeabc('0x35')],_0xc849c9[_0xeabc('0x36')]);_0x17a0df[_0xeabc('0x3a')]=_[_0xeabc('0x39')](_0xc849c9['model'],qs[_0xeabc('0x3b')](_0x1a4bbe[_0xeabc('0x36')][_0xeabc('0x3b')]));_0x17a0df[_0xeabc('0x3a')]=_0x17a0df[_0xeabc('0x3a')][_0xeabc('0x3c')]?_0x17a0df[_0xeabc('0x3a')]:_0xc849c9[_0xeabc('0x35')];if(_0x1a4bbe[_0xeabc('0x36')][_0xeabc('0x44')]){_0x17a0df['include']=[{'all':!![]}];}_0x17a0df=_[_0xeabc('0x40')]({},_0x17a0df,_0x1a4bbe[_0xeabc('0x45')]);return db[_0xeabc('0x31')][_0xeabc('0x46')](_0x17a0df)[_0xeabc('0x26')](handleEntityNotFound(_0x3a7807,null))[_0xeabc('0x26')](respondWithResult(_0x3a7807,null))[_0xeabc('0x47')](handleError(_0x3a7807,null));};exports['create']=function(_0x766743,_0x32e09b){return db[_0xeabc('0x31')][_0xeabc('0x48')](_0x766743[_0xeabc('0x49')],{})['then'](function(_0x305946){var _0x2b2b9c=_0x766743[_0xeabc('0x4a')][_0xeabc('0x27')]({'plain':!![]});if(!_0x2b2b9c)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2b2b9c[_0xeabc('0x4b')]===_0xeabc('0x4a')){var _0x568847=_0x305946[_0xeabc('0x27')]({'plain':!![]});var _0x5a0d4d=_0xeabc('0x4c');return db['UserProfileSection'][_0xeabc('0x46')]({'where':{'name':_0x5a0d4d,'userProfileId':_0x2b2b9c[_0xeabc('0x4d')]},'raw':!![]})[_0xeabc('0x26')](function(_0x1524c3){if(_0x1524c3&&_0x1524c3[_0xeabc('0x4e')]===0x0){return db[_0xeabc('0x29')][_0xeabc('0x48')]({'name':_0x568847[_0xeabc('0x2d')],'resourceId':_0x568847['id'],'type':_0xeabc('0x28'),'sectionId':_0x1524c3['id']},{})[_0xeabc('0x26')](function(){return _0x305946;});}else{return _0x305946;}})['catch'](function(_0x180a14){logger[_0xeabc('0x2b')](_0xeabc('0x4f'),_0x180a14);throw _0x180a14;});}return _0x305946;})[_0xeabc('0x26')](respondWithResult(_0x32e09b,0xc9))['catch'](handleError(_0x32e09b,null));};exports[_0xeabc('0x25')]=function(_0x392913,_0x10d56f){if(_0x392913[_0xeabc('0x49')]['id']){delete _0x392913['body']['id'];}return db[_0xeabc('0x31')][_0xeabc('0x46')]({'where':{'id':_0x392913[_0xeabc('0x50')]['id']}})[_0xeabc('0x26')](handleEntityNotFound(_0x10d56f,null))[_0xeabc('0x26')](saveUpdates(_0x392913[_0xeabc('0x49')],null))[_0xeabc('0x26')](respondWithResult(_0x10d56f,null))[_0xeabc('0x47')](handleError(_0x10d56f,null));};exports[_0xeabc('0x2a')]=function(_0x58ab08,_0x4546c4){return db['AnalyticDefaultReport']['find']({'where':{'id':_0x58ab08['params']['id']}})[_0xeabc('0x26')](handleEntityNotFound(_0x4546c4,null))[_0xeabc('0x26')](removeEntity(_0x4546c4,null))[_0xeabc('0x47')](handleError(_0x4546c4,null));};exports[_0xeabc('0x51')]=function(_0xe89728,_0x2f78f3){var _0x4a2ad6=0xa;var _0x4358d7=[_0xeabc('0x52'),_0xeabc('0x53'),_0xeabc('0x54'),_0xeabc('0x55')];var _0x2c7b4e={'SUM':_0xeabc('0x56'),'COUNT':_0xeabc('0x57'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':'MAX(%s)','MIN':_0xeabc('0x58'),'AVG':_0xeabc('0x59'),'GROUP_CONCAT':_0xeabc('0x5a'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xeabc('0x5b')};var _0x536f42={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xeabc('0x5c'),'HOUR':_0xeabc('0x5d'),'ROUND':_0xeabc('0x5e'),'UNIX_TIMESTAMP':_0xeabc('0x5f')};var _0x26c784=function(_0xc2ef0c){return!_['includes']([_0xeabc('0x60'),_0xeabc('0x61'),_0xeabc('0x62'),_0xeabc('0x63')],_0xc2ef0c);};var _0x11cc1f=function(_0x514787){if(!_0x514787||!_0x514787['rules'][_0xeabc('0x3c')]){return'';}for(var _0x7b659f='(',_0x1b6675=0x0;_0x1b6675<_0x514787[_0xeabc('0x64')][_0xeabc('0x3c')];_0x1b6675+=0x1){_0x1b6675>0x0&&(_0x7b659f+='\x20'+_0x514787[_0xeabc('0x65')]+'\x20');_0x7b659f+=_0x514787[_0xeabc('0x64')][_0x1b6675][_0xeabc('0x66')]?_0x11cc1f(_0x514787[_0xeabc('0x64')][_0x1b6675]['group']):_0x514787[_0xeabc('0x64')][_0x1b6675]['field']+'\x20'+_0x514787[_0xeabc('0x64')][_0x1b6675][_0xeabc('0x67')]+(_0x26c784(_0x514787[_0xeabc('0x64')][_0x1b6675][_0xeabc('0x67')])?'\x20'+_0x514787[_0xeabc('0x64')][_0x1b6675][_0xeabc('0x68')]:'');}return _0x7b659f+')';};var _0xf48062={'where':{'id':_0xe89728[_0xeabc('0x50')]['id']}},_0xb59a2a,_0x5d4bc2,_0x24d0e5,_0x5702cb,_0x3fa31b;_0xf48062=_[_0xeabc('0x40')]({},_0xf48062,_0xe89728[_0xeabc('0x45')]);return db['AnalyticDefaultReport'][_0xeabc('0x46')](_0xf48062)['then'](function(_0x54e7d6){if(_0x54e7d6){_0xb59a2a=_0x54e7d6;return _0x54e7d6[_0xeabc('0x69')]();}return null;})[_0xeabc('0x26')](function(_0x23270a){if(_0x23270a){if(!_0x23270a[_0xeabc('0x3c')]){throw new db['Sequelize']['ValidationErrorItem'](_0xeabc('0x6a'),0x193);}_0x5d4bc2=_0x23270a;return db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0xeabc('0x26')](function(_0x4f1a4f){if(_0x4f1a4f){_0x24d0e5=_['keyBy'](_0x4f1a4f,'id');var _0xa44f2d;var _0x1c84b5=squel['select']();_0x1c84b5['from'](_0xb59a2a[_0xeabc('0x6b')]);for(var _0x5d183a=0x0;_0x5d183a<_0x5d4bc2[_0xeabc('0x3c')];_0x5d183a+=0x1){_0xa44f2d=_0x5d4bc2[_0x5d183a][_0xeabc('0x6c')]?_0x24d0e5[_0x5d4bc2[_0x5d183a]['MetricId']]['metric']:_0x5d4bc2[_0x5d183a][_0xeabc('0x6d')];_0xa44f2d=_0x5d4bc2[_0x5d183a][_0xeabc('0x6e')]?_[_0xeabc('0x6f')](_0x2c7b4e[_0x5d4bc2[_0x5d183a][_0xeabc('0x6e')]],'%s',_0xa44f2d):_0xa44f2d;_0xa44f2d=_0x5d4bc2[_0x5d183a][_0xeabc('0x70')]?_['replace'](_0x536f42[_0x5d4bc2[_0x5d183a]['format']],'%s',_0xa44f2d):_0xa44f2d;if(_0x5d4bc2[_0x5d183a][_0xeabc('0x71')]){_0x1c84b5['group'](_0xa44f2d);}_0x5d4bc2[_0x5d183a][_0xeabc('0x72')]&&_0x1c84b5['order'](_0xa44f2d,_0x5d4bc2[_0x5d183a][_0xeabc('0x72')]==='DESC'?![]:!![]);_0x1c84b5[_0xeabc('0x6d')](_0xa44f2d,_0x5d4bc2[_0x5d183a]['alias']||_0xa44f2d);}if(_0xb59a2a[_0xeabc('0x73')]){_0xb59a2a[_0xeabc('0x73')]=JSON[_0xeabc('0x74')](_0xb59a2a[_0xeabc('0x73')]);for(var _0x5e121c=0x0;_0x5e121c<_0xb59a2a[_0xeabc('0x73')]['length'];_0x5e121c+=0x1){if(_0xb59a2a[_0xeabc('0x73')][_0x5e121c][_0xeabc('0x33')]&&_[_0xeabc('0x75')](_0x4358d7,_0xb59a2a[_0xeabc('0x73')][_0x5e121c][_0xeabc('0x33')])&&_0xb59a2a['joins'][_0x5e121c][_0xeabc('0x76')]&&_0xb59a2a[_0xeabc('0x73')][_0x5e121c][_0xeabc('0x77')]&&_0xb59a2a[_0xeabc('0x73')][_0x5e121c]['foreignKey']){_0x1c84b5[_0xb59a2a[_0xeabc('0x73')][_0x5e121c][_0xeabc('0x33')]](_0xb59a2a[_0xeabc('0x73')][_0x5e121c][_0xeabc('0x77')],null,util['format'](_0xeabc('0x78'),_0xb59a2a[_0xeabc('0x6b')],_0xb59a2a[_0xeabc('0x73')][_0x5e121c][_0xeabc('0x76')],_0xb59a2a['joins'][_0x5e121c]['foreignTable'],_0xb59a2a[_0xeabc('0x73')][_0x5e121c]['foreignKey']));}}}if(_0xb59a2a['conditions']){_0xb59a2a[_0xeabc('0x79')]=JSON[_0xeabc('0x74')](_0xb59a2a[_0xeabc('0x79')]);_0x1c84b5['where'](_0x11cc1f(_0xb59a2a[_0xeabc('0x79')][_0xeabc('0x66')]));}_0x3fa31b=_0x1c84b5['clone']();_0x1c84b5[_0xeabc('0x1e')](_0x4a2ad6);_0x1c84b5[_0xeabc('0x1d')](0x0);logger[_0xeabc('0x7a')](_0xeabc('0x7b'),_0x1c84b5[_0xeabc('0x7c')]());return dbH['sequelize'][_0xeabc('0x36')](_0x1c84b5['toString'](),{'type':dbH['sequelize']['QueryTypes'][_0xeabc('0x7d')]});}})[_0xeabc('0x26')](respondWithResult(_0x2f78f3,null))[_0xeabc('0x47')](handleError(_0x2f78f3,null));};function runReport(_0x4424ce,_0x33fa74,_0x51368f){var _0x39f961=_0x33fa74['name'];var _0x1795fe=0xa;var _0x2f95c7=['join',_0xeabc('0x53'),'right_join','cross_join'];var _0x952dc7={'SUM':_0xeabc('0x56'),'COUNT':_0xeabc('0x57'),'COUNT DISTINCT':_0xeabc('0x7e'),'MAX':_0xeabc('0x7f'),'MIN':'MIN(%s)','AVG':_0xeabc('0x59'),'GROUP_CONCAT':_0xeabc('0x5a'),'GROUP_CONCAT ASC':_0xeabc('0x80'),'GROUP_CONCAT DESC':_0xeabc('0x5b')};var _0x348064={'SEC_TO_TIME':_0xeabc('0x81'),'DATE':_0xeabc('0x5c'),'HOUR':_0xeabc('0x5d'),'ROUND':_0xeabc('0x5e'),'UNIX_TIMESTAMP':_0xeabc('0x5f')};var _0x522c6e=function(_0x436f8e){return!_[_0xeabc('0x75')]([_0xeabc('0x60'),'IS\x20NOT\x20NULL','IS\x20EMPTY',_0xeabc('0x63')],_0x436f8e);};var _0x273ca5=function(_0xe90200){if(!_0xe90200||!_0xe90200[_0xeabc('0x64')][_0xeabc('0x3c')]){return'';}for(var _0x5f5a47='(',_0x289f98=0x0;_0x289f98<_0xe90200['rules']['length'];_0x289f98+=0x1){_0x289f98>0x0&&(_0x5f5a47+='\x20'+_0xe90200[_0xeabc('0x65')]+'\x20');_0x5f5a47+=_0xe90200[_0xeabc('0x64')][_0x289f98]['group']?_0x273ca5(_0xe90200[_0xeabc('0x64')][_0x289f98][_0xeabc('0x66')]):_0xe90200[_0xeabc('0x64')][_0x289f98][_0xeabc('0x6d')]+'\x20'+_0xe90200[_0xeabc('0x64')][_0x289f98][_0xeabc('0x67')]+(_0x522c6e(_0xe90200[_0xeabc('0x64')][_0x289f98][_0xeabc('0x67')])?'\x20'+_0xe90200[_0xeabc('0x64')][_0x289f98][_0xeabc('0x68')]:'');}return _0x5f5a47+')';};var _0x1f8197={'where':{'id':_0x4424ce['id']}},_0x485c13,_0xb54c35,_0x5c9d6f,_0x1caaa7,_0x3e764a;_0x1f8197=_[_0xeabc('0x40')]({},_0x1f8197,_0x51368f);return db[_0xeabc('0x31')][_0xeabc('0x46')](_0x1f8197)[_0xeabc('0x26')](function(_0x40f51e){if(_0x40f51e){_0x485c13=_0x40f51e;return _0x40f51e[_0xeabc('0x69')]();}return null;})[_0xeabc('0x26')](function(_0x156e20){if(_0x156e20){if(!_0x156e20[_0xeabc('0x3c')]){throw new db['Sequelize'][(_0xeabc('0x82'))](_0xeabc('0x6a'),0x193);}_0xb54c35=_0x156e20;return db[_0xeabc('0x83')][_0xeabc('0x42')]({'raw':!![]});}return null;})['then'](function(_0x26c595){if(_0x26c595){_0x5c9d6f=_[_0xeabc('0x84')](_0x26c595,'id');var _0x580661;var _0x3de927=squel[_0xeabc('0x85')]();_0x3de927['from'](_0x485c13['table']);for(var _0x489b1d=0x0;_0x489b1d<_0xb54c35['length'];_0x489b1d+=0x1){_0x580661=_0xb54c35[_0x489b1d][_0xeabc('0x6c')]?_0x5c9d6f[_0xb54c35[_0x489b1d][_0xeabc('0x6c')]][_0xeabc('0x86')]:_0xb54c35[_0x489b1d][_0xeabc('0x6d')];_0x580661=_0xb54c35[_0x489b1d][_0xeabc('0x6e')]?_[_0xeabc('0x6f')](_0x952dc7[_0xb54c35[_0x489b1d][_0xeabc('0x6e')]],'%s',_0x580661):_0x580661;_0x580661=_0xb54c35[_0x489b1d][_0xeabc('0x70')]?_[_0xeabc('0x6f')](_0x348064[_0xb54c35[_0x489b1d][_0xeabc('0x70')]],'%s',_0x580661):_0x580661;if(_0xb54c35[_0x489b1d]['groupBy']){_0x3de927[_0xeabc('0x66')](_0x580661);}_0xb54c35[_0x489b1d][_0xeabc('0x72')]&&_0x3de927['order'](_0x580661,_0xb54c35[_0x489b1d][_0xeabc('0x72')]===_0xeabc('0x87')?![]:!![]);_0x3de927[_0xeabc('0x6d')](_0x580661,_0xb54c35[_0x489b1d]['alias']||_0x580661);}if(_0x485c13[_0xeabc('0x73')]){_0x485c13['joins']=JSON[_0xeabc('0x74')](_0x485c13[_0xeabc('0x73')]);for(var _0x1841f0=0x0;_0x1841f0<_0x485c13[_0xeabc('0x73')][_0xeabc('0x3c')];_0x1841f0+=0x1){if(_0x485c13['joins'][_0x1841f0]['type']&&_['includes'](_0x2f95c7,_0x485c13['joins'][_0x1841f0][_0xeabc('0x33')])&&_0x485c13[_0xeabc('0x73')][_0x1841f0][_0xeabc('0x76')]&&_0x485c13['joins'][_0x1841f0][_0xeabc('0x77')]&&_0x485c13[_0xeabc('0x73')][_0x1841f0][_0xeabc('0x88')]){_0x3de927[_0x485c13[_0xeabc('0x73')][_0x1841f0][_0xeabc('0x33')]](_0x485c13[_0xeabc('0x73')][_0x1841f0][_0xeabc('0x77')],null,util[_0xeabc('0x70')](_0xeabc('0x78'),_0x485c13[_0xeabc('0x6b')],_0x485c13[_0xeabc('0x73')][_0x1841f0][_0xeabc('0x76')],_0x485c13['joins'][_0x1841f0]['foreignTable'],_0x485c13[_0xeabc('0x73')][_0x1841f0]['foreignKey']));}}}if(_0x485c13[_0xeabc('0x79')]){_0x485c13[_0xeabc('0x79')]=JSON[_0xeabc('0x74')](_0x485c13['conditions']);_0x3de927[_0xeabc('0x41')](_0x273ca5(_0x485c13[_0xeabc('0x79')][_0xeabc('0x66')]));}_0x3e764a=_0x3de927['clone']();_0x3de927['limit'](_0x1795fe);_0x3de927[_0xeabc('0x1d')](0x0);return;}})[_0xeabc('0x26')](function(){if(_0x33fa74[_0xeabc('0x89')]===_0xeabc('0x8a')){return null;}var _0x2cc9b3=_[_0xeabc('0x40')](_0x33fa74,{'name':_0x33fa74['fullPath']||_0x33fa74['name']||_0x485c13[_0xeabc('0x2d')],'basename':_0x39f961,'savename':util[_0xeabc('0x70')](_0xeabc('0x8b'),_0x33fa74[_0xeabc('0x2d')]||_0x485c13['name'],require('randomstring')['generate'](0x4),_0x33fa74[_0xeabc('0x89')]||'csv'),'reportId':_0x485c13['id'],'reportType':_0xeabc('0x8c')});return db['AnalyticExtractedReport'][_0xeabc('0x48')](_0x2cc9b3,{'raw':!![]});})['then'](function(_0x6e6ab2){if(_0x485c13[_0xeabc('0x6b')]===_0xeabc('0x8d')){_0x3e764a[_0xeabc('0x41')](_0x485c13[_0xeabc('0x6b')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x33fa74[_0xeabc('0x8e')],_0x33fa74[_0xeabc('0x8f')]);}else{_0x3e764a[_0xeabc('0x41')](_0x485c13['table']+_0xeabc('0x90'),_0x33fa74[_0xeabc('0x8e')],_0x33fa74[_0xeabc('0x8f')]);}if(_0x6e6ab2){logger[_0xeabc('0x91')](_0xeabc('0x92'),_0x3e764a['toString']());require(_0xeabc('0x93'))[_0xeabc('0x94')](path['join'](__dirname,_0xeabc('0x95'),_0x6e6ab2[_0xeabc('0x89')]),[_0x6e6ab2['id'],_0x3e764a['toString'](),path[_0xeabc('0x52')](__dirname,_0xeabc('0x96'),_0x6e6ab2[_0xeabc('0x97')]),_0x39f961]);return _0x6e6ab2;}else{var _0x307d26=squel[_0xeabc('0x85')]();_0x307d26[_0xeabc('0x98')]('('+_0x3e764a[_0xeabc('0x7c')]()+')',_0xeabc('0x99'));_0x307d26[_0xeabc('0x6d')](_0xeabc('0x9a'),_0xeabc('0x20'));_0x3e764a[_0xeabc('0x1e')](_0x33fa74[_0xeabc('0x1e')]||_0x1795fe);_0x3e764a['offset'](_0x33fa74['offset']||0x0);return dbH[_0xeabc('0x9b')][_0xeabc('0x36')](_0x307d26[_0xeabc('0x7c')](),{'type':dbH[_0xeabc('0x9b')]['QueryTypes'][_0xeabc('0x7d')]})['then'](function(_0x49fba2){if(!_0x49fba2['length']){_0x1caaa7=0x0;}else{_0x1caaa7=_0x49fba2[0x0]['count']||0x0;}return dbH['sequelize']['query'](_0x3e764a[_0xeabc('0x7c')](),{'type':dbH[_0xeabc('0x9b')][_0xeabc('0x9c')][_0xeabc('0x7d')]});})[_0xeabc('0x26')](function(_0xe27492){return{'rows':_0xe27492||[],'count':_0x1caaa7};});}});}exports[_0xeabc('0x9d')]=function(_0x3eaedf,_0x44dc85){return runReport(_0x3eaedf['params'],_0x3eaedf[_0xeabc('0x36')],_0x3eaedf[_0xeabc('0x45')])[_0xeabc('0x26')](respondWithResult(_0x44dc85,null))[_0xeabc('0x47')](handleError(_0x44dc85,null));};exports[_0xeabc('0x9e')]=runReport;exports[_0xeabc('0x36')]=function(_0x2a29d7,_0x5bb5d6){var _0x3513ce=0xa;var _0x58cb5d=[_0xeabc('0x52'),_0xeabc('0x53'),'right_join',_0xeabc('0x55')];var _0x4c8bf3={'SUM':_0xeabc('0x56'),'COUNT':_0xeabc('0x57'),'COUNT DISTINCT':_0xeabc('0x7e'),'MAX':_0xeabc('0x7f'),'MIN':_0xeabc('0x58'),'AVG':_0xeabc('0x59'),'GROUP_CONCAT':_0xeabc('0x5a'),'GROUP_CONCAT ASC':_0xeabc('0x80'),'GROUP_CONCAT DESC':_0xeabc('0x5b')};var _0x484c75={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xeabc('0x5c'),'HOUR':_0xeabc('0x5d'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xeabc('0x5f')};var _0x580f72=function(_0x37907a){return!_[_0xeabc('0x75')]([_0xeabc('0x60'),_0xeabc('0x61'),_0xeabc('0x62'),_0xeabc('0x63')],_0x37907a);};var _0x57db6d=function(_0x13cc55){if(!_0x13cc55||!_0x13cc55['rules'][_0xeabc('0x3c')]){return'';}for(var _0x43b88e='(',_0x1fa464=0x0;_0x1fa464<_0x13cc55[_0xeabc('0x64')]['length'];_0x1fa464+=0x1){_0x1fa464>0x0&&(_0x43b88e+='\x20'+_0x13cc55[_0xeabc('0x65')]+'\x20');_0x43b88e+=_0x13cc55[_0xeabc('0x64')][_0x1fa464][_0xeabc('0x66')]?_0x57db6d(_0x13cc55['rules'][_0x1fa464][_0xeabc('0x66')]):_0x13cc55[_0xeabc('0x64')][_0x1fa464][_0xeabc('0x6d')]+'\x20'+_0x13cc55['rules'][_0x1fa464]['condition']+(_0x580f72(_0x13cc55['rules'][_0x1fa464]['condition'])?'\x20'+_0x13cc55[_0xeabc('0x64')][_0x1fa464][_0xeabc('0x68')]:'');}return _0x43b88e+')';};var _0x52e84f={'where':{'id':_0x2a29d7[_0xeabc('0x50')]['id']}},_0x12f024,_0x1d35da,_0x2695a4,_0x199251,_0x1899d6;_0x52e84f=_[_0xeabc('0x40')]({},_0x52e84f,_0x2a29d7[_0xeabc('0x45')]);return db[_0xeabc('0x31')]['find'](_0x52e84f)[_0xeabc('0x26')](function(_0x5bb015){if(_0x5bb015){_0x12f024=_0x5bb015;return _0x5bb015[_0xeabc('0x69')]();}return null;})[_0xeabc('0x26')](function(_0x438ce3){if(_0x438ce3){if(!_0x438ce3[_0xeabc('0x3c')]){throw new db[(_0xeabc('0x9f'))][(_0xeabc('0x82'))](_0xeabc('0x6a'),0x193);}_0x1d35da=_0x438ce3;return db['AnalyticMetric'][_0xeabc('0x42')]({'raw':!![]});}return null;})['then'](function(_0x475160){if(_0x475160){_0x2695a4=_['keyBy'](_0x475160,'id');var _0x10d66b;var _0x12a042=squel[_0xeabc('0x85')]();_0x12a042[_0xeabc('0x98')](_0x12f024[_0xeabc('0x6b')]);for(var _0x49bf0f=0x0;_0x49bf0f<_0x1d35da[_0xeabc('0x3c')];_0x49bf0f+=0x1){_0x10d66b=_0x1d35da[_0x49bf0f][_0xeabc('0x6c')]?_0x2695a4[_0x1d35da[_0x49bf0f][_0xeabc('0x6c')]][_0xeabc('0x86')]:_0x1d35da[_0x49bf0f][_0xeabc('0x6d')];_0x10d66b=_0x1d35da[_0x49bf0f]['function']?_[_0xeabc('0x6f')](_0x4c8bf3[_0x1d35da[_0x49bf0f][_0xeabc('0x6e')]],'%s',_0x10d66b):_0x10d66b;_0x10d66b=_0x1d35da[_0x49bf0f][_0xeabc('0x70')]?_[_0xeabc('0x6f')](_0x484c75[_0x1d35da[_0x49bf0f][_0xeabc('0x70')]],'%s',_0x10d66b):_0x10d66b;if(_0x1d35da[_0x49bf0f]['groupBy']){_0x12a042[_0xeabc('0x66')](_0x10d66b);}_0x1d35da[_0x49bf0f]['orderBy']&&_0x12a042[_0xeabc('0x3e')](_0x10d66b,_0x1d35da[_0x49bf0f][_0xeabc('0x72')]===_0xeabc('0x87')?![]:!![]);_0x12a042[_0xeabc('0x6d')](_0x10d66b,_0x1d35da[_0x49bf0f][_0xeabc('0xa0')]||_0x10d66b);}if(_0x12f024[_0xeabc('0x73')]){_0x12f024[_0xeabc('0x73')]=JSON[_0xeabc('0x74')](_0x12f024[_0xeabc('0x73')]);for(var _0x223a3=0x0;_0x223a3<_0x12f024['joins'][_0xeabc('0x3c')];_0x223a3+=0x1){if(_0x12f024[_0xeabc('0x73')][_0x223a3][_0xeabc('0x33')]&&_[_0xeabc('0x75')](_0x58cb5d,_0x12f024['joins'][_0x223a3][_0xeabc('0x33')])&&_0x12f024['joins'][_0x223a3]['parentKey']&&_0x12f024[_0xeabc('0x73')][_0x223a3][_0xeabc('0x77')]&&_0x12f024[_0xeabc('0x73')][_0x223a3]['foreignKey']){_0x12a042[_0x12f024[_0xeabc('0x73')][_0x223a3][_0xeabc('0x33')]](_0x12f024[_0xeabc('0x73')][_0x223a3][_0xeabc('0x77')],null,util[_0xeabc('0x70')]('%s.%s\x20=\x20%s.%s',_0x12f024[_0xeabc('0x6b')],_0x12f024[_0xeabc('0x73')][_0x223a3]['parentKey'],_0x12f024['joins'][_0x223a3][_0xeabc('0x77')],_0x12f024[_0xeabc('0x73')][_0x223a3][_0xeabc('0x88')]));}}}if(_0x12f024[_0xeabc('0x79')]){_0x12f024[_0xeabc('0x79')]=JSON[_0xeabc('0x74')](_0x12f024[_0xeabc('0x79')]);_0x12a042[_0xeabc('0x41')](_0x57db6d(_0x12f024[_0xeabc('0x79')]['group']));}_0x1899d6=_0x12a042[_0xeabc('0xa1')]();_0x12a042['limit'](_0x3513ce);_0x12a042[_0xeabc('0x1d')](0x0);logger['debug'](_0xeabc('0x7b'),_0x12a042[_0xeabc('0x7c')]());return dbH[_0xeabc('0x9b')][_0xeabc('0x36')](_0x12a042[_0xeabc('0x7c')](),{'type':dbH[_0xeabc('0x9b')][_0xeabc('0x9c')][_0xeabc('0x7d')]});}})[_0xeabc('0x26')](function(){return{'sql':_0x1899d6[_0xeabc('0x7c')]()};})['then'](respondWithResult(_0x5bb5d6,null))['catch'](handleError(_0x5bb5d6,null));};
\ No newline at end of file