Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / analyticCustomReport / analyticCustomReport.controller.js
index be3d534..670f127 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 _0x69bf=['table','MetricId','metric','function','replace','format','groupBy','orderBy','DESC','alias','joins','parse','parentKey','foreignTable','%s.%s\x20=\x20%s.%s','foreignKey','conditions','clone','debug','Limited\x20Query:','toString','sequelize','QueryTypes','SUM(%s)','IS\x20NOT\x20NULL','operator','output','web','fullPath','randomstring','generate','csv','custom','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','../../files/reports','savename','countTable','COUNT(*)','SELECT','run','runReport','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','getFields','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','get','CustomReports','UserProfileResource','error','stack','name','send','index','map','AnalyticCustomReport','fieldName','key','query','keys','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','options','includeAll','include','findAll','rows','catch','rawAttributes','length','create','user','role','Reports','UserProfileSection','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','join','left_join','right_join','cross_join','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','group','field','condition','value','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from'];(function(_0x415637,_0x44cfa4){var _0x39a799=function(_0x535a43){while(--_0x535a43){_0x415637['push'](_0x415637['shift']());}};_0x39a799(++_0x44cfa4);}(_0x69bf,0x188));var _0xf69b=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x69bf[_0x122ef9];return _0x42fba0;};'use strict';var emlformat=require(_0xf69b('0x0'));var rimraf=require(_0xf69b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf69b('0x2'));var rp=require(_0xf69b('0x3'));var moment=require(_0xf69b('0x4'));var BPromise=require(_0xf69b('0x5'));var Mustache=require(_0xf69b('0x6'));var util=require(_0xf69b('0x7'));var path=require(_0xf69b('0x8'));var sox=require(_0xf69b('0x9'));var csv=require('to-csv');var ejs=require(_0xf69b('0xa'));var fs=require('fs');var fs_extra=require(_0xf69b('0xb'));var _=require(_0xf69b('0xc'));var squel=require(_0xf69b('0xd'));var crypto=require(_0xf69b('0xe'));var jsforce=require(_0xf69b('0xf'));var deskjs=require(_0xf69b('0x10'));var toCsv=require(_0xf69b('0x11'));var querystring=require(_0xf69b('0x12'));var Papa=require(_0xf69b('0x13'));var Redis=require(_0xf69b('0x14'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xf69b('0x15'));var hardwareService=require(_0xf69b('0x16'));var logger=require('../../config/logger')(_0xf69b('0x17'));var utils=require(_0xf69b('0x18'));var config=require(_0xf69b('0x19'));var licenseUtil=require(_0xf69b('0x1a'));var db=require(_0xf69b('0x1b'))['db'];var dbH=require(_0xf69b('0x1b'))[_0xf69b('0x1c')];function respondWithStatusCode(_0xa07e0d,_0x4f4f32){_0x4f4f32=_0x4f4f32||0xcc;return function(_0x4ecbef){if(_0x4ecbef){return _0xa07e0d['sendStatus'](_0x4f4f32);}return _0xa07e0d[_0xf69b('0x1d')](_0x4f4f32)[_0xf69b('0x1e')]();};}function respondWithResult(_0xef52ff,_0x46a305){_0x46a305=_0x46a305||0xc8;return function(_0x1909d3){if(_0x1909d3){return _0xef52ff[_0xf69b('0x1d')](_0x46a305)[_0xf69b('0x1f')](_0x1909d3);}};}function respondWithFilteredResult(_0x526b22,_0x185c32){return function(_0x73789e){if(_0x73789e){var _0xabab73=typeof _0x185c32[_0xf69b('0x20')]===_0xf69b('0x21')&&typeof _0x185c32[_0xf69b('0x22')]==='undefined';var _0x4e7b6e=_0x73789e[_0xf69b('0x23')];var _0x543533=_0xabab73?0x0:_0x185c32[_0xf69b('0x20')];var _0x64d197=_0xabab73?_0x73789e[_0xf69b('0x23')]:_0x185c32[_0xf69b('0x20')]+_0x185c32[_0xf69b('0x22')];var _0x575e9f;if(_0x64d197>=_0x4e7b6e){_0x64d197=_0x4e7b6e;_0x575e9f=0xc8;}else{_0x575e9f=0xce;}_0x526b22[_0xf69b('0x1d')](_0x575e9f);return _0x526b22[_0xf69b('0x24')](_0xf69b('0x25'),_0x543533+'-'+_0x64d197+'/'+_0x4e7b6e)['json'](_0x73789e);}return null;};}function patchUpdates(_0x313e48){return function(_0x11e973){try{jsonpatch[_0xf69b('0x26')](_0x11e973,_0x313e48,!![]);}catch(_0x23c229){return BPromise[_0xf69b('0x27')](_0x23c229);}return _0x11e973[_0xf69b('0x28')]();};}function saveUpdates(_0x32a871,_0x51480d){return function(_0x529d1b){if(_0x529d1b){return _0x529d1b[_0xf69b('0x29')](_0x32a871)['then'](function(_0x4bea80){return _0x4bea80;});}return null;};}function removeEntity(_0x48d1a2,_0x377f54){return function(_0x52a971){if(_0x52a971){return _0x52a971[_0xf69b('0x2a')]()[_0xf69b('0x2b')](function(){var _0x39ad27=_0x52a971[_0xf69b('0x2c')]({'plain':!![]});var _0x54b07e=_0xf69b('0x2d');return db[_0xf69b('0x2e')]['destroy']({'where':{'type':_0x54b07e,'resourceId':_0x39ad27['id']}})[_0xf69b('0x2b')](function(){return _0x52a971;});})[_0xf69b('0x2b')](function(){_0x48d1a2[_0xf69b('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2baa06,_0x572f65){return function(_0x36fbd8){if(!_0x36fbd8){_0x2baa06['sendStatus'](0x194);}return _0x36fbd8;};}function handleError(_0x3b024f,_0x411e23){_0x411e23=_0x411e23||0x1f4;return function(_0x2471a8){logger[_0xf69b('0x2f')](_0x2471a8[_0xf69b('0x30')]);if(_0x2471a8[_0xf69b('0x31')]){delete _0x2471a8[_0xf69b('0x31')];}_0x3b024f[_0xf69b('0x1d')](_0x411e23)[_0xf69b('0x32')](_0x2471a8);};}exports[_0xf69b('0x33')]=function(_0x3a7668,_0x46ccce){var _0x39f5f9={},_0x3aaf30={},_0x11b92c={'count':0x0,'rows':[]};var _0x47b56d=_[_0xf69b('0x34')](db[_0xf69b('0x35')]['rawAttributes'],function(_0x687335){return{'name':_0x687335[_0xf69b('0x36')],'type':_0x687335['type'][_0xf69b('0x37')]};});_0x3aaf30['model']=_['map'](_0x47b56d,'name');_0x3aaf30[_0xf69b('0x38')]=_[_0xf69b('0x39')](_0x3a7668[_0xf69b('0x38')]);_0x3aaf30[_0xf69b('0x3a')]=_[_0xf69b('0x3b')](_0x3aaf30[_0xf69b('0x3c')],_0x3aaf30[_0xf69b('0x38')]);_0x39f5f9[_0xf69b('0x3d')]=_[_0xf69b('0x3b')](_0x3aaf30['model'],qs[_0xf69b('0x3e')](_0x3a7668[_0xf69b('0x38')][_0xf69b('0x3e')]));_0x39f5f9['attributes']=_0x39f5f9[_0xf69b('0x3d')]['length']?_0x39f5f9['attributes']:_0x3aaf30[_0xf69b('0x3c')];if(!_0x3a7668[_0xf69b('0x38')][_0xf69b('0x3f')](_0xf69b('0x40'))){_0x39f5f9['limit']=qs[_0xf69b('0x22')](_0x3a7668[_0xf69b('0x38')][_0xf69b('0x22')]);_0x39f5f9['offset']=qs[_0xf69b('0x20')](_0x3a7668['query'][_0xf69b('0x20')]);}_0x39f5f9[_0xf69b('0x41')]=qs[_0xf69b('0x42')](_0x3a7668[_0xf69b('0x38')]['sort']);_0x39f5f9[_0xf69b('0x43')]=qs['filters'](_[_0xf69b('0x44')](_0x3a7668[_0xf69b('0x38')],_0x3aaf30['filters']),_0x47b56d);if(_0x3a7668[_0xf69b('0x38')][_0xf69b('0x45')]){_0x39f5f9[_0xf69b('0x43')]=_[_0xf69b('0x46')](_0x39f5f9['where'],{'$or':_[_0xf69b('0x34')](_0x47b56d,function(_0xb39df1){if(_0xb39df1[_0xf69b('0x47')]!=='VIRTUAL'){var _0x27b467={};_0x27b467[_0xb39df1[_0xf69b('0x31')]]={'$like':'%'+_0x3a7668[_0xf69b('0x38')][_0xf69b('0x45')]+'%'};return _0x27b467;}})});}_0x39f5f9=_[_0xf69b('0x46')]({},_0x39f5f9,_0x3a7668[_0xf69b('0x48')]);var _0x491469={'where':_0x39f5f9[_0xf69b('0x43')]};return db[_0xf69b('0x35')][_0xf69b('0x23')](_0x491469)['then'](function(_0x58df70){_0x11b92c['count']=_0x58df70;if(_0x3a7668[_0xf69b('0x38')][_0xf69b('0x49')]){_0x39f5f9[_0xf69b('0x4a')]=[{'all':!![]}];}return db[_0xf69b('0x35')][_0xf69b('0x4b')](_0x39f5f9);})[_0xf69b('0x2b')](function(_0x126a0f){_0x11b92c[_0xf69b('0x4c')]=_0x126a0f;return _0x11b92c;})[_0xf69b('0x2b')](respondWithFilteredResult(_0x46ccce,_0x39f5f9))[_0xf69b('0x4d')](handleError(_0x46ccce,null));};exports['show']=function(_0x2838dc,_0x29bb1d){var _0x53de43={'raw':![],'where':{'id':_0x2838dc['params']['id']}},_0x3fee2e={};_0x3fee2e[_0xf69b('0x3c')]=_['keys'](db['AnalyticCustomReport'][_0xf69b('0x4e')]);_0x3fee2e[_0xf69b('0x38')]=_[_0xf69b('0x39')](_0x2838dc[_0xf69b('0x38')]);_0x3fee2e[_0xf69b('0x3a')]=_[_0xf69b('0x3b')](_0x3fee2e['model'],_0x3fee2e[_0xf69b('0x38')]);_0x53de43[_0xf69b('0x3d')]=_[_0xf69b('0x3b')](_0x3fee2e[_0xf69b('0x3c')],qs[_0xf69b('0x3e')](_0x2838dc[_0xf69b('0x38')]['fields']));_0x53de43[_0xf69b('0x3d')]=_0x53de43['attributes'][_0xf69b('0x4f')]?_0x53de43[_0xf69b('0x3d')]:_0x3fee2e[_0xf69b('0x3c')];if(_0x2838dc[_0xf69b('0x38')]['includeAll']){_0x53de43[_0xf69b('0x4a')]=[{'all':!![]}];}_0x53de43=_[_0xf69b('0x46')]({},_0x53de43,_0x2838dc[_0xf69b('0x48')]);return db[_0xf69b('0x35')]['find'](_0x53de43)[_0xf69b('0x2b')](handleEntityNotFound(_0x29bb1d,null))['then'](respondWithResult(_0x29bb1d,null))[_0xf69b('0x4d')](handleError(_0x29bb1d,null));};exports[_0xf69b('0x50')]=function(_0x2e99cd,_0x3b07d4){return db[_0xf69b('0x35')][_0xf69b('0x50')](_0x2e99cd['body'],{})['then'](function(_0x5e0d8d){var _0xe763c6=_0x2e99cd[_0xf69b('0x51')]['get']({'plain':!![]});if(!_0xe763c6)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xe763c6[_0xf69b('0x52')]===_0xf69b('0x51')){var _0x32bac3=_0x5e0d8d[_0xf69b('0x2c')]({'plain':!![]});var _0x10cb0a=_0xf69b('0x53');return db[_0xf69b('0x54')][_0xf69b('0x55')]({'where':{'name':_0x10cb0a,'userProfileId':_0xe763c6['userProfileId']},'raw':!![]})[_0xf69b('0x2b')](function(_0xcc77de){if(_0xcc77de&&_0xcc77de[_0xf69b('0x56')]===0x0){return db[_0xf69b('0x2e')][_0xf69b('0x50')]({'name':_0x32bac3[_0xf69b('0x31')],'resourceId':_0x32bac3['id'],'type':_0xf69b('0x2d'),'sectionId':_0xcc77de['id']},{})[_0xf69b('0x2b')](function(){return _0x5e0d8d;});}else{return _0x5e0d8d;}})[_0xf69b('0x4d')](function(_0x5dbdf0){logger[_0xf69b('0x2f')](_0xf69b('0x57'),_0x5dbdf0);throw _0x5dbdf0;});}return _0x5e0d8d;})[_0xf69b('0x2b')](respondWithResult(_0x3b07d4,0xc9))['catch'](handleError(_0x3b07d4,null));};exports[_0xf69b('0x29')]=function(_0x220151,_0x43fb7f){if(_0x220151[_0xf69b('0x58')]['id']){delete _0x220151[_0xf69b('0x58')]['id'];}return db[_0xf69b('0x35')][_0xf69b('0x55')]({'where':{'id':_0x220151[_0xf69b('0x59')]['id']}})[_0xf69b('0x2b')](handleEntityNotFound(_0x43fb7f,null))[_0xf69b('0x2b')](saveUpdates(_0x220151[_0xf69b('0x58')],null))[_0xf69b('0x2b')](respondWithResult(_0x43fb7f,null))[_0xf69b('0x4d')](handleError(_0x43fb7f,null));};exports[_0xf69b('0x2a')]=function(_0x53b7f3,_0x298736){return db[_0xf69b('0x35')][_0xf69b('0x55')]({'where':{'id':_0x53b7f3[_0xf69b('0x59')]['id']}})[_0xf69b('0x2b')](handleEntityNotFound(_0x298736,null))[_0xf69b('0x2b')](removeEntity(_0x298736,null))[_0xf69b('0x4d')](handleError(_0x298736,null));};exports['preview']=function(_0x3125f5,_0x2e0b43){var _0xcea84b=0xa;var _0x832b22=[_0xf69b('0x5a'),_0xf69b('0x5b'),_0xf69b('0x5c'),_0xf69b('0x5d')];var _0x289879={'SUM':'SUM(%s)','COUNT':_0xf69b('0x5e'),'COUNT DISTINCT':_0xf69b('0x5f'),'MAX':_0xf69b('0x60'),'MIN':_0xf69b('0x61'),'AVG':_0xf69b('0x62'),'GROUP_CONCAT':_0xf69b('0x63'),'GROUP_CONCAT ASC':_0xf69b('0x64'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x4d9e5c={'SEC_TO_TIME':_0xf69b('0x65'),'DATE':_0xf69b('0x66'),'HOUR':_0xf69b('0x67'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xf69b('0x68')};var _0x6975d9=function(_0x461413){return!_[_0xf69b('0x69')]([_0xf69b('0x6a'),'IS\x20NOT\x20NULL',_0xf69b('0x6b'),_0xf69b('0x6c')],_0x461413);};var _0x51d2ec=function(_0x411432){if(!_0x411432||!_0x411432[_0xf69b('0x6d')][_0xf69b('0x4f')]){return'';}for(var _0x1a3497='(',_0x103f65=0x0;_0x103f65<_0x411432[_0xf69b('0x6d')][_0xf69b('0x4f')];_0x103f65+=0x1){_0x103f65>0x0&&(_0x1a3497+='\x20'+_0x411432['operator']+'\x20');_0x1a3497+=_0x411432[_0xf69b('0x6d')][_0x103f65][_0xf69b('0x6e')]?_0x51d2ec(_0x411432[_0xf69b('0x6d')][_0x103f65]['group']):_0x411432['rules'][_0x103f65][_0xf69b('0x6f')]+'\x20'+_0x411432[_0xf69b('0x6d')][_0x103f65]['condition']+(_0x6975d9(_0x411432[_0xf69b('0x6d')][_0x103f65][_0xf69b('0x70')])?'\x20'+_0x411432[_0xf69b('0x6d')][_0x103f65][_0xf69b('0x71')]:'');}return _0x1a3497+')';};var _0x11ae47={'where':{'id':_0x3125f5[_0xf69b('0x59')]['id']}},_0x4769c8,_0x147667,_0x17d2ec,_0x5d5f3d,_0x4ff0e7;_0x11ae47=_['merge']({},_0x11ae47,_0x3125f5[_0xf69b('0x48')]);return db[_0xf69b('0x35')]['find'](_0x11ae47)[_0xf69b('0x2b')](function(_0x215118){if(_0x215118){_0x4769c8=_0x215118;return _0x215118['getFields']();}return null;})[_0xf69b('0x2b')](function(_0x506726){if(_0x506726){if(!_0x506726[_0xf69b('0x4f')]){throw new db[(_0xf69b('0x72'))][(_0xf69b('0x73'))](_0xf69b('0x74'),0x193);}_0x147667=_0x506726;return db[_0xf69b('0x75')][_0xf69b('0x4b')]({'raw':!![]});}return null;})[_0xf69b('0x2b')](function(_0x1dddaf){if(_0x1dddaf){_0x17d2ec=_[_0xf69b('0x76')](_0x1dddaf,'id');var _0x498ce9;var _0x16cc04=squel[_0xf69b('0x77')]();_0x16cc04[_0xf69b('0x78')](_0x4769c8[_0xf69b('0x79')]);for(var _0x3a52e7=0x0;_0x3a52e7<_0x147667[_0xf69b('0x4f')];_0x3a52e7+=0x1){_0x498ce9=_0x147667[_0x3a52e7][_0xf69b('0x7a')]?_0x17d2ec[_0x147667[_0x3a52e7][_0xf69b('0x7a')]][_0xf69b('0x7b')]:_0x147667[_0x3a52e7][_0xf69b('0x6f')];_0x498ce9=_0x147667[_0x3a52e7][_0xf69b('0x7c')]?_[_0xf69b('0x7d')](_0x289879[_0x147667[_0x3a52e7]['function']],'%s',_0x498ce9):_0x498ce9;_0x498ce9=_0x147667[_0x3a52e7][_0xf69b('0x7e')]?_[_0xf69b('0x7d')](_0x4d9e5c[_0x147667[_0x3a52e7][_0xf69b('0x7e')]],'%s',_0x498ce9):_0x498ce9;if(_0x147667[_0x3a52e7][_0xf69b('0x7f')]){_0x16cc04[_0xf69b('0x6e')](_0x498ce9);}_0x147667[_0x3a52e7][_0xf69b('0x80')]&&_0x16cc04[_0xf69b('0x41')](_0x498ce9,_0x147667[_0x3a52e7][_0xf69b('0x80')]===_0xf69b('0x81')?![]:!![]);_0x16cc04[_0xf69b('0x6f')](_0x498ce9,_0x147667[_0x3a52e7][_0xf69b('0x82')]||_0x498ce9);}if(_0x4769c8[_0xf69b('0x83')]){_0x4769c8['joins']=JSON[_0xf69b('0x84')](_0x4769c8['joins']);for(var _0x25c223=0x0;_0x25c223<_0x4769c8[_0xf69b('0x83')]['length'];_0x25c223+=0x1){if(_0x4769c8['joins'][_0x25c223]['type']&&_[_0xf69b('0x69')](_0x832b22,_0x4769c8[_0xf69b('0x83')][_0x25c223][_0xf69b('0x47')])&&_0x4769c8[_0xf69b('0x83')][_0x25c223][_0xf69b('0x85')]&&_0x4769c8['joins'][_0x25c223]['foreignTable']&&_0x4769c8['joins'][_0x25c223]['foreignKey']){_0x16cc04[_0x4769c8[_0xf69b('0x83')][_0x25c223][_0xf69b('0x47')]](_0x4769c8[_0xf69b('0x83')][_0x25c223][_0xf69b('0x86')],null,util[_0xf69b('0x7e')](_0xf69b('0x87'),_0x4769c8[_0xf69b('0x79')],_0x4769c8[_0xf69b('0x83')][_0x25c223][_0xf69b('0x85')],_0x4769c8[_0xf69b('0x83')][_0x25c223][_0xf69b('0x86')],_0x4769c8[_0xf69b('0x83')][_0x25c223][_0xf69b('0x88')]));}}}if(_0x4769c8[_0xf69b('0x89')]){_0x4769c8[_0xf69b('0x89')]=JSON[_0xf69b('0x84')](_0x4769c8[_0xf69b('0x89')]);_0x16cc04['where'](_0x51d2ec(_0x4769c8[_0xf69b('0x89')][_0xf69b('0x6e')]));}_0x4ff0e7=_0x16cc04[_0xf69b('0x8a')]();_0x16cc04[_0xf69b('0x22')](_0xcea84b);_0x16cc04[_0xf69b('0x20')](0x0);logger[_0xf69b('0x8b')](_0xf69b('0x8c'),_0x16cc04[_0xf69b('0x8d')]());return dbH[_0xf69b('0x8e')]['query'](_0x16cc04[_0xf69b('0x8d')](),{'type':dbH['sequelize'][_0xf69b('0x8f')]['SELECT']});}})[_0xf69b('0x2b')](respondWithResult(_0x2e0b43,null))[_0xf69b('0x4d')](handleError(_0x2e0b43,null));};function runReport(_0x415097,_0x2fb63e,_0x3aa49c){var _0x1f1127=_0x2fb63e[_0xf69b('0x31')];var _0x382f3d=0xa;var _0x1552cd=['join',_0xf69b('0x5b'),'right_join','cross_join'];var _0x5e2088={'SUM':_0xf69b('0x90'),'COUNT':_0xf69b('0x5e'),'COUNT DISTINCT':_0xf69b('0x5f'),'MAX':_0xf69b('0x60'),'MIN':_0xf69b('0x61'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xf69b('0x63'),'GROUP_CONCAT ASC':_0xf69b('0x64'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x440586={'SEC_TO_TIME':_0xf69b('0x65'),'DATE':_0xf69b('0x66'),'HOUR':'HOUR(%s)','ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xf69b('0x68')};var _0x21f85e=function(_0x1f8b32){return!_[_0xf69b('0x69')]([_0xf69b('0x6a'),_0xf69b('0x91'),_0xf69b('0x6b'),_0xf69b('0x6c')],_0x1f8b32);};var _0x486990=function(_0x475fb0){if(!_0x475fb0||!_0x475fb0[_0xf69b('0x6d')]['length']){return'';}for(var _0x100668='(',_0x1b297f=0x0;_0x1b297f<_0x475fb0[_0xf69b('0x6d')]['length'];_0x1b297f+=0x1){_0x1b297f>0x0&&(_0x100668+='\x20'+_0x475fb0[_0xf69b('0x92')]+'\x20');_0x100668+=_0x475fb0['rules'][_0x1b297f][_0xf69b('0x6e')]?_0x486990(_0x475fb0[_0xf69b('0x6d')][_0x1b297f]['group']):_0x475fb0['rules'][_0x1b297f][_0xf69b('0x6f')]+'\x20'+_0x475fb0[_0xf69b('0x6d')][_0x1b297f]['condition']+(_0x21f85e(_0x475fb0[_0xf69b('0x6d')][_0x1b297f]['condition'])?'\x20'+_0x475fb0[_0xf69b('0x6d')][_0x1b297f][_0xf69b('0x71')]:'');}return _0x100668+')';};var _0x4ae3a8={'where':{'id':_0x415097['id']}},_0x2e318e,_0x5a5f86,_0x59be68,_0x9ab2bf,_0x110832;_0x4ae3a8=_[_0xf69b('0x46')]({},_0x4ae3a8,_0x3aa49c);return db[_0xf69b('0x35')][_0xf69b('0x55')](_0x4ae3a8)[_0xf69b('0x2b')](function(_0x4328a8){if(_0x4328a8){_0x2e318e=_0x4328a8;return _0x4328a8['getFields']();}return null;})[_0xf69b('0x2b')](function(_0xa7e312){if(_0xa7e312){if(!_0xa7e312['length']){throw new db[(_0xf69b('0x72'))]['ValidationErrorItem'](_0xf69b('0x74'),0x193);}_0x5a5f86=_0xa7e312;return db[_0xf69b('0x75')][_0xf69b('0x4b')]({'raw':!![]});}return null;})[_0xf69b('0x2b')](function(_0x3710f1){if(_0x3710f1){_0x59be68=_[_0xf69b('0x76')](_0x3710f1,'id');var _0x50b836;var _0x147ba2=squel[_0xf69b('0x77')]();_0x147ba2[_0xf69b('0x78')](_0x2e318e[_0xf69b('0x79')]);for(var _0x3529a3=0x0;_0x3529a3<_0x5a5f86['length'];_0x3529a3+=0x1){_0x50b836=_0x5a5f86[_0x3529a3][_0xf69b('0x7a')]?_0x59be68[_0x5a5f86[_0x3529a3]['MetricId']]['metric']:_0x5a5f86[_0x3529a3][_0xf69b('0x6f')];_0x50b836=_0x5a5f86[_0x3529a3][_0xf69b('0x7c')]?_[_0xf69b('0x7d')](_0x5e2088[_0x5a5f86[_0x3529a3][_0xf69b('0x7c')]],'%s',_0x50b836):_0x50b836;_0x50b836=_0x5a5f86[_0x3529a3]['format']?_[_0xf69b('0x7d')](_0x440586[_0x5a5f86[_0x3529a3][_0xf69b('0x7e')]],'%s',_0x50b836):_0x50b836;if(_0x5a5f86[_0x3529a3][_0xf69b('0x7f')]){_0x147ba2[_0xf69b('0x6e')](_0x50b836);}_0x5a5f86[_0x3529a3]['orderBy']&&_0x147ba2[_0xf69b('0x41')](_0x50b836,_0x5a5f86[_0x3529a3][_0xf69b('0x80')]==='DESC'?![]:!![]);_0x147ba2[_0xf69b('0x6f')](_0x50b836,_0x5a5f86[_0x3529a3][_0xf69b('0x82')]||_0x50b836);}if(_0x2e318e[_0xf69b('0x83')]){_0x2e318e[_0xf69b('0x83')]=JSON['parse'](_0x2e318e[_0xf69b('0x83')]);for(var _0x3f4843=0x0;_0x3f4843<_0x2e318e[_0xf69b('0x83')][_0xf69b('0x4f')];_0x3f4843+=0x1){if(_0x2e318e[_0xf69b('0x83')][_0x3f4843][_0xf69b('0x47')]&&_[_0xf69b('0x69')](_0x1552cd,_0x2e318e[_0xf69b('0x83')][_0x3f4843][_0xf69b('0x47')])&&_0x2e318e[_0xf69b('0x83')][_0x3f4843][_0xf69b('0x85')]&&_0x2e318e['joins'][_0x3f4843][_0xf69b('0x86')]&&_0x2e318e[_0xf69b('0x83')][_0x3f4843][_0xf69b('0x88')]){_0x147ba2[_0x2e318e[_0xf69b('0x83')][_0x3f4843][_0xf69b('0x47')]](_0x2e318e[_0xf69b('0x83')][_0x3f4843]['foreignTable'],null,util[_0xf69b('0x7e')]('%s.%s\x20=\x20%s.%s',_0x2e318e[_0xf69b('0x79')],_0x2e318e[_0xf69b('0x83')][_0x3f4843]['parentKey'],_0x2e318e['joins'][_0x3f4843]['foreignTable'],_0x2e318e[_0xf69b('0x83')][_0x3f4843][_0xf69b('0x88')]));}}}if(_0x2e318e[_0xf69b('0x89')]){_0x2e318e[_0xf69b('0x89')]=JSON[_0xf69b('0x84')](_0x2e318e['conditions']);_0x147ba2['where'](_0x486990(_0x2e318e[_0xf69b('0x89')][_0xf69b('0x6e')]));}_0x110832=_0x147ba2[_0xf69b('0x8a')]();_0x147ba2['limit'](_0x382f3d);_0x147ba2[_0xf69b('0x20')](0x0);return;}})[_0xf69b('0x2b')](function(){if(_0x2fb63e[_0xf69b('0x93')]===_0xf69b('0x94')){return null;}var _0x4c2d9f=_[_0xf69b('0x46')](_0x2fb63e,{'name':_0x2fb63e[_0xf69b('0x95')]||_0x2fb63e[_0xf69b('0x31')]||_0x2e318e[_0xf69b('0x31')],'basename':_0x1f1127,'savename':util[_0xf69b('0x7e')]('%s-%s.%s',_0x2fb63e[_0xf69b('0x31')]||_0x2e318e[_0xf69b('0x31')],require(_0xf69b('0x96'))[_0xf69b('0x97')](0x4),_0x2fb63e['output']||_0xf69b('0x98')),'reportId':_0x2e318e['id'],'reportType':_0xf69b('0x99')});return db['AnalyticExtractedReport']['create'](_0x4c2d9f,{'raw':!![]});})['then'](function(_0x22c8ed){if(_0x2e318e[_0xf69b('0x79')]===_0xf69b('0x9a')){_0x110832[_0xf69b('0x43')](_0x2e318e['table']+_0xf69b('0x9b'),_0x2fb63e[_0xf69b('0x9c')],_0x2fb63e[_0xf69b('0x9d')]);}else{_0x110832['where'](_0x2e318e['table']+_0xf69b('0x9e'),_0x2fb63e[_0xf69b('0x9c')],_0x2fb63e[_0xf69b('0x9d')]);}if(_0x22c8ed){logger[_0xf69b('0x9f')](_0xf69b('0xa0'),_0x110832[_0xf69b('0x8d')]());require(_0xf69b('0xa1'))['fork'](path[_0xf69b('0x5a')](__dirname,'../../components/export/',_0x22c8ed[_0xf69b('0x93')]),[_0x22c8ed['id'],_0x110832[_0xf69b('0x8d')](),path[_0xf69b('0x5a')](__dirname,_0xf69b('0xa2'),_0x22c8ed[_0xf69b('0xa3')]),_0x1f1127]);return _0x22c8ed;}else{var _0x1921e4=squel[_0xf69b('0x77')]();_0x1921e4[_0xf69b('0x78')]('('+_0x110832[_0xf69b('0x8d')]()+')',_0xf69b('0xa4'));_0x1921e4[_0xf69b('0x6f')](_0xf69b('0xa5'),_0xf69b('0x23'));_0x110832[_0xf69b('0x22')](_0x2fb63e[_0xf69b('0x22')]||_0x382f3d);_0x110832[_0xf69b('0x20')](_0x2fb63e['offset']||0x0);return dbH[_0xf69b('0x8e')][_0xf69b('0x38')](_0x1921e4['toString'](),{'type':dbH[_0xf69b('0x8e')][_0xf69b('0x8f')][_0xf69b('0xa6')]})[_0xf69b('0x2b')](function(_0x126715){if(!_0x126715['length']){_0x9ab2bf=0x0;}else{_0x9ab2bf=_0x126715[0x0][_0xf69b('0x23')]||0x0;}return dbH[_0xf69b('0x8e')]['query'](_0x110832['toString'](),{'type':dbH[_0xf69b('0x8e')][_0xf69b('0x8f')]['SELECT']});})['then'](function(_0x5bf69b){return{'rows':_0x5bf69b||[],'count':_0x9ab2bf};});}});}exports[_0xf69b('0xa7')]=function(_0x409d88,_0xe7815d){return runReport(_0x409d88[_0xf69b('0x59')],_0x409d88[_0xf69b('0x38')],_0x409d88[_0xf69b('0x48')])[_0xf69b('0x2b')](respondWithResult(_0xe7815d,null))[_0xf69b('0x4d')](handleError(_0xe7815d,null));};exports[_0xf69b('0xa8')]=runReport;exports[_0xf69b('0x38')]=function(_0x37dde2,_0x51f52e){var _0x45b635=0xa;var _0x14caea=[_0xf69b('0x5a'),_0xf69b('0x5b'),_0xf69b('0x5c'),_0xf69b('0x5d')];var _0x274b30={'SUM':_0xf69b('0x90'),'COUNT':_0xf69b('0x5e'),'COUNT DISTINCT':_0xf69b('0x5f'),'MAX':'MAX(%s)','MIN':_0xf69b('0x61'),'AVG':_0xf69b('0x62'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xf69b('0x64'),'GROUP_CONCAT DESC':_0xf69b('0xa9')};var _0x470d85={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':'DATE(%s)','HOUR':_0xf69b('0x67'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x309b60=function(_0x10444b){return!_['includes']([_0xf69b('0x6a'),_0xf69b('0x91'),_0xf69b('0x6b'),_0xf69b('0x6c')],_0x10444b);};var _0x118c61=function(_0x2f3383){if(!_0x2f3383||!_0x2f3383[_0xf69b('0x6d')]['length']){return'';}for(var _0x1b0c9d='(',_0x4df84c=0x0;_0x4df84c<_0x2f3383[_0xf69b('0x6d')][_0xf69b('0x4f')];_0x4df84c+=0x1){_0x4df84c>0x0&&(_0x1b0c9d+='\x20'+_0x2f3383[_0xf69b('0x92')]+'\x20');_0x1b0c9d+=_0x2f3383[_0xf69b('0x6d')][_0x4df84c][_0xf69b('0x6e')]?_0x118c61(_0x2f3383[_0xf69b('0x6d')][_0x4df84c][_0xf69b('0x6e')]):_0x2f3383[_0xf69b('0x6d')][_0x4df84c][_0xf69b('0x6f')]+'\x20'+_0x2f3383[_0xf69b('0x6d')][_0x4df84c][_0xf69b('0x70')]+(_0x309b60(_0x2f3383[_0xf69b('0x6d')][_0x4df84c]['condition'])?'\x20'+_0x2f3383[_0xf69b('0x6d')][_0x4df84c]['value']:'');}return _0x1b0c9d+')';};var _0x416f45={'where':{'id':_0x37dde2[_0xf69b('0x59')]['id']}},_0x98bd8b,_0x83ec48,_0x37228b,_0x4c06e2,_0x525024;_0x416f45=_[_0xf69b('0x46')]({},_0x416f45,_0x37dde2[_0xf69b('0x48')]);return db[_0xf69b('0x35')][_0xf69b('0x55')](_0x416f45)['then'](function(_0x50e9ef){if(_0x50e9ef){_0x98bd8b=_0x50e9ef;return _0x50e9ef[_0xf69b('0xaa')]();}return null;})[_0xf69b('0x2b')](function(_0x322acb){if(_0x322acb){if(!_0x322acb[_0xf69b('0x4f')]){throw new db[(_0xf69b('0x72'))][(_0xf69b('0x73'))](_0xf69b('0x74'),0x193);}_0x83ec48=_0x322acb;return db[_0xf69b('0x75')][_0xf69b('0x4b')]({'raw':!![]});}return null;})[_0xf69b('0x2b')](function(_0x53b501){if(_0x53b501){_0x37228b=_[_0xf69b('0x76')](_0x53b501,'id');var _0x2e7e82;var _0x47824c=squel[_0xf69b('0x77')]();_0x47824c[_0xf69b('0x78')](_0x98bd8b[_0xf69b('0x79')]);for(var _0x1343d4=0x0;_0x1343d4<_0x83ec48[_0xf69b('0x4f')];_0x1343d4+=0x1){_0x2e7e82=_0x83ec48[_0x1343d4][_0xf69b('0x7a')]?_0x37228b[_0x83ec48[_0x1343d4]['MetricId']]['metric']:_0x83ec48[_0x1343d4][_0xf69b('0x6f')];_0x2e7e82=_0x83ec48[_0x1343d4][_0xf69b('0x7c')]?_[_0xf69b('0x7d')](_0x274b30[_0x83ec48[_0x1343d4][_0xf69b('0x7c')]],'%s',_0x2e7e82):_0x2e7e82;_0x2e7e82=_0x83ec48[_0x1343d4][_0xf69b('0x7e')]?_['replace'](_0x470d85[_0x83ec48[_0x1343d4][_0xf69b('0x7e')]],'%s',_0x2e7e82):_0x2e7e82;if(_0x83ec48[_0x1343d4][_0xf69b('0x7f')]){_0x47824c['group'](_0x2e7e82);}_0x83ec48[_0x1343d4]['orderBy']&&_0x47824c[_0xf69b('0x41')](_0x2e7e82,_0x83ec48[_0x1343d4][_0xf69b('0x80')]==='DESC'?![]:!![]);_0x47824c[_0xf69b('0x6f')](_0x2e7e82,_0x83ec48[_0x1343d4][_0xf69b('0x82')]||_0x2e7e82);}if(_0x98bd8b[_0xf69b('0x83')]){_0x98bd8b[_0xf69b('0x83')]=JSON[_0xf69b('0x84')](_0x98bd8b[_0xf69b('0x83')]);for(var _0x1c9e0c=0x0;_0x1c9e0c<_0x98bd8b[_0xf69b('0x83')]['length'];_0x1c9e0c+=0x1){if(_0x98bd8b[_0xf69b('0x83')][_0x1c9e0c][_0xf69b('0x47')]&&_[_0xf69b('0x69')](_0x14caea,_0x98bd8b[_0xf69b('0x83')][_0x1c9e0c][_0xf69b('0x47')])&&_0x98bd8b[_0xf69b('0x83')][_0x1c9e0c][_0xf69b('0x85')]&&_0x98bd8b['joins'][_0x1c9e0c][_0xf69b('0x86')]&&_0x98bd8b[_0xf69b('0x83')][_0x1c9e0c][_0xf69b('0x88')]){_0x47824c[_0x98bd8b[_0xf69b('0x83')][_0x1c9e0c][_0xf69b('0x47')]](_0x98bd8b[_0xf69b('0x83')][_0x1c9e0c][_0xf69b('0x86')],null,util[_0xf69b('0x7e')](_0xf69b('0x87'),_0x98bd8b[_0xf69b('0x79')],_0x98bd8b[_0xf69b('0x83')][_0x1c9e0c][_0xf69b('0x85')],_0x98bd8b['joins'][_0x1c9e0c][_0xf69b('0x86')],_0x98bd8b[_0xf69b('0x83')][_0x1c9e0c][_0xf69b('0x88')]));}}}if(_0x98bd8b[_0xf69b('0x89')]){_0x98bd8b[_0xf69b('0x89')]=JSON[_0xf69b('0x84')](_0x98bd8b[_0xf69b('0x89')]);_0x47824c[_0xf69b('0x43')](_0x118c61(_0x98bd8b[_0xf69b('0x89')][_0xf69b('0x6e')]));}_0x525024=_0x47824c[_0xf69b('0x8a')]();_0x47824c[_0xf69b('0x22')](_0x45b635);_0x47824c[_0xf69b('0x20')](0x0);logger[_0xf69b('0x8b')](_0xf69b('0x8c'),_0x47824c[_0xf69b('0x8d')]());return dbH[_0xf69b('0x8e')][_0xf69b('0x38')](_0x47824c['toString'](),{'type':dbH['sequelize']['QueryTypes']['SELECT']});}})[_0xf69b('0x2b')](function(){return{'sql':_0x525024[_0xf69b('0x8d')]()};})['then'](respondWithResult(_0x51f52e,null))[_0xf69b('0x4d')](handleError(_0x51f52e,null));};
\ No newline at end of file