Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 0c3a7d3..80d85d8 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 _0x46ed=['SEC_TO_TIME(%s)','value','AnalyticMetric','select','DESC','output','fullPath','%s-%s.%s','randomstring','csv','default','AnalyticExtractedReport','cdr','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','info','Run\x20Query:','child_process','../../files/reports','savename','countTable','COUNT(*)','sequelize','runReport','left_join','COUNT(%s)','MIN(%s)','AVG(%s)','Limited\x20Query:','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','get','DefaultReports','UserProfileResource','destroy','sendStatus','error','stack','name','send','index','map','AnalyticDefaultReport','rawAttributes','fieldName','type','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','merge','options','includeAll','include','findAll','catch','params','find','create','body','user','Reports','UserProfileSection','userProfileId','autoAssociation','preview','join','right_join','cross_join','SUM(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','DATE(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','keyBy','from','table','MetricId','metric','function','replace','format','groupBy','orderBy','order','alias','joins','parentKey','foreignKey','foreignTable','%s.%s\x20=\x20%s.%s','conditions','parse','clone','toString','QueryTypes','SELECT'];(function(_0x2a74f5,_0x542b0b){var _0x358258=function(_0x52e19e){while(--_0x52e19e){_0x2a74f5['push'](_0x2a74f5['shift']());}};_0x358258(++_0x542b0b);}(_0x46ed,0x168));var _0xd46e=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0x46ed[_0x40a045];return _0x1a687c;};'use strict';var emlformat=require(_0xd46e('0x0'));var rimraf=require(_0xd46e('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd46e('0x2'));var rp=require(_0xd46e('0x3'));var moment=require(_0xd46e('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xd46e('0x5'));var util=require(_0xd46e('0x6'));var path=require('path');var sox=require(_0xd46e('0x7'));var csv=require(_0xd46e('0x8'));var ejs=require(_0xd46e('0x9'));var fs=require('fs');var fs_extra=require(_0xd46e('0xa'));var _=require(_0xd46e('0xb'));var squel=require(_0xd46e('0xc'));var crypto=require(_0xd46e('0xd'));var jsforce=require(_0xd46e('0xe'));var deskjs=require(_0xd46e('0xf'));var toCsv=require(_0xd46e('0x8'));var querystring=require(_0xd46e('0x10'));var Papa=require('papaparse');var Redis=require(_0xd46e('0x11'));var authService=require(_0xd46e('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xd46e('0x13'));var hardwareService=require(_0xd46e('0x14'));var logger=require(_0xd46e('0x15'))(_0xd46e('0x16'));var utils=require(_0xd46e('0x17'));var config=require(_0xd46e('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xd46e('0x19'))['db'];var dbH=require('../../mysqldb')['dbH'];function respondWithStatusCode(_0xf3048c,_0x27dbfb){_0x27dbfb=_0x27dbfb||0xcc;return function(_0x53b309){if(_0x53b309){return _0xf3048c['sendStatus'](_0x27dbfb);}return _0xf3048c[_0xd46e('0x1a')](_0x27dbfb)[_0xd46e('0x1b')]();};}function respondWithResult(_0x1e9aae,_0x3fdf88){_0x3fdf88=_0x3fdf88||0xc8;return function(_0x50c7c3){if(_0x50c7c3){return _0x1e9aae[_0xd46e('0x1a')](_0x3fdf88)[_0xd46e('0x1c')](_0x50c7c3);}};}function respondWithFilteredResult(_0x417402,_0x3d72ce){return function(_0x36a317){if(_0x36a317){var _0x47fa8f=typeof _0x3d72ce[_0xd46e('0x1d')]===_0xd46e('0x1e')&&typeof _0x3d72ce[_0xd46e('0x1f')]==='undefined';var _0x5ddd04=_0x36a317[_0xd46e('0x20')];var _0x1bd574=_0x47fa8f?0x0:_0x3d72ce['offset'];var _0x4fd1f2=_0x47fa8f?_0x36a317[_0xd46e('0x20')]:_0x3d72ce[_0xd46e('0x1d')]+_0x3d72ce[_0xd46e('0x1f')];var _0x2273c5;if(_0x4fd1f2>=_0x5ddd04){_0x4fd1f2=_0x5ddd04;_0x2273c5=0xc8;}else{_0x2273c5=0xce;}_0x417402[_0xd46e('0x1a')](_0x2273c5);return _0x417402[_0xd46e('0x21')](_0xd46e('0x22'),_0x1bd574+'-'+_0x4fd1f2+'/'+_0x5ddd04)[_0xd46e('0x1c')](_0x36a317);}return null;};}function patchUpdates(_0xb4940){return function(_0x3c7e91){try{jsonpatch[_0xd46e('0x23')](_0x3c7e91,_0xb4940,!![]);}catch(_0x5ba94d){return BPromise[_0xd46e('0x24')](_0x5ba94d);}return _0x3c7e91[_0xd46e('0x25')]();};}function saveUpdates(_0x79aa51,_0x45ce0b){return function(_0x128246){if(_0x128246){return _0x128246[_0xd46e('0x26')](_0x79aa51)[_0xd46e('0x27')](function(_0x8a1be){return _0x8a1be;});}return null;};}function removeEntity(_0x62dea5,_0x4cf899){return function(_0x314570){if(_0x314570){return _0x314570['destroy']()['then'](function(){var _0x371054=_0x314570[_0xd46e('0x28')]({'plain':!![]});var _0x21135f=_0xd46e('0x29');return db[_0xd46e('0x2a')][_0xd46e('0x2b')]({'where':{'type':_0x21135f,'resourceId':_0x371054['id']}})[_0xd46e('0x27')](function(){return _0x314570;});})['then'](function(){_0x62dea5[_0xd46e('0x1a')](0xcc)[_0xd46e('0x1b')]();});}};}function handleEntityNotFound(_0xddbce9,_0x17db79){return function(_0x96f15c){if(!_0x96f15c){_0xddbce9[_0xd46e('0x2c')](0x194);}return _0x96f15c;};}function handleError(_0x58aeef,_0x465d54){_0x465d54=_0x465d54||0x1f4;return function(_0x3a1ced){logger[_0xd46e('0x2d')](_0x3a1ced[_0xd46e('0x2e')]);if(_0x3a1ced[_0xd46e('0x2f')]){delete _0x3a1ced[_0xd46e('0x2f')];}_0x58aeef[_0xd46e('0x1a')](_0x465d54)[_0xd46e('0x30')](_0x3a1ced);};}exports[_0xd46e('0x31')]=function(_0x45ea47,_0x2ff785){var _0x504324={},_0x2f4a1b={},_0x5ed8dc={'count':0x0,'rows':[]};var _0x1248ce=_[_0xd46e('0x32')](db[_0xd46e('0x33')][_0xd46e('0x34')],function(_0x5ef248){return{'name':_0x5ef248[_0xd46e('0x35')],'type':_0x5ef248[_0xd46e('0x36')]['key']};});_0x2f4a1b[_0xd46e('0x37')]=_[_0xd46e('0x32')](_0x1248ce,'name');_0x2f4a1b[_0xd46e('0x38')]=_[_0xd46e('0x39')](_0x45ea47[_0xd46e('0x38')]);_0x2f4a1b['filters']=_['intersection'](_0x2f4a1b[_0xd46e('0x37')],_0x2f4a1b[_0xd46e('0x38')]);_0x504324[_0xd46e('0x3a')]=_[_0xd46e('0x3b')](_0x2f4a1b[_0xd46e('0x37')],qs[_0xd46e('0x3c')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x3c')]));_0x504324['attributes']=_0x504324[_0xd46e('0x3a')][_0xd46e('0x3d')]?_0x504324[_0xd46e('0x3a')]:_0x2f4a1b[_0xd46e('0x37')];if(!_0x45ea47[_0xd46e('0x38')][_0xd46e('0x3e')](_0xd46e('0x3f'))){_0x504324['limit']=qs[_0xd46e('0x1f')](_0x45ea47[_0xd46e('0x38')]['limit']);_0x504324[_0xd46e('0x1d')]=qs[_0xd46e('0x1d')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x1d')]);}_0x504324['order']=qs[_0xd46e('0x40')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x40')]);_0x504324[_0xd46e('0x41')]=qs[_0xd46e('0x42')](_[_0xd46e('0x43')](_0x45ea47[_0xd46e('0x38')],_0x2f4a1b[_0xd46e('0x42')]),_0x1248ce);if(_0x45ea47['query'][_0xd46e('0x44')]){_0x504324[_0xd46e('0x41')]=_[_0xd46e('0x45')](_0x504324[_0xd46e('0x41')],{'$or':_[_0xd46e('0x32')](_0x1248ce,function(_0x56f99c){if(_0x56f99c[_0xd46e('0x36')]!=='VIRTUAL'){var _0x55230d={};_0x55230d[_0x56f99c['name']]={'$like':'%'+_0x45ea47['query'][_0xd46e('0x44')]+'%'};return _0x55230d;}})});}_0x504324=_['merge']({},_0x504324,_0x45ea47[_0xd46e('0x46')]);var _0x40720e={'where':_0x504324['where']};return db[_0xd46e('0x33')][_0xd46e('0x20')](_0x40720e)[_0xd46e('0x27')](function(_0x31ba12){_0x5ed8dc[_0xd46e('0x20')]=_0x31ba12;if(_0x45ea47[_0xd46e('0x38')][_0xd46e('0x47')]){_0x504324[_0xd46e('0x48')]=[{'all':!![]}];}return db[_0xd46e('0x33')][_0xd46e('0x49')](_0x504324);})[_0xd46e('0x27')](function(_0x5ea048){_0x5ed8dc['rows']=_0x5ea048;return _0x5ed8dc;})['then'](respondWithFilteredResult(_0x2ff785,_0x504324))[_0xd46e('0x4a')](handleError(_0x2ff785,null));};exports['show']=function(_0x168d35,_0x272f5f){var _0x3fdf67={'raw':!![],'where':{'id':_0x168d35[_0xd46e('0x4b')]['id']}},_0x416505={};_0x416505[_0xd46e('0x37')]=_[_0xd46e('0x39')](db[_0xd46e('0x33')]['rawAttributes']);_0x416505[_0xd46e('0x38')]=_['keys'](_0x168d35[_0xd46e('0x38')]);_0x416505[_0xd46e('0x42')]=_[_0xd46e('0x3b')](_0x416505[_0xd46e('0x37')],_0x416505[_0xd46e('0x38')]);_0x3fdf67['attributes']=_[_0xd46e('0x3b')](_0x416505[_0xd46e('0x37')],qs[_0xd46e('0x3c')](_0x168d35[_0xd46e('0x38')][_0xd46e('0x3c')]));_0x3fdf67['attributes']=_0x3fdf67[_0xd46e('0x3a')][_0xd46e('0x3d')]?_0x3fdf67[_0xd46e('0x3a')]:_0x416505[_0xd46e('0x37')];if(_0x168d35[_0xd46e('0x38')]['includeAll']){_0x3fdf67[_0xd46e('0x48')]=[{'all':!![]}];}_0x3fdf67=_[_0xd46e('0x45')]({},_0x3fdf67,_0x168d35[_0xd46e('0x46')]);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0x3fdf67)[_0xd46e('0x27')](handleEntityNotFound(_0x272f5f,null))[_0xd46e('0x27')](respondWithResult(_0x272f5f,null))[_0xd46e('0x4a')](handleError(_0x272f5f,null));};exports['create']=function(_0xf9dab,_0x71a8dc){return db[_0xd46e('0x33')][_0xd46e('0x4d')](_0xf9dab[_0xd46e('0x4e')],{})['then'](function(_0x4ae314){var _0x3a94cf=_0xf9dab[_0xd46e('0x4f')][_0xd46e('0x28')]({'plain':!![]});if(!_0x3a94cf)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3a94cf['role']===_0xd46e('0x4f')){var _0x9d8638=_0x4ae314['get']({'plain':!![]});var _0x2eee92=_0xd46e('0x50');return db[_0xd46e('0x51')][_0xd46e('0x4c')]({'where':{'name':_0x2eee92,'userProfileId':_0x3a94cf[_0xd46e('0x52')]},'raw':!![]})[_0xd46e('0x27')](function(_0x80ed51){if(_0x80ed51&&_0x80ed51[_0xd46e('0x53')]===0x0){return db['UserProfileResource'][_0xd46e('0x4d')]({'name':_0x9d8638[_0xd46e('0x2f')],'resourceId':_0x9d8638['id'],'type':_0xd46e('0x29'),'sectionId':_0x80ed51['id']},{})[_0xd46e('0x27')](function(){return _0x4ae314;});}else{return _0x4ae314;}})['catch'](function(_0x56dd9a){logger[_0xd46e('0x2d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x56dd9a);throw _0x56dd9a;});}return _0x4ae314;})[_0xd46e('0x27')](respondWithResult(_0x71a8dc,0xc9))[_0xd46e('0x4a')](handleError(_0x71a8dc,null));};exports[_0xd46e('0x26')]=function(_0x31f7eb,_0x5a7870){if(_0x31f7eb[_0xd46e('0x4e')]['id']){delete _0x31f7eb['body']['id'];}return db[_0xd46e('0x33')][_0xd46e('0x4c')]({'where':{'id':_0x31f7eb[_0xd46e('0x4b')]['id']}})['then'](handleEntityNotFound(_0x5a7870,null))[_0xd46e('0x27')](saveUpdates(_0x31f7eb[_0xd46e('0x4e')],null))[_0xd46e('0x27')](respondWithResult(_0x5a7870,null))[_0xd46e('0x4a')](handleError(_0x5a7870,null));};exports[_0xd46e('0x2b')]=function(_0x2cc676,_0x2760ef){return db[_0xd46e('0x33')][_0xd46e('0x4c')]({'where':{'id':_0x2cc676[_0xd46e('0x4b')]['id']}})[_0xd46e('0x27')](handleEntityNotFound(_0x2760ef,null))[_0xd46e('0x27')](removeEntity(_0x2760ef,null))[_0xd46e('0x4a')](handleError(_0x2760ef,null));};exports[_0xd46e('0x54')]=function(_0x47a86c,_0x3ec709){var _0x37a22f=0xa;var _0xe0cd61=[_0xd46e('0x55'),'left_join',_0xd46e('0x56'),_0xd46e('0x57')];var _0xaf9641={'SUM':_0xd46e('0x58'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':_0xd46e('0x5c'),'GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x481dce={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':_0xd46e('0x61')};var _0x2dacb4=function(_0x2f9fcb){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),_0xd46e('0x64'),_0xd46e('0x65'),_0xd46e('0x66')],_0x2f9fcb);};var _0x1aaa99=function(_0x272514){if(!_0x272514||!_0x272514[_0xd46e('0x67')][_0xd46e('0x3d')]){return'';}for(var _0x476f09='(',_0x5067b7=0x0;_0x5067b7<_0x272514[_0xd46e('0x67')][_0xd46e('0x3d')];_0x5067b7+=0x1){_0x5067b7>0x0&&(_0x476f09+='\x20'+_0x272514[_0xd46e('0x68')]+'\x20');_0x476f09+=_0x272514['rules'][_0x5067b7][_0xd46e('0x69')]?_0x1aaa99(_0x272514[_0xd46e('0x67')][_0x5067b7]['group']):_0x272514[_0xd46e('0x67')][_0x5067b7][_0xd46e('0x6a')]+'\x20'+_0x272514[_0xd46e('0x67')][_0x5067b7]['condition']+(_0x2dacb4(_0x272514[_0xd46e('0x67')][_0x5067b7][_0xd46e('0x6b')])?'\x20'+_0x272514[_0xd46e('0x67')][_0x5067b7]['value']:'');}return _0x476f09+')';};var _0xe5f8cd={'where':{'id':_0x47a86c[_0xd46e('0x4b')]['id']}},_0x516e7d,_0x32eed0,_0x148187,_0x35db1b,_0x4f3ba0;_0xe5f8cd=_[_0xd46e('0x45')]({},_0xe5f8cd,_0x47a86c[_0xd46e('0x46')]);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0xe5f8cd)[_0xd46e('0x27')](function(_0x16f906){if(_0x16f906){_0x516e7d=_0x16f906;return _0x16f906[_0xd46e('0x6c')]();}return null;})[_0xd46e('0x27')](function(_0x3e55a3){if(_0x3e55a3){if(!_0x3e55a3[_0xd46e('0x3d')]){throw new db[(_0xd46e('0x6d'))][(_0xd46e('0x6e'))](_0xd46e('0x6f'),0x193);}_0x32eed0=_0x3e55a3;return db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0xd46e('0x27')](function(_0x3e0ed5){if(_0x3e0ed5){_0x148187=_[_0xd46e('0x70')](_0x3e0ed5,'id');var _0x2fff69;var _0x249938=squel['select']();_0x249938[_0xd46e('0x71')](_0x516e7d[_0xd46e('0x72')]);for(var _0xfb4073=0x0;_0xfb4073<_0x32eed0[_0xd46e('0x3d')];_0xfb4073+=0x1){_0x2fff69=_0x32eed0[_0xfb4073]['MetricId']?_0x148187[_0x32eed0[_0xfb4073][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x32eed0[_0xfb4073]['field'];_0x2fff69=_0x32eed0[_0xfb4073][_0xd46e('0x75')]?_[_0xd46e('0x76')](_0xaf9641[_0x32eed0[_0xfb4073]['function']],'%s',_0x2fff69):_0x2fff69;_0x2fff69=_0x32eed0[_0xfb4073][_0xd46e('0x77')]?_[_0xd46e('0x76')](_0x481dce[_0x32eed0[_0xfb4073]['format']],'%s',_0x2fff69):_0x2fff69;if(_0x32eed0[_0xfb4073][_0xd46e('0x78')]){_0x249938['group'](_0x2fff69);}_0x32eed0[_0xfb4073][_0xd46e('0x79')]&&_0x249938[_0xd46e('0x7a')](_0x2fff69,_0x32eed0[_0xfb4073]['orderBy']==='DESC'?![]:!![]);_0x249938[_0xd46e('0x6a')](_0x2fff69,_0x32eed0[_0xfb4073][_0xd46e('0x7b')]||_0x2fff69);}if(_0x516e7d[_0xd46e('0x7c')]){_0x516e7d[_0xd46e('0x7c')]=JSON['parse'](_0x516e7d[_0xd46e('0x7c')]);for(var _0x372509=0x0;_0x372509<_0x516e7d['joins'][_0xd46e('0x3d')];_0x372509+=0x1){if(_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0xe0cd61,_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x36')])&&_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7d')]&&_0x516e7d[_0xd46e('0x7c')][_0x372509]['foreignTable']&&_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7e')]){_0x249938[_0x516e7d['joins'][_0x372509][_0xd46e('0x36')]](_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7f')],null,util[_0xd46e('0x77')](_0xd46e('0x80'),_0x516e7d[_0xd46e('0x72')],_0x516e7d['joins'][_0x372509]['parentKey'],_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7f')],_0x516e7d['joins'][_0x372509]['foreignKey']));}}}if(_0x516e7d['conditions']){_0x516e7d[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0x516e7d[_0xd46e('0x81')]);_0x249938['where'](_0x1aaa99(_0x516e7d[_0xd46e('0x81')][_0xd46e('0x69')]));}_0x4f3ba0=_0x249938[_0xd46e('0x83')]();_0x249938['limit'](_0x37a22f);_0x249938['offset'](0x0);logger['debug']('Limited\x20Query:',_0x249938[_0xd46e('0x84')]());return dbH['sequelize'][_0xd46e('0x38')](_0x249938['toString'](),{'type':dbH['sequelize'][_0xd46e('0x85')][_0xd46e('0x86')]});}})[_0xd46e('0x27')](respondWithResult(_0x3ec709,null))[_0xd46e('0x4a')](handleError(_0x3ec709,null));};function runReport(_0xf16d87,_0x99872a,_0x57a7cc){var _0x586024=_0x99872a[_0xd46e('0x2f')];var _0x383919=0xa;var _0x114f2c=[_0xd46e('0x55'),'left_join',_0xd46e('0x56'),_0xd46e('0x57')];var _0x4ca21f={'SUM':_0xd46e('0x58'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':_0xd46e('0x5c'),'GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x5ef4cc={'SEC_TO_TIME':_0xd46e('0x87'),'DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':_0xd46e('0x61')};var _0x88460a=function(_0x3a3744){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),_0xd46e('0x64'),_0xd46e('0x65'),_0xd46e('0x66')],_0x3a3744);};var _0x3c476d=function(_0x1b2a6d){if(!_0x1b2a6d||!_0x1b2a6d[_0xd46e('0x67')][_0xd46e('0x3d')]){return'';}for(var _0x441f73='(',_0x1d2738=0x0;_0x1d2738<_0x1b2a6d['rules'][_0xd46e('0x3d')];_0x1d2738+=0x1){_0x1d2738>0x0&&(_0x441f73+='\x20'+_0x1b2a6d['operator']+'\x20');_0x441f73+=_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x69')]?_0x3c476d(_0x1b2a6d['rules'][_0x1d2738][_0xd46e('0x69')]):_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6a')]+'\x20'+_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6b')]+(_0x88460a(_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6b')])?'\x20'+_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x88')]:'');}return _0x441f73+')';};var _0x3fa34d={'where':{'id':_0xf16d87['id']}},_0xc098c9,_0x5f5ba7,_0x493df5,_0x18e140,_0x459a0c;_0x3fa34d=_[_0xd46e('0x45')]({},_0x3fa34d,_0x57a7cc);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0x3fa34d)[_0xd46e('0x27')](function(_0x5b554e){if(_0x5b554e){_0xc098c9=_0x5b554e;return _0x5b554e[_0xd46e('0x6c')]();}return null;})[_0xd46e('0x27')](function(_0xa254f5){if(_0xa254f5){if(!_0xa254f5[_0xd46e('0x3d')]){throw new db[(_0xd46e('0x6d'))][(_0xd46e('0x6e'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x5f5ba7=_0xa254f5;return db[_0xd46e('0x89')][_0xd46e('0x49')]({'raw':!![]});}return null;})['then'](function(_0x3c8d68){if(_0x3c8d68){_0x493df5=_[_0xd46e('0x70')](_0x3c8d68,'id');var _0x9e222d;var _0x3da17e=squel[_0xd46e('0x8a')]();_0x3da17e[_0xd46e('0x71')](_0xc098c9[_0xd46e('0x72')]);for(var _0x282f71=0x0;_0x282f71<_0x5f5ba7[_0xd46e('0x3d')];_0x282f71+=0x1){_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x73')]?_0x493df5[_0x5f5ba7[_0x282f71][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x5f5ba7[_0x282f71][_0xd46e('0x6a')];_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x75')]?_['replace'](_0x4ca21f[_0x5f5ba7[_0x282f71]['function']],'%s',_0x9e222d):_0x9e222d;_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x77')]?_[_0xd46e('0x76')](_0x5ef4cc[_0x5f5ba7[_0x282f71][_0xd46e('0x77')]],'%s',_0x9e222d):_0x9e222d;if(_0x5f5ba7[_0x282f71][_0xd46e('0x78')]){_0x3da17e[_0xd46e('0x69')](_0x9e222d);}_0x5f5ba7[_0x282f71][_0xd46e('0x79')]&&_0x3da17e['order'](_0x9e222d,_0x5f5ba7[_0x282f71][_0xd46e('0x79')]===_0xd46e('0x8b')?![]:!![]);_0x3da17e[_0xd46e('0x6a')](_0x9e222d,_0x5f5ba7[_0x282f71][_0xd46e('0x7b')]||_0x9e222d);}if(_0xc098c9['joins']){_0xc098c9[_0xd46e('0x7c')]=JSON[_0xd46e('0x82')](_0xc098c9['joins']);for(var _0xdf967c=0x0;_0xdf967c<_0xc098c9['joins']['length'];_0xdf967c+=0x1){if(_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0x114f2c,_0xc098c9[_0xd46e('0x7c')][_0xdf967c]['type'])&&_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7d')]&&_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7f')]&&_0xc098c9['joins'][_0xdf967c]['foreignKey']){_0x3da17e[_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x36')]](_0xc098c9['joins'][_0xdf967c]['foreignTable'],null,util[_0xd46e('0x77')](_0xd46e('0x80'),_0xc098c9[_0xd46e('0x72')],_0xc098c9[_0xd46e('0x7c')][_0xdf967c]['parentKey'],_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x7f')],_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7e')]));}}}if(_0xc098c9[_0xd46e('0x81')]){_0xc098c9[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0xc098c9[_0xd46e('0x81')]);_0x3da17e[_0xd46e('0x41')](_0x3c476d(_0xc098c9['conditions'][_0xd46e('0x69')]));}_0x459a0c=_0x3da17e[_0xd46e('0x83')]();_0x3da17e['limit'](_0x383919);_0x3da17e['offset'](0x0);return;}})[_0xd46e('0x27')](function(){if(_0x99872a[_0xd46e('0x8c')]==='web'){return null;}var _0x5e637d=_[_0xd46e('0x45')](_0x99872a,{'name':_0x99872a[_0xd46e('0x8d')]||_0x99872a['name']||_0xc098c9[_0xd46e('0x2f')],'basename':_0x586024,'savename':util[_0xd46e('0x77')](_0xd46e('0x8e'),_0x99872a[_0xd46e('0x2f')]||_0xc098c9[_0xd46e('0x2f')],require(_0xd46e('0x8f'))['generate'](0x4),_0x99872a[_0xd46e('0x8c')]||_0xd46e('0x90')),'reportId':_0xc098c9['id'],'reportType':_0xd46e('0x91')});return db[_0xd46e('0x92')][_0xd46e('0x4d')](_0x5e637d,{'raw':!![]});})[_0xd46e('0x27')](function(_0x3311a6){if(_0xc098c9[_0xd46e('0x72')]===_0xd46e('0x93')){_0x459a0c[_0xd46e('0x41')](_0xc098c9[_0xd46e('0x72')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x99872a[_0xd46e('0x94')],_0x99872a['endDate']);}else{_0x459a0c['where'](_0xc098c9[_0xd46e('0x72')]+_0xd46e('0x95'),_0x99872a[_0xd46e('0x94')],_0x99872a[_0xd46e('0x96')]);}if(_0x3311a6){logger[_0xd46e('0x97')](_0xd46e('0x98'),_0x459a0c[_0xd46e('0x84')]());require(_0xd46e('0x99'))['fork'](path[_0xd46e('0x55')](__dirname,'../../components/export/',_0x3311a6[_0xd46e('0x8c')]),[_0x3311a6['id'],_0x459a0c[_0xd46e('0x84')](),path[_0xd46e('0x55')](__dirname,_0xd46e('0x9a'),_0x3311a6[_0xd46e('0x9b')]),_0x586024]);return _0x3311a6;}else{var _0x399918=squel[_0xd46e('0x8a')]();_0x399918[_0xd46e('0x71')]('('+_0x459a0c['toString']()+')',_0xd46e('0x9c'));_0x399918[_0xd46e('0x6a')](_0xd46e('0x9d'),'count');_0x459a0c[_0xd46e('0x1f')](_0x99872a[_0xd46e('0x1f')]||_0x383919);_0x459a0c[_0xd46e('0x1d')](_0x99872a['offset']||0x0);return dbH[_0xd46e('0x9e')][_0xd46e('0x38')](_0x399918[_0xd46e('0x84')](),{'type':dbH[_0xd46e('0x9e')][_0xd46e('0x85')][_0xd46e('0x86')]})['then'](function(_0x4967ff){if(!_0x4967ff[_0xd46e('0x3d')]){_0x18e140=0x0;}else{_0x18e140=_0x4967ff[0x0][_0xd46e('0x20')]||0x0;}return dbH['sequelize'][_0xd46e('0x38')](_0x459a0c[_0xd46e('0x84')](),{'type':dbH[_0xd46e('0x9e')][_0xd46e('0x85')][_0xd46e('0x86')]});})[_0xd46e('0x27')](function(_0x4bb76b){return{'rows':_0x4bb76b||[],'count':_0x18e140};});}});}exports['run']=function(_0x204a9f,_0x52ca5a){return runReport(_0x204a9f[_0xd46e('0x4b')],_0x204a9f[_0xd46e('0x38')],_0x204a9f['options'])[_0xd46e('0x27')](respondWithResult(_0x52ca5a,null))[_0xd46e('0x4a')](handleError(_0x52ca5a,null));};exports[_0xd46e('0x9f')]=runReport;exports[_0xd46e('0x38')]=function(_0x786ae,_0x537c73){var _0x1610bd=0xa;var _0x20cc4c=[_0xd46e('0x55'),_0xd46e('0xa0'),_0xd46e('0x56'),_0xd46e('0x57')];var _0x368742={'SUM':_0xd46e('0x58'),'COUNT':_0xd46e('0xa1'),'COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':_0xd46e('0xa2'),'AVG':_0xd46e('0xa3'),'GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x285cf8={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0xc87da2=function(_0x195f02){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),'IS\x20NOT\x20NULL',_0xd46e('0x65'),_0xd46e('0x66')],_0x195f02);};var _0x44322f=function(_0x49959f){if(!_0x49959f||!_0x49959f['rules'][_0xd46e('0x3d')]){return'';}for(var _0x2094e5='(',_0x85aac1=0x0;_0x85aac1<_0x49959f[_0xd46e('0x67')][_0xd46e('0x3d')];_0x85aac1+=0x1){_0x85aac1>0x0&&(_0x2094e5+='\x20'+_0x49959f[_0xd46e('0x68')]+'\x20');_0x2094e5+=_0x49959f['rules'][_0x85aac1][_0xd46e('0x69')]?_0x44322f(_0x49959f['rules'][_0x85aac1][_0xd46e('0x69')]):_0x49959f['rules'][_0x85aac1][_0xd46e('0x6a')]+'\x20'+_0x49959f['rules'][_0x85aac1]['condition']+(_0xc87da2(_0x49959f[_0xd46e('0x67')][_0x85aac1][_0xd46e('0x6b')])?'\x20'+_0x49959f[_0xd46e('0x67')][_0x85aac1][_0xd46e('0x88')]:'');}return _0x2094e5+')';};var _0x101a29={'where':{'id':_0x786ae[_0xd46e('0x4b')]['id']}},_0x3a44da,_0x417068,_0x52e73e,_0x206077,_0xe729b6;_0x101a29=_[_0xd46e('0x45')]({},_0x101a29,_0x786ae[_0xd46e('0x46')]);return db['AnalyticDefaultReport'][_0xd46e('0x4c')](_0x101a29)[_0xd46e('0x27')](function(_0x1d08bb){if(_0x1d08bb){_0x3a44da=_0x1d08bb;return _0x1d08bb['getFields']();}return null;})[_0xd46e('0x27')](function(_0x8c6ed1){if(_0x8c6ed1){if(!_0x8c6ed1['length']){throw new db['Sequelize']['ValidationErrorItem'](_0xd46e('0x6f'),0x193);}_0x417068=_0x8c6ed1;return db[_0xd46e('0x89')]['findAll']({'raw':!![]});}return null;})[_0xd46e('0x27')](function(_0x3a13f8){if(_0x3a13f8){_0x52e73e=_['keyBy'](_0x3a13f8,'id');var _0x5a8661;var _0x157fb0=squel[_0xd46e('0x8a')]();_0x157fb0[_0xd46e('0x71')](_0x3a44da[_0xd46e('0x72')]);for(var _0x50750f=0x0;_0x50750f<_0x417068['length'];_0x50750f+=0x1){_0x5a8661=_0x417068[_0x50750f][_0xd46e('0x73')]?_0x52e73e[_0x417068[_0x50750f][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x417068[_0x50750f][_0xd46e('0x6a')];_0x5a8661=_0x417068[_0x50750f][_0xd46e('0x75')]?_[_0xd46e('0x76')](_0x368742[_0x417068[_0x50750f][_0xd46e('0x75')]],'%s',_0x5a8661):_0x5a8661;_0x5a8661=_0x417068[_0x50750f]['format']?_[_0xd46e('0x76')](_0x285cf8[_0x417068[_0x50750f][_0xd46e('0x77')]],'%s',_0x5a8661):_0x5a8661;if(_0x417068[_0x50750f]['groupBy']){_0x157fb0[_0xd46e('0x69')](_0x5a8661);}_0x417068[_0x50750f][_0xd46e('0x79')]&&_0x157fb0[_0xd46e('0x7a')](_0x5a8661,_0x417068[_0x50750f][_0xd46e('0x79')]===_0xd46e('0x8b')?![]:!![]);_0x157fb0[_0xd46e('0x6a')](_0x5a8661,_0x417068[_0x50750f][_0xd46e('0x7b')]||_0x5a8661);}if(_0x3a44da[_0xd46e('0x7c')]){_0x3a44da['joins']=JSON[_0xd46e('0x82')](_0x3a44da[_0xd46e('0x7c')]);for(var _0x3c819b=0x0;_0x3c819b<_0x3a44da[_0xd46e('0x7c')][_0xd46e('0x3d')];_0x3c819b+=0x1){if(_0x3a44da['joins'][_0x3c819b][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0x20cc4c,_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x36')])&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7d')]&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')]&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b]['foreignKey']){_0x157fb0[_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x36')]](_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')],null,util['format']('%s.%s\x20=\x20%s.%s',_0x3a44da[_0xd46e('0x72')],_0x3a44da['joins'][_0x3c819b][_0xd46e('0x7d')],_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')],_0x3a44da[_0xd46e('0x7c')][_0x3c819b]['foreignKey']));}}}if(_0x3a44da[_0xd46e('0x81')]){_0x3a44da[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0x3a44da[_0xd46e('0x81')]);_0x157fb0[_0xd46e('0x41')](_0x44322f(_0x3a44da[_0xd46e('0x81')][_0xd46e('0x69')]));}_0xe729b6=_0x157fb0[_0xd46e('0x83')]();_0x157fb0[_0xd46e('0x1f')](_0x1610bd);_0x157fb0['offset'](0x0);logger['debug'](_0xd46e('0xa4'),_0x157fb0['toString']());return dbH[_0xd46e('0x9e')][_0xd46e('0x38')](_0x157fb0[_0xd46e('0x84')](),{'type':dbH['sequelize'][_0xd46e('0x85')][_0xd46e('0x86')]});}})[_0xd46e('0x27')](function(){return{'sql':_0xe729b6['toString']()};})['then'](respondWithResult(_0x537c73,null))[_0xd46e('0x4a')](handleError(_0x537c73,null));};
\ No newline at end of file