Built motion from commit 9d7072cc.|2.5.39
[motion2.git] / server / api / analyticCustomReport / analyticCustomReport.controller.js
index be3d534..0736133 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb03e=['../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','get','CustomReports','UserProfileResource','status','stack','index','map','AnalyticCustomReport','rawAttributes','type','model','name','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','pick','filter','merge','where','VIRTUAL','options','includeAll','include','rows','catch','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','preview','join','left_join','right_join','SUM(%s)','COUNT(%s)','MAX(%s)','MIN(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','DATE(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','rules','operator','group','condition','value','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','findAll','keyBy','from','MetricId','metric','field','replace','format','orderBy','order','DESC','alias','joins','parse','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','debug','Limited\x20Query:','toString','sequelize','QueryTypes','SELECT','cross_join','AVG(%s)','HOUR(%s)','IS\x20NOT\x20EMPTY','getFields','table','function','clone','output','fullPath','%s-%s.%s','randomstring','generate','custom','AnalyticExtractedReport','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','fork','../../components/export/','countTable','COUNT(*)','run','runReport','COUNT(DISTINCT\x20%s)','select','groupBy','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis'];(function(_0x5afa73,_0x5413f3){var _0x398a08=function(_0x241d7d){while(--_0x241d7d){_0x5afa73['push'](_0x5afa73['shift']());}};_0x398a08(++_0x5413f3);}(_0xb03e,0x1eb));var _0xeb03=function(_0x54c347,_0x3cdd3c){_0x54c347=_0x54c347-0x0;var _0x1711e7=_0xb03e[_0x54c347];return _0x1711e7;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xeb03('0x0'));var zipdir=require(_0xeb03('0x1'));var jsonpatch=require(_0xeb03('0x2'));var rp=require(_0xeb03('0x3'));var moment=require(_0xeb03('0x4'));var BPromise=require(_0xeb03('0x5'));var Mustache=require(_0xeb03('0x6'));var util=require(_0xeb03('0x7'));var path=require(_0xeb03('0x8'));var sox=require(_0xeb03('0x9'));var csv=require(_0xeb03('0xa'));var ejs=require(_0xeb03('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xeb03('0xc'));var squel=require(_0xeb03('0xd'));var crypto=require(_0xeb03('0xe'));var jsforce=require(_0xeb03('0xf'));var deskjs=require(_0xeb03('0x10'));var toCsv=require(_0xeb03('0xa'));var querystring=require('querystring');var Papa=require(_0xeb03('0x11'));var Redis=require(_0xeb03('0x12'));var authService=require(_0xeb03('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0xeb03('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xeb03('0x15'))(_0xeb03('0x16'));var utils=require(_0xeb03('0x17'));var config=require(_0xeb03('0x18'));var licenseUtil=require(_0xeb03('0x19'));var db=require(_0xeb03('0x1a'))['db'];var dbH=require(_0xeb03('0x1a'))[_0xeb03('0x1b')];function respondWithStatusCode(_0x97f46d,_0x2422fd){_0x2422fd=_0x2422fd||0xcc;return function(_0x39ab62){if(_0x39ab62){return _0x97f46d[_0xeb03('0x1c')](_0x2422fd);}return _0x97f46d['status'](_0x2422fd)[_0xeb03('0x1d')]();};}function respondWithResult(_0x100bef,_0x372c71){_0x372c71=_0x372c71||0xc8;return function(_0x33f9ba){if(_0x33f9ba){return _0x100bef['status'](_0x372c71)[_0xeb03('0x1e')](_0x33f9ba);}};}function respondWithFilteredResult(_0x36f5d8,_0x3f26ef){return function(_0x478989){if(_0x478989){var _0x7ce874=typeof _0x3f26ef[_0xeb03('0x1f')]===_0xeb03('0x20')&&typeof _0x3f26ef[_0xeb03('0x21')]===_0xeb03('0x20');var _0x1b4cbd=_0x478989[_0xeb03('0x22')];var _0x8d6725=_0x7ce874?0x0:_0x3f26ef[_0xeb03('0x1f')];var _0x469d25=_0x7ce874?_0x478989[_0xeb03('0x22')]:_0x3f26ef[_0xeb03('0x1f')]+_0x3f26ef[_0xeb03('0x21')];var _0x19bddf;if(_0x469d25>=_0x1b4cbd){_0x469d25=_0x1b4cbd;_0x19bddf=0xc8;}else{_0x19bddf=0xce;}_0x36f5d8['status'](_0x19bddf);return _0x36f5d8[_0xeb03('0x23')](_0xeb03('0x24'),_0x8d6725+'-'+_0x469d25+'/'+_0x1b4cbd)[_0xeb03('0x1e')](_0x478989);}return null;};}function patchUpdates(_0x391729){return function(_0xe5a1c2){try{jsonpatch[_0xeb03('0x25')](_0xe5a1c2,_0x391729,!![]);}catch(_0xb98dc1){return BPromise[_0xeb03('0x26')](_0xb98dc1);}return _0xe5a1c2[_0xeb03('0x27')]();};}function saveUpdates(_0x5a704b,_0x712ac2){return function(_0x1707ec){if(_0x1707ec){return _0x1707ec[_0xeb03('0x28')](_0x5a704b)[_0xeb03('0x29')](function(_0x2f99e6){return _0x2f99e6;});}return null;};}function removeEntity(_0x5dcda3,_0x638353){return function(_0x406864){if(_0x406864){return _0x406864[_0xeb03('0x2a')]()[_0xeb03('0x29')](function(){var _0x3f276a=_0x406864[_0xeb03('0x2b')]({'plain':!![]});var _0xb04f34=_0xeb03('0x2c');return db[_0xeb03('0x2d')]['destroy']({'where':{'type':_0xb04f34,'resourceId':_0x3f276a['id']}})[_0xeb03('0x29')](function(){return _0x406864;});})[_0xeb03('0x29')](function(){_0x5dcda3[_0xeb03('0x2e')](0xcc)[_0xeb03('0x1d')]();});}};}function handleEntityNotFound(_0x4cdea6,_0x581685){return function(_0x1064a5){if(!_0x1064a5){_0x4cdea6['sendStatus'](0x194);}return _0x1064a5;};}function handleError(_0x31a622,_0x8bd544){_0x8bd544=_0x8bd544||0x1f4;return function(_0x160a37){logger['error'](_0x160a37[_0xeb03('0x2f')]);if(_0x160a37['name']){delete _0x160a37['name'];}_0x31a622['status'](_0x8bd544)['send'](_0x160a37);};}exports[_0xeb03('0x30')]=function(_0x433ce8,_0x5d0cc1){var _0x528479={},_0x4d830a={},_0x47f7d8={'count':0x0,'rows':[]};var _0x1e8009=_[_0xeb03('0x31')](db[_0xeb03('0x32')][_0xeb03('0x33')],function(_0x19fa35){return{'name':_0x19fa35['fieldName'],'type':_0x19fa35[_0xeb03('0x34')]['key']};});_0x4d830a[_0xeb03('0x35')]=_[_0xeb03('0x31')](_0x1e8009,_0xeb03('0x36'));_0x4d830a[_0xeb03('0x37')]=_[_0xeb03('0x38')](_0x433ce8[_0xeb03('0x37')]);_0x4d830a[_0xeb03('0x39')]=_[_0xeb03('0x3a')](_0x4d830a['model'],_0x4d830a[_0xeb03('0x37')]);_0x528479['attributes']=_[_0xeb03('0x3a')](_0x4d830a[_0xeb03('0x35')],qs[_0xeb03('0x3b')](_0x433ce8[_0xeb03('0x37')][_0xeb03('0x3b')]));_0x528479[_0xeb03('0x3c')]=_0x528479['attributes'][_0xeb03('0x3d')]?_0x528479['attributes']:_0x4d830a['model'];if(!_0x433ce8['query'][_0xeb03('0x3e')](_0xeb03('0x3f'))){_0x528479[_0xeb03('0x21')]=qs[_0xeb03('0x21')](_0x433ce8[_0xeb03('0x37')]['limit']);_0x528479[_0xeb03('0x1f')]=qs[_0xeb03('0x1f')](_0x433ce8[_0xeb03('0x37')]['offset']);}_0x528479['order']=qs[_0xeb03('0x40')](_0x433ce8[_0xeb03('0x37')][_0xeb03('0x40')]);_0x528479['where']=qs[_0xeb03('0x39')](_[_0xeb03('0x41')](_0x433ce8['query'],_0x4d830a['filters']),_0x1e8009);if(_0x433ce8[_0xeb03('0x37')][_0xeb03('0x42')]){_0x528479['where']=_[_0xeb03('0x43')](_0x528479[_0xeb03('0x44')],{'$or':_[_0xeb03('0x31')](_0x1e8009,function(_0x1d28ec){if(_0x1d28ec[_0xeb03('0x34')]!==_0xeb03('0x45')){var _0x278529={};_0x278529[_0x1d28ec[_0xeb03('0x36')]]={'$like':'%'+_0x433ce8[_0xeb03('0x37')][_0xeb03('0x42')]+'%'};return _0x278529;}})});}_0x528479=_[_0xeb03('0x43')]({},_0x528479,_0x433ce8[_0xeb03('0x46')]);var _0x2a9348={'where':_0x528479[_0xeb03('0x44')]};return db[_0xeb03('0x32')][_0xeb03('0x22')](_0x2a9348)[_0xeb03('0x29')](function(_0x3f93ef){_0x47f7d8[_0xeb03('0x22')]=_0x3f93ef;if(_0x433ce8[_0xeb03('0x37')][_0xeb03('0x47')]){_0x528479[_0xeb03('0x48')]=[{'all':!![]}];}return db[_0xeb03('0x32')]['findAll'](_0x528479);})['then'](function(_0x44aa30){_0x47f7d8[_0xeb03('0x49')]=_0x44aa30;return _0x47f7d8;})[_0xeb03('0x29')](respondWithFilteredResult(_0x5d0cc1,_0x528479))[_0xeb03('0x4a')](handleError(_0x5d0cc1,null));};exports[_0xeb03('0x4b')]=function(_0x39ab97,_0x103c78){var _0xcd049b={'raw':![],'where':{'id':_0x39ab97[_0xeb03('0x4c')]['id']}},_0x5d91c1={};_0x5d91c1[_0xeb03('0x35')]=_[_0xeb03('0x38')](db[_0xeb03('0x32')][_0xeb03('0x33')]);_0x5d91c1['query']=_['keys'](_0x39ab97[_0xeb03('0x37')]);_0x5d91c1['filters']=_['intersection'](_0x5d91c1['model'],_0x5d91c1[_0xeb03('0x37')]);_0xcd049b[_0xeb03('0x3c')]=_[_0xeb03('0x3a')](_0x5d91c1[_0xeb03('0x35')],qs[_0xeb03('0x3b')](_0x39ab97[_0xeb03('0x37')]['fields']));_0xcd049b[_0xeb03('0x3c')]=_0xcd049b['attributes']['length']?_0xcd049b[_0xeb03('0x3c')]:_0x5d91c1[_0xeb03('0x35')];if(_0x39ab97[_0xeb03('0x37')]['includeAll']){_0xcd049b[_0xeb03('0x48')]=[{'all':!![]}];}_0xcd049b=_[_0xeb03('0x43')]({},_0xcd049b,_0x39ab97[_0xeb03('0x46')]);return db[_0xeb03('0x32')][_0xeb03('0x4d')](_0xcd049b)['then'](handleEntityNotFound(_0x103c78,null))[_0xeb03('0x29')](respondWithResult(_0x103c78,null))['catch'](handleError(_0x103c78,null));};exports[_0xeb03('0x4e')]=function(_0x2c99d0,_0x14f1d0){return db[_0xeb03('0x32')][_0xeb03('0x4e')](_0x2c99d0[_0xeb03('0x4f')],{})[_0xeb03('0x29')](function(_0x292319){var _0x38c993=_0x2c99d0[_0xeb03('0x50')][_0xeb03('0x2b')]({'plain':!![]});if(!_0x38c993)throw new Error(_0xeb03('0x51'));if(_0x38c993[_0xeb03('0x52')]===_0xeb03('0x50')){var _0x2a7eaf=_0x292319[_0xeb03('0x2b')]({'plain':!![]});var _0xf5c1ab=_0xeb03('0x53');return db[_0xeb03('0x54')][_0xeb03('0x4d')]({'where':{'name':_0xf5c1ab,'userProfileId':_0x38c993[_0xeb03('0x55')]},'raw':!![]})[_0xeb03('0x29')](function(_0x1761ab){if(_0x1761ab&&_0x1761ab[_0xeb03('0x56')]===0x0){return db['UserProfileResource'][_0xeb03('0x4e')]({'name':_0x2a7eaf[_0xeb03('0x36')],'resourceId':_0x2a7eaf['id'],'type':_0xeb03('0x2c'),'sectionId':_0x1761ab['id']},{})['then'](function(){return _0x292319;});}else{return _0x292319;}})[_0xeb03('0x4a')](function(_0x3604e8){logger[_0xeb03('0x57')](_0xeb03('0x58'),_0x3604e8);throw _0x3604e8;});}return _0x292319;})[_0xeb03('0x29')](respondWithResult(_0x14f1d0,0xc9))[_0xeb03('0x4a')](handleError(_0x14f1d0,null));};exports[_0xeb03('0x28')]=function(_0x36f18e,_0x1fe50a){if(_0x36f18e[_0xeb03('0x4f')]['id']){delete _0x36f18e[_0xeb03('0x4f')]['id'];}return db[_0xeb03('0x32')][_0xeb03('0x4d')]({'where':{'id':_0x36f18e[_0xeb03('0x4c')]['id']}})['then'](handleEntityNotFound(_0x1fe50a,null))[_0xeb03('0x29')](saveUpdates(_0x36f18e[_0xeb03('0x4f')],null))[_0xeb03('0x29')](respondWithResult(_0x1fe50a,null))[_0xeb03('0x4a')](handleError(_0x1fe50a,null));};exports[_0xeb03('0x2a')]=function(_0x39e2c7,_0x4320f7){return db[_0xeb03('0x32')][_0xeb03('0x4d')]({'where':{'id':_0x39e2c7[_0xeb03('0x4c')]['id']}})['then'](handleEntityNotFound(_0x4320f7,null))[_0xeb03('0x29')](removeEntity(_0x4320f7,null))[_0xeb03('0x4a')](handleError(_0x4320f7,null));};exports[_0xeb03('0x59')]=function(_0x62105a,_0x58c096){var _0x24a0c5=0xa;var _0x68e1b7=[_0xeb03('0x5a'),_0xeb03('0x5b'),_0xeb03('0x5c'),'cross_join'];var _0x43efc3={'SUM':_0xeb03('0x5d'),'COUNT':_0xeb03('0x5e'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xeb03('0x5f'),'MIN':_0xeb03('0x60'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xeb03('0x61'),'GROUP_CONCAT ASC':_0xeb03('0x62'),'GROUP_CONCAT DESC':_0xeb03('0x63')};var _0x5693cf={'SEC_TO_TIME':_0xeb03('0x64'),'DATE':_0xeb03('0x65'),'HOUR':'HOUR(%s)','ROUND':_0xeb03('0x66'),'UNIX_TIMESTAMP':_0xeb03('0x67')};var _0x1972fb=function(_0x3ac2de){return!_[_0xeb03('0x68')]([_0xeb03('0x69'),_0xeb03('0x6a'),_0xeb03('0x6b'),'IS\x20NOT\x20EMPTY'],_0x3ac2de);};var _0x4447b6=function(_0x50489b){if(!_0x50489b||!_0x50489b[_0xeb03('0x6c')][_0xeb03('0x3d')]){return'';}for(var _0x3a9518='(',_0x59d0c7=0x0;_0x59d0c7<_0x50489b[_0xeb03('0x6c')][_0xeb03('0x3d')];_0x59d0c7+=0x1){_0x59d0c7>0x0&&(_0x3a9518+='\x20'+_0x50489b[_0xeb03('0x6d')]+'\x20');_0x3a9518+=_0x50489b[_0xeb03('0x6c')][_0x59d0c7]['group']?_0x4447b6(_0x50489b[_0xeb03('0x6c')][_0x59d0c7][_0xeb03('0x6e')]):_0x50489b['rules'][_0x59d0c7]['field']+'\x20'+_0x50489b['rules'][_0x59d0c7][_0xeb03('0x6f')]+(_0x1972fb(_0x50489b[_0xeb03('0x6c')][_0x59d0c7][_0xeb03('0x6f')])?'\x20'+_0x50489b[_0xeb03('0x6c')][_0x59d0c7][_0xeb03('0x70')]:'');}return _0x3a9518+')';};var _0x461777={'where':{'id':_0x62105a[_0xeb03('0x4c')]['id']}},_0x443fc9,_0x240178,_0x2c78dd,_0x57c435,_0x484398;_0x461777=_[_0xeb03('0x43')]({},_0x461777,_0x62105a['options']);return db[_0xeb03('0x32')][_0xeb03('0x4d')](_0x461777)[_0xeb03('0x29')](function(_0x1890aa){if(_0x1890aa){_0x443fc9=_0x1890aa;return _0x1890aa['getFields']();}return null;})['then'](function(_0x21a182){if(_0x21a182){if(!_0x21a182[_0xeb03('0x3d')]){throw new db[(_0xeb03('0x71'))][(_0xeb03('0x72'))](_0xeb03('0x73'),0x193);}_0x240178=_0x21a182;return db[_0xeb03('0x74')][_0xeb03('0x75')]({'raw':!![]});}return null;})[_0xeb03('0x29')](function(_0x2e67a4){if(_0x2e67a4){_0x2c78dd=_[_0xeb03('0x76')](_0x2e67a4,'id');var _0x46fba8;var _0x53b7ac=squel['select']();_0x53b7ac[_0xeb03('0x77')](_0x443fc9['table']);for(var _0x1099ff=0x0;_0x1099ff<_0x240178['length'];_0x1099ff+=0x1){_0x46fba8=_0x240178[_0x1099ff][_0xeb03('0x78')]?_0x2c78dd[_0x240178[_0x1099ff]['MetricId']][_0xeb03('0x79')]:_0x240178[_0x1099ff][_0xeb03('0x7a')];_0x46fba8=_0x240178[_0x1099ff]['function']?_[_0xeb03('0x7b')](_0x43efc3[_0x240178[_0x1099ff]['function']],'%s',_0x46fba8):_0x46fba8;_0x46fba8=_0x240178[_0x1099ff][_0xeb03('0x7c')]?_['replace'](_0x5693cf[_0x240178[_0x1099ff][_0xeb03('0x7c')]],'%s',_0x46fba8):_0x46fba8;if(_0x240178[_0x1099ff]['groupBy']){_0x53b7ac['group'](_0x46fba8);}_0x240178[_0x1099ff][_0xeb03('0x7d')]&&_0x53b7ac[_0xeb03('0x7e')](_0x46fba8,_0x240178[_0x1099ff][_0xeb03('0x7d')]===_0xeb03('0x7f')?![]:!![]);_0x53b7ac[_0xeb03('0x7a')](_0x46fba8,_0x240178[_0x1099ff][_0xeb03('0x80')]||_0x46fba8);}if(_0x443fc9[_0xeb03('0x81')]){_0x443fc9['joins']=JSON[_0xeb03('0x82')](_0x443fc9[_0xeb03('0x81')]);for(var _0x1c0735=0x0;_0x1c0735<_0x443fc9[_0xeb03('0x81')][_0xeb03('0x3d')];_0x1c0735+=0x1){if(_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x34')]&&_['includes'](_0x68e1b7,_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x34')])&&_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x83')]&&_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x84')]&&_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x85')]){_0x53b7ac[_0x443fc9['joins'][_0x1c0735][_0xeb03('0x34')]](_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x84')],null,util[_0xeb03('0x7c')](_0xeb03('0x86'),_0x443fc9['table'],_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x83')],_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x84')],_0x443fc9[_0xeb03('0x81')][_0x1c0735][_0xeb03('0x85')]));}}}if(_0x443fc9[_0xeb03('0x87')]){_0x443fc9['conditions']=JSON[_0xeb03('0x82')](_0x443fc9[_0xeb03('0x87')]);_0x53b7ac[_0xeb03('0x44')](_0x4447b6(_0x443fc9[_0xeb03('0x87')][_0xeb03('0x6e')]));}_0x484398=_0x53b7ac['clone']();_0x53b7ac[_0xeb03('0x21')](_0x24a0c5);_0x53b7ac[_0xeb03('0x1f')](0x0);logger[_0xeb03('0x88')](_0xeb03('0x89'),_0x53b7ac[_0xeb03('0x8a')]());return dbH[_0xeb03('0x8b')][_0xeb03('0x37')](_0x53b7ac['toString'](),{'type':dbH[_0xeb03('0x8b')][_0xeb03('0x8c')][_0xeb03('0x8d')]});}})[_0xeb03('0x29')](respondWithResult(_0x58c096,null))[_0xeb03('0x4a')](handleError(_0x58c096,null));};function runReport(_0x388fbd,_0x5e3318,_0xf472a1){var _0x1a7bf0=_0x5e3318[_0xeb03('0x36')];var _0x48b6e9=0xa;var _0x349c15=[_0xeb03('0x5a'),_0xeb03('0x5b'),_0xeb03('0x5c'),_0xeb03('0x8e')];var _0x248468={'SUM':_0xeb03('0x5d'),'COUNT':'COUNT(%s)','COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xeb03('0x5f'),'MIN':_0xeb03('0x60'),'AVG':_0xeb03('0x8f'),'GROUP_CONCAT':_0xeb03('0x61'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xeb03('0x63')};var _0x42c477={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xeb03('0x65'),'HOUR':_0xeb03('0x90'),'ROUND':_0xeb03('0x66'),'UNIX_TIMESTAMP':_0xeb03('0x67')};var _0xda9cb6=function(_0x8b7fb){return!_['includes']([_0xeb03('0x69'),_0xeb03('0x6a'),_0xeb03('0x6b'),_0xeb03('0x91')],_0x8b7fb);};var _0xe2c7f7=function(_0x2f60b4){if(!_0x2f60b4||!_0x2f60b4[_0xeb03('0x6c')][_0xeb03('0x3d')]){return'';}for(var _0x1cec91='(',_0x3fd8c9=0x0;_0x3fd8c9<_0x2f60b4['rules'][_0xeb03('0x3d')];_0x3fd8c9+=0x1){_0x3fd8c9>0x0&&(_0x1cec91+='\x20'+_0x2f60b4[_0xeb03('0x6d')]+'\x20');_0x1cec91+=_0x2f60b4['rules'][_0x3fd8c9][_0xeb03('0x6e')]?_0xe2c7f7(_0x2f60b4[_0xeb03('0x6c')][_0x3fd8c9]['group']):_0x2f60b4[_0xeb03('0x6c')][_0x3fd8c9][_0xeb03('0x7a')]+'\x20'+_0x2f60b4[_0xeb03('0x6c')][_0x3fd8c9][_0xeb03('0x6f')]+(_0xda9cb6(_0x2f60b4[_0xeb03('0x6c')][_0x3fd8c9]['condition'])?'\x20'+_0x2f60b4['rules'][_0x3fd8c9]['value']:'');}return _0x1cec91+')';};var _0x3cead5={'where':{'id':_0x388fbd['id']}},_0x4d7e0f,_0x155d0a,_0x2c8705,_0x22d094,_0x37e510;_0x3cead5=_[_0xeb03('0x43')]({},_0x3cead5,_0xf472a1);return db[_0xeb03('0x32')][_0xeb03('0x4d')](_0x3cead5)[_0xeb03('0x29')](function(_0x25e79e){if(_0x25e79e){_0x4d7e0f=_0x25e79e;return _0x25e79e[_0xeb03('0x92')]();}return null;})[_0xeb03('0x29')](function(_0x27a388){if(_0x27a388){if(!_0x27a388['length']){throw new db['Sequelize'][(_0xeb03('0x72'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x155d0a=_0x27a388;return db['AnalyticMetric'][_0xeb03('0x75')]({'raw':!![]});}return null;})[_0xeb03('0x29')](function(_0x502b25){if(_0x502b25){_0x2c8705=_['keyBy'](_0x502b25,'id');var _0x41eadc;var _0xc53874=squel['select']();_0xc53874[_0xeb03('0x77')](_0x4d7e0f[_0xeb03('0x93')]);for(var _0x2efed6=0x0;_0x2efed6<_0x155d0a[_0xeb03('0x3d')];_0x2efed6+=0x1){_0x41eadc=_0x155d0a[_0x2efed6][_0xeb03('0x78')]?_0x2c8705[_0x155d0a[_0x2efed6]['MetricId']][_0xeb03('0x79')]:_0x155d0a[_0x2efed6]['field'];_0x41eadc=_0x155d0a[_0x2efed6]['function']?_[_0xeb03('0x7b')](_0x248468[_0x155d0a[_0x2efed6][_0xeb03('0x94')]],'%s',_0x41eadc):_0x41eadc;_0x41eadc=_0x155d0a[_0x2efed6][_0xeb03('0x7c')]?_[_0xeb03('0x7b')](_0x42c477[_0x155d0a[_0x2efed6]['format']],'%s',_0x41eadc):_0x41eadc;if(_0x155d0a[_0x2efed6]['groupBy']){_0xc53874[_0xeb03('0x6e')](_0x41eadc);}_0x155d0a[_0x2efed6][_0xeb03('0x7d')]&&_0xc53874[_0xeb03('0x7e')](_0x41eadc,_0x155d0a[_0x2efed6][_0xeb03('0x7d')]===_0xeb03('0x7f')?![]:!![]);_0xc53874[_0xeb03('0x7a')](_0x41eadc,_0x155d0a[_0x2efed6][_0xeb03('0x80')]||_0x41eadc);}if(_0x4d7e0f[_0xeb03('0x81')]){_0x4d7e0f['joins']=JSON['parse'](_0x4d7e0f[_0xeb03('0x81')]);for(var _0x5741d4=0x0;_0x5741d4<_0x4d7e0f[_0xeb03('0x81')]['length'];_0x5741d4+=0x1){if(_0x4d7e0f[_0xeb03('0x81')][_0x5741d4][_0xeb03('0x34')]&&_[_0xeb03('0x68')](_0x349c15,_0x4d7e0f[_0xeb03('0x81')][_0x5741d4][_0xeb03('0x34')])&&_0x4d7e0f[_0xeb03('0x81')][_0x5741d4][_0xeb03('0x83')]&&_0x4d7e0f[_0xeb03('0x81')][_0x5741d4]['foreignTable']&&_0x4d7e0f['joins'][_0x5741d4][_0xeb03('0x85')]){_0xc53874[_0x4d7e0f[_0xeb03('0x81')][_0x5741d4][_0xeb03('0x34')]](_0x4d7e0f[_0xeb03('0x81')][_0x5741d4][_0xeb03('0x84')],null,util['format'](_0xeb03('0x86'),_0x4d7e0f[_0xeb03('0x93')],_0x4d7e0f['joins'][_0x5741d4][_0xeb03('0x83')],_0x4d7e0f[_0xeb03('0x81')][_0x5741d4][_0xeb03('0x84')],_0x4d7e0f[_0xeb03('0x81')][_0x5741d4][_0xeb03('0x85')]));}}}if(_0x4d7e0f[_0xeb03('0x87')]){_0x4d7e0f[_0xeb03('0x87')]=JSON[_0xeb03('0x82')](_0x4d7e0f[_0xeb03('0x87')]);_0xc53874[_0xeb03('0x44')](_0xe2c7f7(_0x4d7e0f[_0xeb03('0x87')][_0xeb03('0x6e')]));}_0x37e510=_0xc53874[_0xeb03('0x95')]();_0xc53874[_0xeb03('0x21')](_0x48b6e9);_0xc53874['offset'](0x0);return;}})[_0xeb03('0x29')](function(){if(_0x5e3318[_0xeb03('0x96')]==='web'){return null;}var _0x1f3ee1=_['merge'](_0x5e3318,{'name':_0x5e3318[_0xeb03('0x97')]||_0x5e3318['name']||_0x4d7e0f[_0xeb03('0x36')],'basename':_0x1a7bf0,'savename':util[_0xeb03('0x7c')](_0xeb03('0x98'),_0x5e3318[_0xeb03('0x36')]||_0x4d7e0f[_0xeb03('0x36')],require(_0xeb03('0x99'))[_0xeb03('0x9a')](0x4),_0x5e3318[_0xeb03('0x96')]||'csv'),'reportId':_0x4d7e0f['id'],'reportType':_0xeb03('0x9b')});return db[_0xeb03('0x9c')][_0xeb03('0x4e')](_0x1f3ee1,{'raw':!![]});})[_0xeb03('0x29')](function(_0x5759fe){if(_0x4d7e0f[_0xeb03('0x93')]==='cdr'){_0x37e510[_0xeb03('0x44')](_0x4d7e0f[_0xeb03('0x93')]+_0xeb03('0x9d'),_0x5e3318[_0xeb03('0x9e')],_0x5e3318['endDate']);}else{_0x37e510[_0xeb03('0x44')](_0x4d7e0f[_0xeb03('0x93')]+_0xeb03('0x9f'),_0x5e3318[_0xeb03('0x9e')],_0x5e3318['endDate']);}if(_0x5759fe){logger[_0xeb03('0xa0')]('Run\x20Query:',_0x37e510[_0xeb03('0x8a')]());require('child_process')[_0xeb03('0xa1')](path['join'](__dirname,_0xeb03('0xa2'),_0x5759fe[_0xeb03('0x96')]),[_0x5759fe['id'],_0x37e510[_0xeb03('0x8a')](),path['join'](__dirname,'../../files/reports',_0x5759fe['savename']),_0x1a7bf0]);return _0x5759fe;}else{var _0x50b2c5=squel['select']();_0x50b2c5[_0xeb03('0x77')]('('+_0x37e510[_0xeb03('0x8a')]()+')',_0xeb03('0xa3'));_0x50b2c5[_0xeb03('0x7a')](_0xeb03('0xa4'),_0xeb03('0x22'));_0x37e510['limit'](_0x5e3318[_0xeb03('0x21')]||_0x48b6e9);_0x37e510[_0xeb03('0x1f')](_0x5e3318[_0xeb03('0x1f')]||0x0);return dbH[_0xeb03('0x8b')]['query'](_0x50b2c5['toString'](),{'type':dbH[_0xeb03('0x8b')][_0xeb03('0x8c')]['SELECT']})[_0xeb03('0x29')](function(_0x2ebd1a){if(!_0x2ebd1a[_0xeb03('0x3d')]){_0x22d094=0x0;}else{_0x22d094=_0x2ebd1a[0x0][_0xeb03('0x22')]||0x0;}return dbH[_0xeb03('0x8b')][_0xeb03('0x37')](_0x37e510[_0xeb03('0x8a')](),{'type':dbH['sequelize'][_0xeb03('0x8c')][_0xeb03('0x8d')]});})[_0xeb03('0x29')](function(_0x2fbeae){return{'rows':_0x2fbeae||[],'count':_0x22d094};});}});}exports[_0xeb03('0xa5')]=function(_0x16a366,_0x30f740){return runReport(_0x16a366[_0xeb03('0x4c')],_0x16a366['query'],_0x16a366[_0xeb03('0x46')])['then'](respondWithResult(_0x30f740,null))['catch'](handleError(_0x30f740,null));};exports[_0xeb03('0xa6')]=runReport;exports[_0xeb03('0x37')]=function(_0x4b92b8,_0x22a544){var _0x4cd18c=0xa;var _0xc3d089=['join',_0xeb03('0x5b'),_0xeb03('0x5c'),_0xeb03('0x8e')];var _0x1522d4={'SUM':_0xeb03('0x5d'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xeb03('0xa7'),'MAX':_0xeb03('0x5f'),'MIN':_0xeb03('0x60'),'AVG':_0xeb03('0x8f'),'GROUP_CONCAT':_0xeb03('0x61'),'GROUP_CONCAT ASC':_0xeb03('0x62'),'GROUP_CONCAT DESC':_0xeb03('0x63')};var _0x464a37={'SEC_TO_TIME':_0xeb03('0x64'),'DATE':'DATE(%s)','HOUR':'HOUR(%s)','ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xeb03('0x67')};var _0x40a6ce=function(_0x400e5b){return!_[_0xeb03('0x68')](['IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY',_0xeb03('0x91')],_0x400e5b);};var _0x22e88d=function(_0x2c89c4){if(!_0x2c89c4||!_0x2c89c4[_0xeb03('0x6c')][_0xeb03('0x3d')]){return'';}for(var _0x47b6f2='(',_0x4057b8=0x0;_0x4057b8<_0x2c89c4[_0xeb03('0x6c')]['length'];_0x4057b8+=0x1){_0x4057b8>0x0&&(_0x47b6f2+='\x20'+_0x2c89c4[_0xeb03('0x6d')]+'\x20');_0x47b6f2+=_0x2c89c4['rules'][_0x4057b8]['group']?_0x22e88d(_0x2c89c4[_0xeb03('0x6c')][_0x4057b8][_0xeb03('0x6e')]):_0x2c89c4[_0xeb03('0x6c')][_0x4057b8]['field']+'\x20'+_0x2c89c4[_0xeb03('0x6c')][_0x4057b8][_0xeb03('0x6f')]+(_0x40a6ce(_0x2c89c4['rules'][_0x4057b8][_0xeb03('0x6f')])?'\x20'+_0x2c89c4['rules'][_0x4057b8]['value']:'');}return _0x47b6f2+')';};var _0x301b97={'where':{'id':_0x4b92b8['params']['id']}},_0x119356,_0x366054,_0x131815,_0x143350,_0x1d9efd;_0x301b97=_[_0xeb03('0x43')]({},_0x301b97,_0x4b92b8[_0xeb03('0x46')]);return db[_0xeb03('0x32')][_0xeb03('0x4d')](_0x301b97)[_0xeb03('0x29')](function(_0x3e438f){if(_0x3e438f){_0x119356=_0x3e438f;return _0x3e438f[_0xeb03('0x92')]();}return null;})[_0xeb03('0x29')](function(_0x164994){if(_0x164994){if(!_0x164994[_0xeb03('0x3d')]){throw new db[(_0xeb03('0x71'))][(_0xeb03('0x72'))](_0xeb03('0x73'),0x193);}_0x366054=_0x164994;return db[_0xeb03('0x74')][_0xeb03('0x75')]({'raw':!![]});}return null;})[_0xeb03('0x29')](function(_0x24e088){if(_0x24e088){_0x131815=_[_0xeb03('0x76')](_0x24e088,'id');var _0x1d68f1;var _0x42b815=squel[_0xeb03('0xa8')]();_0x42b815[_0xeb03('0x77')](_0x119356['table']);for(var _0x3417af=0x0;_0x3417af<_0x366054['length'];_0x3417af+=0x1){_0x1d68f1=_0x366054[_0x3417af][_0xeb03('0x78')]?_0x131815[_0x366054[_0x3417af][_0xeb03('0x78')]][_0xeb03('0x79')]:_0x366054[_0x3417af][_0xeb03('0x7a')];_0x1d68f1=_0x366054[_0x3417af][_0xeb03('0x94')]?_[_0xeb03('0x7b')](_0x1522d4[_0x366054[_0x3417af]['function']],'%s',_0x1d68f1):_0x1d68f1;_0x1d68f1=_0x366054[_0x3417af][_0xeb03('0x7c')]?_[_0xeb03('0x7b')](_0x464a37[_0x366054[_0x3417af]['format']],'%s',_0x1d68f1):_0x1d68f1;if(_0x366054[_0x3417af][_0xeb03('0xa9')]){_0x42b815['group'](_0x1d68f1);}_0x366054[_0x3417af][_0xeb03('0x7d')]&&_0x42b815[_0xeb03('0x7e')](_0x1d68f1,_0x366054[_0x3417af][_0xeb03('0x7d')]===_0xeb03('0x7f')?![]:!![]);_0x42b815[_0xeb03('0x7a')](_0x1d68f1,_0x366054[_0x3417af][_0xeb03('0x80')]||_0x1d68f1);}if(_0x119356[_0xeb03('0x81')]){_0x119356['joins']=JSON[_0xeb03('0x82')](_0x119356[_0xeb03('0x81')]);for(var _0xf30c4d=0x0;_0xf30c4d<_0x119356[_0xeb03('0x81')][_0xeb03('0x3d')];_0xf30c4d+=0x1){if(_0x119356[_0xeb03('0x81')][_0xf30c4d][_0xeb03('0x34')]&&_[_0xeb03('0x68')](_0xc3d089,_0x119356[_0xeb03('0x81')][_0xf30c4d][_0xeb03('0x34')])&&_0x119356[_0xeb03('0x81')][_0xf30c4d][_0xeb03('0x83')]&&_0x119356[_0xeb03('0x81')][_0xf30c4d][_0xeb03('0x84')]&&_0x119356['joins'][_0xf30c4d]['foreignKey']){_0x42b815[_0x119356[_0xeb03('0x81')][_0xf30c4d][_0xeb03('0x34')]](_0x119356[_0xeb03('0x81')][_0xf30c4d][_0xeb03('0x84')],null,util[_0xeb03('0x7c')]('%s.%s\x20=\x20%s.%s',_0x119356[_0xeb03('0x93')],_0x119356['joins'][_0xf30c4d][_0xeb03('0x83')],_0x119356[_0xeb03('0x81')][_0xf30c4d][_0xeb03('0x84')],_0x119356[_0xeb03('0x81')][_0xf30c4d][_0xeb03('0x85')]));}}}if(_0x119356[_0xeb03('0x87')]){_0x119356['conditions']=JSON[_0xeb03('0x82')](_0x119356[_0xeb03('0x87')]);_0x42b815[_0xeb03('0x44')](_0x22e88d(_0x119356[_0xeb03('0x87')][_0xeb03('0x6e')]));}_0x1d9efd=_0x42b815[_0xeb03('0x95')]();_0x42b815[_0xeb03('0x21')](_0x4cd18c);_0x42b815[_0xeb03('0x1f')](0x0);logger['debug'](_0xeb03('0x89'),_0x42b815[_0xeb03('0x8a')]());return dbH['sequelize'][_0xeb03('0x37')](_0x42b815['toString'](),{'type':dbH[_0xeb03('0x8b')][_0xeb03('0x8c')][_0xeb03('0x8d')]});}})[_0xeb03('0x29')](function(){return{'sql':_0x1d9efd[_0xeb03('0x8a')]()};})[_0xeb03('0x29')](respondWithResult(_0x22a544,null))[_0xeb03('0x4a')](handleError(_0x22a544,null));};
\ No newline at end of file
+var _0xb55d=['value','getFields','orderBy','output','web','fullPath','%s-%s.%s','randomstring','custom','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','../../components/export/','../../files/reports','savename','select','countTable','COUNT(*)','sequelize','run','ROUND(%s)','Please\x20insert\x20at\x20least\x20one\x20field','metric','eml-format','rimraf','moment','bluebird','mustache','path','fs-extra','lodash','squel','crypto','jsforce','to-csv','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','CustomReports','UserProfileResource','destroy','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','options','AnalyticCustomReport','include','findAll','catch','length','includeAll','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','left_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','DATE(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','Sequelize','ValidationErrorItem','AnalyticMetric','keyBy','from','table','MetricId','function','replace','format','groupBy','DESC','alias','joins','parse','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','clone','debug','Limited\x20Query:','toString','QueryTypes','SELECT','join','right_join','cross_join','AVG(%s)','SEC_TO_TIME(%s)','includes'];(function(_0x1a8a08,_0x2b8318){var _0x266ba3=function(_0x281561){while(--_0x281561){_0x1a8a08['push'](_0x1a8a08['shift']());}};_0x266ba3(++_0x2b8318);}(_0xb55d,0x15a));var _0xdb55=function(_0x5b19b9,_0x3ae40c){_0x5b19b9=_0x5b19b9-0x0;var _0xb673f5=_0xb55d[_0x5b19b9];return _0xb673f5;};'use strict';var emlformat=require(_0xdb55('0x0'));var rimraf=require(_0xdb55('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xdb55('0x2'));var BPromise=require(_0xdb55('0x3'));var Mustache=require(_0xdb55('0x4'));var util=require('util');var path=require(_0xdb55('0x5'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xdb55('0x6'));var _=require(_0xdb55('0x7'));var squel=require(_0xdb55('0x8'));var crypto=require(_0xdb55('0x9'));var jsforce=require(_0xdb55('0xa'));var deskjs=require('desk.js');var toCsv=require(_0xdb55('0xb'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xdb55('0xc'));var authService=require('../../components/auth/service');var qs=require(_0xdb55('0xd'));var as=require(_0xdb55('0xe'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0xdb55('0xf'));var licenseUtil=require(_0xdb55('0x10'));var db=require(_0xdb55('0x11'))['db'];var dbH=require(_0xdb55('0x11'))[_0xdb55('0x12')];function respondWithStatusCode(_0x149a28,_0x199d71){_0x199d71=_0x199d71||0xcc;return function(_0x277f1c){if(_0x277f1c){return _0x149a28[_0xdb55('0x13')](_0x199d71);}return _0x149a28[_0xdb55('0x14')](_0x199d71)[_0xdb55('0x15')]();};}function respondWithResult(_0x35576a,_0x4c8b4c){_0x4c8b4c=_0x4c8b4c||0xc8;return function(_0x1b23b5){if(_0x1b23b5){return _0x35576a['status'](_0x4c8b4c)[_0xdb55('0x16')](_0x1b23b5);}};}function respondWithFilteredResult(_0x226096,_0x3c759a){return function(_0x147b2d){if(_0x147b2d){var _0x4609ad=typeof _0x3c759a[_0xdb55('0x17')]===_0xdb55('0x18')&&typeof _0x3c759a[_0xdb55('0x19')]===_0xdb55('0x18');var _0x451bbd=_0x147b2d['count'];var _0x12bbee=_0x4609ad?0x0:_0x3c759a[_0xdb55('0x17')];var _0x46ed9c=_0x4609ad?_0x147b2d[_0xdb55('0x1a')]:_0x3c759a[_0xdb55('0x17')]+_0x3c759a[_0xdb55('0x19')];var _0x2f4507;if(_0x46ed9c>=_0x451bbd){_0x46ed9c=_0x451bbd;_0x2f4507=0xc8;}else{_0x2f4507=0xce;}_0x226096[_0xdb55('0x14')](_0x2f4507);return _0x226096[_0xdb55('0x1b')](_0xdb55('0x1c'),_0x12bbee+'-'+_0x46ed9c+'/'+_0x451bbd)[_0xdb55('0x16')](_0x147b2d);}return null;};}function patchUpdates(_0x4d5197){return function(_0x3215a0){try{jsonpatch[_0xdb55('0x1d')](_0x3215a0,_0x4d5197,!![]);}catch(_0x4c91de){return BPromise[_0xdb55('0x1e')](_0x4c91de);}return _0x3215a0[_0xdb55('0x1f')]();};}function saveUpdates(_0x5440cb,_0x236938){return function(_0x6fdc49){if(_0x6fdc49){return _0x6fdc49[_0xdb55('0x20')](_0x5440cb)[_0xdb55('0x21')](function(_0x514e15){return _0x514e15;});}return null;};}function removeEntity(_0x2130e7,_0x196ef2){return function(_0x30a6e1){if(_0x30a6e1){return _0x30a6e1['destroy']()[_0xdb55('0x21')](function(){var _0x3b300d=_0x30a6e1['get']({'plain':!![]});var _0x373c38=_0xdb55('0x22');return db[_0xdb55('0x23')][_0xdb55('0x24')]({'where':{'type':_0x373c38,'resourceId':_0x3b300d['id']}})['then'](function(){return _0x30a6e1;});})['then'](function(){_0x2130e7[_0xdb55('0x14')](0xcc)[_0xdb55('0x15')]();});}};}function handleEntityNotFound(_0x30d4be,_0x35c445){return function(_0x54ee00){if(!_0x54ee00){_0x30d4be[_0xdb55('0x13')](0x194);}return _0x54ee00;};}function handleError(_0x1fc51c,_0x4e3e6a){_0x4e3e6a=_0x4e3e6a||0x1f4;return function(_0x1f7c12){logger[_0xdb55('0x25')](_0x1f7c12[_0xdb55('0x26')]);if(_0x1f7c12[_0xdb55('0x27')]){delete _0x1f7c12[_0xdb55('0x27')];}_0x1fc51c['status'](_0x4e3e6a)[_0xdb55('0x28')](_0x1f7c12);};}exports[_0xdb55('0x29')]=function(_0x4789bb,_0x2a028d){var _0x1605d5={},_0x4ab399={},_0x58944e={'count':0x0,'rows':[]};var _0xe940ef=_[_0xdb55('0x2a')](db['AnalyticCustomReport'][_0xdb55('0x2b')],function(_0x213e96){return{'name':_0x213e96[_0xdb55('0x2c')],'type':_0x213e96[_0xdb55('0x2d')][_0xdb55('0x2e')]};});_0x4ab399[_0xdb55('0x2f')]=_[_0xdb55('0x2a')](_0xe940ef,_0xdb55('0x27'));_0x4ab399['query']=_[_0xdb55('0x30')](_0x4789bb[_0xdb55('0x31')]);_0x4ab399[_0xdb55('0x32')]=_[_0xdb55('0x33')](_0x4ab399['model'],_0x4ab399[_0xdb55('0x31')]);_0x1605d5['attributes']=_['intersection'](_0x4ab399[_0xdb55('0x2f')],qs[_0xdb55('0x34')](_0x4789bb[_0xdb55('0x31')][_0xdb55('0x34')]));_0x1605d5[_0xdb55('0x35')]=_0x1605d5[_0xdb55('0x35')]['length']?_0x1605d5[_0xdb55('0x35')]:_0x4ab399[_0xdb55('0x2f')];if(!_0x4789bb[_0xdb55('0x31')][_0xdb55('0x36')](_0xdb55('0x37'))){_0x1605d5[_0xdb55('0x19')]=qs[_0xdb55('0x19')](_0x4789bb[_0xdb55('0x31')]['limit']);_0x1605d5[_0xdb55('0x17')]=qs['offset'](_0x4789bb[_0xdb55('0x31')]['offset']);}_0x1605d5[_0xdb55('0x38')]=qs['sort'](_0x4789bb[_0xdb55('0x31')][_0xdb55('0x39')]);_0x1605d5[_0xdb55('0x3a')]=qs[_0xdb55('0x32')](_[_0xdb55('0x3b')](_0x4789bb[_0xdb55('0x31')],_0x4ab399[_0xdb55('0x32')]),_0xe940ef);if(_0x4789bb[_0xdb55('0x31')]['filter']){_0x1605d5['where']=_[_0xdb55('0x3c')](_0x1605d5['where'],{'$or':_['map'](_0xe940ef,function(_0x4e581a){if(_0x4e581a[_0xdb55('0x2d')]!==_0xdb55('0x3d')){var _0x39d468={};_0x39d468[_0x4e581a[_0xdb55('0x27')]]={'$like':'%'+_0x4789bb[_0xdb55('0x31')]['filter']+'%'};return _0x39d468;}})});}_0x1605d5=_[_0xdb55('0x3c')]({},_0x1605d5,_0x4789bb[_0xdb55('0x3e')]);var _0x4ce63d={'where':_0x1605d5['where']};return db[_0xdb55('0x3f')]['count'](_0x4ce63d)['then'](function(_0x1c60f8){_0x58944e[_0xdb55('0x1a')]=_0x1c60f8;if(_0x4789bb[_0xdb55('0x31')]['includeAll']){_0x1605d5[_0xdb55('0x40')]=[{'all':!![]}];}return db[_0xdb55('0x3f')][_0xdb55('0x41')](_0x1605d5);})[_0xdb55('0x21')](function(_0x529290){_0x58944e['rows']=_0x529290;return _0x58944e;})[_0xdb55('0x21')](respondWithFilteredResult(_0x2a028d,_0x1605d5))[_0xdb55('0x42')](handleError(_0x2a028d,null));};exports['show']=function(_0x5a2390,_0x1b0eaa){var _0xa025ea={'raw':![],'where':{'id':_0x5a2390['params']['id']}},_0x4fabb2={};_0x4fabb2[_0xdb55('0x2f')]=_['keys'](db[_0xdb55('0x3f')][_0xdb55('0x2b')]);_0x4fabb2[_0xdb55('0x31')]=_[_0xdb55('0x30')](_0x5a2390[_0xdb55('0x31')]);_0x4fabb2[_0xdb55('0x32')]=_['intersection'](_0x4fabb2[_0xdb55('0x2f')],_0x4fabb2['query']);_0xa025ea['attributes']=_[_0xdb55('0x33')](_0x4fabb2[_0xdb55('0x2f')],qs[_0xdb55('0x34')](_0x5a2390[_0xdb55('0x31')][_0xdb55('0x34')]));_0xa025ea[_0xdb55('0x35')]=_0xa025ea[_0xdb55('0x35')][_0xdb55('0x43')]?_0xa025ea[_0xdb55('0x35')]:_0x4fabb2[_0xdb55('0x2f')];if(_0x5a2390['query'][_0xdb55('0x44')]){_0xa025ea['include']=[{'all':!![]}];}_0xa025ea=_[_0xdb55('0x3c')]({},_0xa025ea,_0x5a2390[_0xdb55('0x3e')]);return db[_0xdb55('0x3f')][_0xdb55('0x45')](_0xa025ea)[_0xdb55('0x21')](handleEntityNotFound(_0x1b0eaa,null))['then'](respondWithResult(_0x1b0eaa,null))[_0xdb55('0x42')](handleError(_0x1b0eaa,null));};exports[_0xdb55('0x46')]=function(_0x17fd72,_0x2e89a1){return db[_0xdb55('0x3f')][_0xdb55('0x46')](_0x17fd72[_0xdb55('0x47')],{})['then'](function(_0x337905){var _0x81fcbe=_0x17fd72[_0xdb55('0x48')][_0xdb55('0x49')]({'plain':!![]});if(!_0x81fcbe)throw new Error(_0xdb55('0x4a'));if(_0x81fcbe[_0xdb55('0x4b')]===_0xdb55('0x48')){var _0x56c4fb=_0x337905[_0xdb55('0x49')]({'plain':!![]});var _0xb8fcb=_0xdb55('0x4c');return db['UserProfileSection'][_0xdb55('0x45')]({'where':{'name':_0xb8fcb,'userProfileId':_0x81fcbe[_0xdb55('0x4d')]},'raw':!![]})['then'](function(_0x2d0811){if(_0x2d0811&&_0x2d0811[_0xdb55('0x4e')]===0x0){return db[_0xdb55('0x23')][_0xdb55('0x46')]({'name':_0x56c4fb[_0xdb55('0x27')],'resourceId':_0x56c4fb['id'],'type':_0xdb55('0x22'),'sectionId':_0x2d0811['id']},{})[_0xdb55('0x21')](function(){return _0x337905;});}else{return _0x337905;}})[_0xdb55('0x42')](function(_0x4f08db){logger[_0xdb55('0x25')](_0xdb55('0x4f'),_0x4f08db);throw _0x4f08db;});}return _0x337905;})[_0xdb55('0x21')](respondWithResult(_0x2e89a1,0xc9))['catch'](handleError(_0x2e89a1,null));};exports['update']=function(_0x20d3c4,_0x2af30e){if(_0x20d3c4[_0xdb55('0x47')]['id']){delete _0x20d3c4[_0xdb55('0x47')]['id'];}return db[_0xdb55('0x3f')][_0xdb55('0x45')]({'where':{'id':_0x20d3c4[_0xdb55('0x50')]['id']}})['then'](handleEntityNotFound(_0x2af30e,null))[_0xdb55('0x21')](saveUpdates(_0x20d3c4[_0xdb55('0x47')],null))[_0xdb55('0x21')](respondWithResult(_0x2af30e,null))[_0xdb55('0x42')](handleError(_0x2af30e,null));};exports[_0xdb55('0x24')]=function(_0x27c649,_0x1932d9){return db[_0xdb55('0x3f')]['find']({'where':{'id':_0x27c649['params']['id']}})[_0xdb55('0x21')](handleEntityNotFound(_0x1932d9,null))[_0xdb55('0x21')](removeEntity(_0x1932d9,null))['catch'](handleError(_0x1932d9,null));};exports['preview']=function(_0xa0e355,_0x5003aa){var _0x256046=0xa;var _0x47c81e=['join',_0xdb55('0x51'),'right_join','cross_join'];var _0x6cc650={'SUM':_0xdb55('0x52'),'COUNT':_0xdb55('0x53'),'COUNT DISTINCT':_0xdb55('0x54'),'MAX':_0xdb55('0x55'),'MIN':_0xdb55('0x56'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xdb55('0x57'),'GROUP_CONCAT ASC':_0xdb55('0x58'),'GROUP_CONCAT DESC':_0xdb55('0x59')};var _0x5edce8={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xdb55('0x5a'),'HOUR':_0xdb55('0x5b'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xdb55('0x5c')};var _0x57a739=function(_0x48f1dd){return!_['includes']([_0xdb55('0x5d'),_0xdb55('0x5e'),_0xdb55('0x5f'),_0xdb55('0x60')],_0x48f1dd);};var _0x335125=function(_0x504ae4){if(!_0x504ae4||!_0x504ae4[_0xdb55('0x61')][_0xdb55('0x43')]){return'';}for(var _0x5be74b='(',_0x47205f=0x0;_0x47205f<_0x504ae4[_0xdb55('0x61')][_0xdb55('0x43')];_0x47205f+=0x1){_0x47205f>0x0&&(_0x5be74b+='\x20'+_0x504ae4[_0xdb55('0x62')]+'\x20');_0x5be74b+=_0x504ae4[_0xdb55('0x61')][_0x47205f][_0xdb55('0x63')]?_0x335125(_0x504ae4[_0xdb55('0x61')][_0x47205f][_0xdb55('0x63')]):_0x504ae4[_0xdb55('0x61')][_0x47205f][_0xdb55('0x64')]+'\x20'+_0x504ae4[_0xdb55('0x61')][_0x47205f][_0xdb55('0x65')]+(_0x57a739(_0x504ae4['rules'][_0x47205f][_0xdb55('0x65')])?'\x20'+_0x504ae4[_0xdb55('0x61')][_0x47205f]['value']:'');}return _0x5be74b+')';};var _0x1a2b47={'where':{'id':_0xa0e355[_0xdb55('0x50')]['id']}},_0x5249f1,_0x4db433,_0x15c18e,_0x27f306,_0x3db97e;_0x1a2b47=_[_0xdb55('0x3c')]({},_0x1a2b47,_0xa0e355['options']);return db[_0xdb55('0x3f')][_0xdb55('0x45')](_0x1a2b47)[_0xdb55('0x21')](function(_0x2f2355){if(_0x2f2355){_0x5249f1=_0x2f2355;return _0x2f2355['getFields']();}return null;})[_0xdb55('0x21')](function(_0x46c12e){if(_0x46c12e){if(!_0x46c12e[_0xdb55('0x43')]){throw new db[(_0xdb55('0x66'))][(_0xdb55('0x67'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x4db433=_0x46c12e;return db[_0xdb55('0x68')]['findAll']({'raw':!![]});}return null;})[_0xdb55('0x21')](function(_0x26b2dd){if(_0x26b2dd){_0x15c18e=_[_0xdb55('0x69')](_0x26b2dd,'id');var _0x49449e;var _0x3a0611=squel['select']();_0x3a0611[_0xdb55('0x6a')](_0x5249f1[_0xdb55('0x6b')]);for(var _0x2d158e=0x0;_0x2d158e<_0x4db433[_0xdb55('0x43')];_0x2d158e+=0x1){_0x49449e=_0x4db433[_0x2d158e][_0xdb55('0x6c')]?_0x15c18e[_0x4db433[_0x2d158e][_0xdb55('0x6c')]]['metric']:_0x4db433[_0x2d158e][_0xdb55('0x64')];_0x49449e=_0x4db433[_0x2d158e][_0xdb55('0x6d')]?_[_0xdb55('0x6e')](_0x6cc650[_0x4db433[_0x2d158e][_0xdb55('0x6d')]],'%s',_0x49449e):_0x49449e;_0x49449e=_0x4db433[_0x2d158e][_0xdb55('0x6f')]?_[_0xdb55('0x6e')](_0x5edce8[_0x4db433[_0x2d158e]['format']],'%s',_0x49449e):_0x49449e;if(_0x4db433[_0x2d158e][_0xdb55('0x70')]){_0x3a0611[_0xdb55('0x63')](_0x49449e);}_0x4db433[_0x2d158e]['orderBy']&&_0x3a0611['order'](_0x49449e,_0x4db433[_0x2d158e]['orderBy']===_0xdb55('0x71')?![]:!![]);_0x3a0611[_0xdb55('0x64')](_0x49449e,_0x4db433[_0x2d158e][_0xdb55('0x72')]||_0x49449e);}if(_0x5249f1[_0xdb55('0x73')]){_0x5249f1[_0xdb55('0x73')]=JSON[_0xdb55('0x74')](_0x5249f1[_0xdb55('0x73')]);for(var _0x33e473=0x0;_0x33e473<_0x5249f1[_0xdb55('0x73')][_0xdb55('0x43')];_0x33e473+=0x1){if(_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x2d')]&&_['includes'](_0x47c81e,_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x2d')])&&_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x75')]&&_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x76')]&&_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x77')]){_0x3a0611[_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x2d')]](_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x76')],null,util['format'](_0xdb55('0x78'),_0x5249f1[_0xdb55('0x6b')],_0x5249f1['joins'][_0x33e473]['parentKey'],_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x76')],_0x5249f1[_0xdb55('0x73')][_0x33e473][_0xdb55('0x77')]));}}}if(_0x5249f1[_0xdb55('0x79')]){_0x5249f1[_0xdb55('0x79')]=JSON[_0xdb55('0x74')](_0x5249f1[_0xdb55('0x79')]);_0x3a0611[_0xdb55('0x3a')](_0x335125(_0x5249f1[_0xdb55('0x79')]['group']));}_0x3db97e=_0x3a0611[_0xdb55('0x7a')]();_0x3a0611[_0xdb55('0x19')](_0x256046);_0x3a0611['offset'](0x0);logger[_0xdb55('0x7b')](_0xdb55('0x7c'),_0x3a0611['toString']());return dbH['sequelize']['query'](_0x3a0611[_0xdb55('0x7d')](),{'type':dbH['sequelize'][_0xdb55('0x7e')][_0xdb55('0x7f')]});}})['then'](respondWithResult(_0x5003aa,null))[_0xdb55('0x42')](handleError(_0x5003aa,null));};function runReport(_0x29d7b4,_0x3848e9,_0x5316fe){var _0xf5355e=_0x3848e9[_0xdb55('0x27')];var _0x417828=0xa;var _0x10b3cd=[_0xdb55('0x80'),_0xdb55('0x51'),_0xdb55('0x81'),_0xdb55('0x82')];var _0x5f4453={'SUM':_0xdb55('0x52'),'COUNT':_0xdb55('0x53'),'COUNT DISTINCT':_0xdb55('0x54'),'MAX':_0xdb55('0x55'),'MIN':_0xdb55('0x56'),'AVG':_0xdb55('0x83'),'GROUP_CONCAT':_0xdb55('0x57'),'GROUP_CONCAT ASC':_0xdb55('0x58'),'GROUP_CONCAT DESC':_0xdb55('0x59')};var _0x3b3c0c={'SEC_TO_TIME':_0xdb55('0x84'),'DATE':_0xdb55('0x5a'),'HOUR':_0xdb55('0x5b'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xdb55('0x5c')};var _0x1bf95d=function(_0x4d4c26){return!_[_0xdb55('0x85')]([_0xdb55('0x5d'),_0xdb55('0x5e'),_0xdb55('0x5f'),'IS\x20NOT\x20EMPTY'],_0x4d4c26);};var _0xc8277=function(_0x284481){if(!_0x284481||!_0x284481['rules'][_0xdb55('0x43')]){return'';}for(var _0x3a8f4b='(',_0x3924b8=0x0;_0x3924b8<_0x284481[_0xdb55('0x61')]['length'];_0x3924b8+=0x1){_0x3924b8>0x0&&(_0x3a8f4b+='\x20'+_0x284481['operator']+'\x20');_0x3a8f4b+=_0x284481['rules'][_0x3924b8][_0xdb55('0x63')]?_0xc8277(_0x284481[_0xdb55('0x61')][_0x3924b8][_0xdb55('0x63')]):_0x284481[_0xdb55('0x61')][_0x3924b8]['field']+'\x20'+_0x284481[_0xdb55('0x61')][_0x3924b8][_0xdb55('0x65')]+(_0x1bf95d(_0x284481[_0xdb55('0x61')][_0x3924b8][_0xdb55('0x65')])?'\x20'+_0x284481['rules'][_0x3924b8][_0xdb55('0x86')]:'');}return _0x3a8f4b+')';};var _0x5dda95={'where':{'id':_0x29d7b4['id']}},_0x29ab0d,_0x58f60e,_0x5a041e,_0x69683d,_0x49b5bd;_0x5dda95=_[_0xdb55('0x3c')]({},_0x5dda95,_0x5316fe);return db[_0xdb55('0x3f')][_0xdb55('0x45')](_0x5dda95)[_0xdb55('0x21')](function(_0x25b5ec){if(_0x25b5ec){_0x29ab0d=_0x25b5ec;return _0x25b5ec[_0xdb55('0x87')]();}return null;})[_0xdb55('0x21')](function(_0x1d9f23){if(_0x1d9f23){if(!_0x1d9f23[_0xdb55('0x43')]){throw new db[(_0xdb55('0x66'))]['ValidationErrorItem']('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x58f60e=_0x1d9f23;return db[_0xdb55('0x68')][_0xdb55('0x41')]({'raw':!![]});}return null;})['then'](function(_0x63e6ae){if(_0x63e6ae){_0x5a041e=_['keyBy'](_0x63e6ae,'id');var _0x530714;var _0x206352=squel['select']();_0x206352[_0xdb55('0x6a')](_0x29ab0d[_0xdb55('0x6b')]);for(var _0x241a03=0x0;_0x241a03<_0x58f60e[_0xdb55('0x43')];_0x241a03+=0x1){_0x530714=_0x58f60e[_0x241a03][_0xdb55('0x6c')]?_0x5a041e[_0x58f60e[_0x241a03][_0xdb55('0x6c')]]['metric']:_0x58f60e[_0x241a03][_0xdb55('0x64')];_0x530714=_0x58f60e[_0x241a03][_0xdb55('0x6d')]?_[_0xdb55('0x6e')](_0x5f4453[_0x58f60e[_0x241a03]['function']],'%s',_0x530714):_0x530714;_0x530714=_0x58f60e[_0x241a03][_0xdb55('0x6f')]?_['replace'](_0x3b3c0c[_0x58f60e[_0x241a03]['format']],'%s',_0x530714):_0x530714;if(_0x58f60e[_0x241a03]['groupBy']){_0x206352['group'](_0x530714);}_0x58f60e[_0x241a03][_0xdb55('0x88')]&&_0x206352[_0xdb55('0x38')](_0x530714,_0x58f60e[_0x241a03][_0xdb55('0x88')]==='DESC'?![]:!![]);_0x206352[_0xdb55('0x64')](_0x530714,_0x58f60e[_0x241a03]['alias']||_0x530714);}if(_0x29ab0d[_0xdb55('0x73')]){_0x29ab0d[_0xdb55('0x73')]=JSON['parse'](_0x29ab0d['joins']);for(var _0x1f62e9=0x0;_0x1f62e9<_0x29ab0d[_0xdb55('0x73')]['length'];_0x1f62e9+=0x1){if(_0x29ab0d[_0xdb55('0x73')][_0x1f62e9]['type']&&_[_0xdb55('0x85')](_0x10b3cd,_0x29ab0d[_0xdb55('0x73')][_0x1f62e9][_0xdb55('0x2d')])&&_0x29ab0d[_0xdb55('0x73')][_0x1f62e9][_0xdb55('0x75')]&&_0x29ab0d[_0xdb55('0x73')][_0x1f62e9][_0xdb55('0x76')]&&_0x29ab0d[_0xdb55('0x73')][_0x1f62e9][_0xdb55('0x77')]){_0x206352[_0x29ab0d[_0xdb55('0x73')][_0x1f62e9]['type']](_0x29ab0d['joins'][_0x1f62e9][_0xdb55('0x76')],null,util[_0xdb55('0x6f')](_0xdb55('0x78'),_0x29ab0d[_0xdb55('0x6b')],_0x29ab0d['joins'][_0x1f62e9]['parentKey'],_0x29ab0d[_0xdb55('0x73')][_0x1f62e9][_0xdb55('0x76')],_0x29ab0d['joins'][_0x1f62e9]['foreignKey']));}}}if(_0x29ab0d['conditions']){_0x29ab0d[_0xdb55('0x79')]=JSON[_0xdb55('0x74')](_0x29ab0d['conditions']);_0x206352[_0xdb55('0x3a')](_0xc8277(_0x29ab0d[_0xdb55('0x79')]['group']));}_0x49b5bd=_0x206352[_0xdb55('0x7a')]();_0x206352[_0xdb55('0x19')](_0x417828);_0x206352[_0xdb55('0x17')](0x0);return;}})['then'](function(){if(_0x3848e9[_0xdb55('0x89')]===_0xdb55('0x8a')){return null;}var _0x20e523=_[_0xdb55('0x3c')](_0x3848e9,{'name':_0x3848e9[_0xdb55('0x8b')]||_0x3848e9[_0xdb55('0x27')]||_0x29ab0d[_0xdb55('0x27')],'basename':_0xf5355e,'savename':util['format'](_0xdb55('0x8c'),_0x3848e9['name']||_0x29ab0d[_0xdb55('0x27')],require(_0xdb55('0x8d'))['generate'](0x4),_0x3848e9['output']||'csv'),'reportId':_0x29ab0d['id'],'reportType':_0xdb55('0x8e')});return db[_0xdb55('0x8f')][_0xdb55('0x46')](_0x20e523,{'raw':!![]});})[_0xdb55('0x21')](function(_0x50a8e7){if(_0x29ab0d[_0xdb55('0x6b')]===_0xdb55('0x90')){_0x49b5bd[_0xdb55('0x3a')](_0x29ab0d[_0xdb55('0x6b')]+_0xdb55('0x91'),_0x3848e9[_0xdb55('0x92')],_0x3848e9['endDate']);}else{_0x49b5bd[_0xdb55('0x3a')](_0x29ab0d['table']+_0xdb55('0x93'),_0x3848e9[_0xdb55('0x92')],_0x3848e9['endDate']);}if(_0x50a8e7){logger[_0xdb55('0x94')]('Run\x20Query:',_0x49b5bd['toString']());require('child_process')['fork'](path[_0xdb55('0x80')](__dirname,_0xdb55('0x95'),_0x50a8e7['output']),[_0x50a8e7['id'],_0x49b5bd['toString'](),path[_0xdb55('0x80')](__dirname,_0xdb55('0x96'),_0x50a8e7[_0xdb55('0x97')]),_0xf5355e]);return _0x50a8e7;}else{var _0xa526af=squel[_0xdb55('0x98')]();_0xa526af['from']('('+_0x49b5bd[_0xdb55('0x7d')]()+')',_0xdb55('0x99'));_0xa526af[_0xdb55('0x64')](_0xdb55('0x9a'),_0xdb55('0x1a'));_0x49b5bd[_0xdb55('0x19')](_0x3848e9[_0xdb55('0x19')]||_0x417828);_0x49b5bd[_0xdb55('0x17')](_0x3848e9['offset']||0x0);return dbH[_0xdb55('0x9b')][_0xdb55('0x31')](_0xa526af[_0xdb55('0x7d')](),{'type':dbH[_0xdb55('0x9b')][_0xdb55('0x7e')][_0xdb55('0x7f')]})['then'](function(_0xd5fcb8){if(!_0xd5fcb8[_0xdb55('0x43')]){_0x69683d=0x0;}else{_0x69683d=_0xd5fcb8[0x0][_0xdb55('0x1a')]||0x0;}return dbH[_0xdb55('0x9b')]['query'](_0x49b5bd['toString'](),{'type':dbH[_0xdb55('0x9b')][_0xdb55('0x7e')][_0xdb55('0x7f')]});})[_0xdb55('0x21')](function(_0x5be3c7){return{'rows':_0x5be3c7||[],'count':_0x69683d};});}});}exports[_0xdb55('0x9c')]=function(_0x1e23fa,_0x26a20f){return runReport(_0x1e23fa[_0xdb55('0x50')],_0x1e23fa[_0xdb55('0x31')],_0x1e23fa['options'])[_0xdb55('0x21')](respondWithResult(_0x26a20f,null))[_0xdb55('0x42')](handleError(_0x26a20f,null));};exports['runReport']=runReport;exports[_0xdb55('0x31')]=function(_0x55f1fa,_0x30fe81){var _0x361fda=0xa;var _0x439f5d=[_0xdb55('0x80'),_0xdb55('0x51'),_0xdb55('0x81'),_0xdb55('0x82')];var _0x11494f={'SUM':_0xdb55('0x52'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xdb55('0x54'),'MAX':_0xdb55('0x55'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xdb55('0x57'),'GROUP_CONCAT ASC':_0xdb55('0x58'),'GROUP_CONCAT DESC':_0xdb55('0x59')};var _0x363c7e={'SEC_TO_TIME':_0xdb55('0x84'),'DATE':_0xdb55('0x5a'),'HOUR':'HOUR(%s)','ROUND':_0xdb55('0x9d'),'UNIX_TIMESTAMP':_0xdb55('0x5c')};var _0x4765ea=function(_0x4c3f3b){return!_['includes']([_0xdb55('0x5d'),_0xdb55('0x5e'),_0xdb55('0x5f'),_0xdb55('0x60')],_0x4c3f3b);};var _0x5405de=function(_0x1b3dd9){if(!_0x1b3dd9||!_0x1b3dd9['rules'][_0xdb55('0x43')]){return'';}for(var _0x430a66='(',_0x4ae42d=0x0;_0x4ae42d<_0x1b3dd9[_0xdb55('0x61')][_0xdb55('0x43')];_0x4ae42d+=0x1){_0x4ae42d>0x0&&(_0x430a66+='\x20'+_0x1b3dd9['operator']+'\x20');_0x430a66+=_0x1b3dd9[_0xdb55('0x61')][_0x4ae42d][_0xdb55('0x63')]?_0x5405de(_0x1b3dd9[_0xdb55('0x61')][_0x4ae42d]['group']):_0x1b3dd9[_0xdb55('0x61')][_0x4ae42d]['field']+'\x20'+_0x1b3dd9['rules'][_0x4ae42d][_0xdb55('0x65')]+(_0x4765ea(_0x1b3dd9[_0xdb55('0x61')][_0x4ae42d][_0xdb55('0x65')])?'\x20'+_0x1b3dd9[_0xdb55('0x61')][_0x4ae42d][_0xdb55('0x86')]:'');}return _0x430a66+')';};var _0x2d5d7b={'where':{'id':_0x55f1fa[_0xdb55('0x50')]['id']}},_0x468dc4,_0x18474b,_0x17ba8c,_0x3b22f4,_0x191b56;_0x2d5d7b=_[_0xdb55('0x3c')]({},_0x2d5d7b,_0x55f1fa[_0xdb55('0x3e')]);return db[_0xdb55('0x3f')][_0xdb55('0x45')](_0x2d5d7b)['then'](function(_0x2ce5ab){if(_0x2ce5ab){_0x468dc4=_0x2ce5ab;return _0x2ce5ab[_0xdb55('0x87')]();}return null;})[_0xdb55('0x21')](function(_0x5d3991){if(_0x5d3991){if(!_0x5d3991[_0xdb55('0x43')]){throw new db['Sequelize'][(_0xdb55('0x67'))](_0xdb55('0x9e'),0x193);}_0x18474b=_0x5d3991;return db['AnalyticMetric'][_0xdb55('0x41')]({'raw':!![]});}return null;})[_0xdb55('0x21')](function(_0x4c2adf){if(_0x4c2adf){_0x17ba8c=_['keyBy'](_0x4c2adf,'id');var _0x2b0ba2;var _0x43e85f=squel[_0xdb55('0x98')]();_0x43e85f[_0xdb55('0x6a')](_0x468dc4[_0xdb55('0x6b')]);for(var _0x141351=0x0;_0x141351<_0x18474b[_0xdb55('0x43')];_0x141351+=0x1){_0x2b0ba2=_0x18474b[_0x141351]['MetricId']?_0x17ba8c[_0x18474b[_0x141351][_0xdb55('0x6c')]][_0xdb55('0x9f')]:_0x18474b[_0x141351]['field'];_0x2b0ba2=_0x18474b[_0x141351][_0xdb55('0x6d')]?_[_0xdb55('0x6e')](_0x11494f[_0x18474b[_0x141351][_0xdb55('0x6d')]],'%s',_0x2b0ba2):_0x2b0ba2;_0x2b0ba2=_0x18474b[_0x141351]['format']?_[_0xdb55('0x6e')](_0x363c7e[_0x18474b[_0x141351]['format']],'%s',_0x2b0ba2):_0x2b0ba2;if(_0x18474b[_0x141351][_0xdb55('0x70')]){_0x43e85f[_0xdb55('0x63')](_0x2b0ba2);}_0x18474b[_0x141351][_0xdb55('0x88')]&&_0x43e85f[_0xdb55('0x38')](_0x2b0ba2,_0x18474b[_0x141351][_0xdb55('0x88')]===_0xdb55('0x71')?![]:!![]);_0x43e85f[_0xdb55('0x64')](_0x2b0ba2,_0x18474b[_0x141351]['alias']||_0x2b0ba2);}if(_0x468dc4['joins']){_0x468dc4[_0xdb55('0x73')]=JSON[_0xdb55('0x74')](_0x468dc4[_0xdb55('0x73')]);for(var _0x355d4e=0x0;_0x355d4e<_0x468dc4[_0xdb55('0x73')][_0xdb55('0x43')];_0x355d4e+=0x1){if(_0x468dc4[_0xdb55('0x73')][_0x355d4e][_0xdb55('0x2d')]&&_[_0xdb55('0x85')](_0x439f5d,_0x468dc4['joins'][_0x355d4e]['type'])&&_0x468dc4[_0xdb55('0x73')][_0x355d4e]['parentKey']&&_0x468dc4['joins'][_0x355d4e][_0xdb55('0x76')]&&_0x468dc4['joins'][_0x355d4e][_0xdb55('0x77')]){_0x43e85f[_0x468dc4[_0xdb55('0x73')][_0x355d4e][_0xdb55('0x2d')]](_0x468dc4['joins'][_0x355d4e][_0xdb55('0x76')],null,util['format'](_0xdb55('0x78'),_0x468dc4['table'],_0x468dc4['joins'][_0x355d4e][_0xdb55('0x75')],_0x468dc4[_0xdb55('0x73')][_0x355d4e][_0xdb55('0x76')],_0x468dc4[_0xdb55('0x73')][_0x355d4e][_0xdb55('0x77')]));}}}if(_0x468dc4[_0xdb55('0x79')]){_0x468dc4[_0xdb55('0x79')]=JSON[_0xdb55('0x74')](_0x468dc4[_0xdb55('0x79')]);_0x43e85f[_0xdb55('0x3a')](_0x5405de(_0x468dc4['conditions'][_0xdb55('0x63')]));}_0x191b56=_0x43e85f['clone']();_0x43e85f['limit'](_0x361fda);_0x43e85f[_0xdb55('0x17')](0x0);logger[_0xdb55('0x7b')](_0xdb55('0x7c'),_0x43e85f[_0xdb55('0x7d')]());return dbH[_0xdb55('0x9b')][_0xdb55('0x31')](_0x43e85f[_0xdb55('0x7d')](),{'type':dbH[_0xdb55('0x9b')][_0xdb55('0x7e')][_0xdb55('0x7f')]});}})['then'](function(){return{'sql':_0x191b56[_0xdb55('0x7d')]()};})[_0xdb55('0x21')](respondWithResult(_0x30fe81,null))[_0xdb55('0x42')](handleError(_0x30fe81,null));};
\ No newline at end of file