Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / analyticCustomReport / analyticCustomReport.controller.js
index 581e1aa..670f127 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0f49=['status','end','json','count','offset','limit','set','Content-Range','apply','save','update','then','destroy','get','CustomReports','UserProfileResource','sendStatus','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','keys','query','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filters','filter','where','merge','options','AnalyticCustomReport','includeAll','findAll','rows','catch','show','params','include','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','join','cross_join','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','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\x20NOT\x20EMPTY','rules','group','field','condition','value','getFields','ValidationErrorItem','AnalyticMetric','keyBy','from','table','MetricId','metric','function','replace','format','groupBy','orderBy','DESC','alias','joins','parse','foreignTable','parentKey','foreignKey','conditions','clone','debug','Limited\x20Query:','toString','sequelize','QueryTypes','SELECT','left_join','right_join','SUM(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','HOUR(%s)','operator','Sequelize','Please\x20insert\x20at\x20least\x20one\x20field','select','output','web','randomstring','csv','custom','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','run','runReport','MIN(%s)','IS\x20EMPTY','%s.%s\x20=\x20%s.%s','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb'];(function(_0x387583,_0x127b08){var _0x45d2f9=function(_0x1d82ac){while(--_0x1d82ac){_0x387583['push'](_0x387583['shift']());}};_0x45d2f9(++_0x127b08);}(_0x0f49,0x8e));var _0x90f4=function(_0x5f52a4,_0x5706d9){_0x5f52a4=_0x5f52a4-0x0;var _0xde1bce=_0x0f49[_0x5f52a4];return _0xde1bce;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x90f4('0x0'));var rimraf=require(_0x90f4('0x1'));var zipdir=require(_0x90f4('0x2'));var jsonpatch=require(_0x90f4('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x90f4('0x4'));var Mustache=require(_0x90f4('0x5'));var util=require(_0x90f4('0x6'));var path=require(_0x90f4('0x7'));var sox=require(_0x90f4('0x8'));var csv=require(_0x90f4('0x9'));var ejs=require(_0x90f4('0xa'));var fs=require('fs');var _=require(_0x90f4('0xb'));var squel=require(_0x90f4('0xc'));var crypto=require('crypto');var jsforce=require(_0x90f4('0xd'));var deskjs=require(_0x90f4('0xe'));var toCsv=require(_0x90f4('0x9'));var querystring=require(_0x90f4('0xf'));var Papa=require('papaparse');var Redis=require(_0x90f4('0x10'));var authService=require(_0x90f4('0x11'));var qs=require(_0x90f4('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x90f4('0x13'));var logger=require(_0x90f4('0x14'))(_0x90f4('0x15'));var utils=require(_0x90f4('0x16'));var config=require(_0x90f4('0x17'));var licenseUtil=require(_0x90f4('0x18'));var db=require('../../mysqldb')['db'];var dbH=require(_0x90f4('0x19'))['dbH'];function respondWithStatusCode(_0x4f9b64,_0xa947f9){_0xa947f9=_0xa947f9||0xcc;return function(_0xf6dd74){if(_0xf6dd74){return _0x4f9b64['sendStatus'](_0xa947f9);}return _0x4f9b64[_0x90f4('0x1a')](_0xa947f9)[_0x90f4('0x1b')]();};}function respondWithResult(_0x28ca17,_0x34759a){_0x34759a=_0x34759a||0xc8;return function(_0x28c6ad){if(_0x28c6ad){return _0x28ca17[_0x90f4('0x1a')](_0x34759a)[_0x90f4('0x1c')](_0x28c6ad);}};}function respondWithFilteredResult(_0x40dd0d,_0x5dc24e){return function(_0x5d0792){if(_0x5d0792){var _0x9b1067=_0x5d0792[_0x90f4('0x1d')],_0x5e5c6d=_0x5dc24e[_0x90f4('0x1e')],_0x187dd1=_0x5dc24e['offset']+_0x5dc24e[_0x90f4('0x1f')],_0x501b6c;if(_0x187dd1>=_0x9b1067){_0x187dd1=_0x9b1067;_0x501b6c=0xc8;}else{_0x501b6c=0xce;}_0x40dd0d[_0x90f4('0x1a')](_0x501b6c);return _0x40dd0d[_0x90f4('0x20')](_0x90f4('0x21'),_0x5e5c6d+'-'+_0x187dd1+'/'+_0x9b1067)[_0x90f4('0x1c')](_0x5d0792);}return null;};}function patchUpdates(_0x11b730){return function(_0x45ea28){try{jsonpatch[_0x90f4('0x22')](_0x45ea28,_0x11b730,!![]);}catch(_0x376822){return BPromise['reject'](_0x376822);}return _0x45ea28[_0x90f4('0x23')]();};}function saveUpdates(_0x2e16cb,_0x49d9bc){return function(_0x298d80){if(_0x298d80){return _0x298d80[_0x90f4('0x24')](_0x2e16cb)[_0x90f4('0x25')](function(_0x4ea43b){return _0x4ea43b;});}return null;};}function removeEntity(_0x5ae0b2,_0x52c3ad){return function(_0x3d2d4b){if(_0x3d2d4b){return _0x3d2d4b[_0x90f4('0x26')]()[_0x90f4('0x25')](function(){var _0x574935=_0x3d2d4b[_0x90f4('0x27')]({'plain':!![]});var _0x454e28=_0x90f4('0x28');return db[_0x90f4('0x29')]['destroy']({'where':{'type':_0x454e28,'resourceId':_0x574935['id']}})[_0x90f4('0x25')](function(){return _0x3d2d4b;});})[_0x90f4('0x25')](function(){_0x5ae0b2[_0x90f4('0x1a')](0xcc)[_0x90f4('0x1b')]();});}};}function handleEntityNotFound(_0x4a0630,_0x1fa720){return function(_0x175cd6){if(!_0x175cd6){_0x4a0630[_0x90f4('0x2a')](0x194);}return _0x175cd6;};}function handleError(_0x443419,_0xbd26f2){_0xbd26f2=_0xbd26f2||0x1f4;return function(_0x31655d){logger[_0x90f4('0x2b')](_0x31655d[_0x90f4('0x2c')]);if(_0x31655d[_0x90f4('0x2d')]){delete _0x31655d[_0x90f4('0x2d')];}_0x443419[_0x90f4('0x1a')](_0xbd26f2)[_0x90f4('0x2e')](_0x31655d);};}exports[_0x90f4('0x2f')]=function(_0x3aa915,_0xac8cd7){var _0x1809d1={},_0x332ee2={},_0x1009ca={'count':0x0,'rows':[]};var _0x4d8b30=_[_0x90f4('0x30')](db['AnalyticCustomReport'][_0x90f4('0x31')],function(_0x2ebdfe){return{'name':_0x2ebdfe[_0x90f4('0x32')],'type':_0x2ebdfe[_0x90f4('0x33')][_0x90f4('0x34')]};});_0x332ee2['model']=_[_0x90f4('0x30')](_0x4d8b30,'name');_0x332ee2['query']=_[_0x90f4('0x35')](_0x3aa915[_0x90f4('0x36')]);_0x332ee2['filters']=_[_0x90f4('0x37')](_0x332ee2[_0x90f4('0x38')],_0x332ee2[_0x90f4('0x36')]);_0x1809d1[_0x90f4('0x39')]=_['intersection'](_0x332ee2[_0x90f4('0x38')],qs[_0x90f4('0x3a')](_0x3aa915[_0x90f4('0x36')][_0x90f4('0x3a')]));_0x1809d1['attributes']=_0x1809d1[_0x90f4('0x39')][_0x90f4('0x3b')]?_0x1809d1['attributes']:_0x332ee2['model'];if(!_0x3aa915[_0x90f4('0x36')][_0x90f4('0x3c')](_0x90f4('0x3d'))){_0x1809d1[_0x90f4('0x1f')]=qs[_0x90f4('0x1f')](_0x3aa915[_0x90f4('0x36')][_0x90f4('0x1f')]);_0x1809d1[_0x90f4('0x1e')]=qs[_0x90f4('0x1e')](_0x3aa915['query'][_0x90f4('0x1e')]);}_0x1809d1[_0x90f4('0x3e')]=qs[_0x90f4('0x3f')](_0x3aa915[_0x90f4('0x36')][_0x90f4('0x3f')]);_0x1809d1['where']=qs[_0x90f4('0x40')](_['pick'](_0x3aa915[_0x90f4('0x36')],_0x332ee2['filters']),_0x4d8b30);if(_0x3aa915[_0x90f4('0x36')][_0x90f4('0x41')]){_0x1809d1[_0x90f4('0x42')]=_[_0x90f4('0x43')](_0x1809d1['where'],{'$or':_[_0x90f4('0x30')](_0x4d8b30,function(_0x3011b6){if(_0x3011b6[_0x90f4('0x33')]!=='VIRTUAL'){var _0x244ba4={};_0x244ba4[_0x3011b6[_0x90f4('0x2d')]]={'$like':'%'+_0x3aa915[_0x90f4('0x36')]['filter']+'%'};return _0x244ba4;}})});}_0x1809d1=_[_0x90f4('0x43')]({},_0x1809d1,_0x3aa915[_0x90f4('0x44')]);var _0x3d0411={'where':_0x1809d1[_0x90f4('0x42')]};return db[_0x90f4('0x45')][_0x90f4('0x1d')](_0x3d0411)['then'](function(_0x430a30){_0x1009ca['count']=_0x430a30;if(_0x3aa915[_0x90f4('0x36')][_0x90f4('0x46')]){_0x1809d1['include']=[{'all':!![]}];}return db['AnalyticCustomReport'][_0x90f4('0x47')](_0x1809d1);})[_0x90f4('0x25')](function(_0xc847b){_0x1009ca[_0x90f4('0x48')]=_0xc847b;return _0x1009ca;})[_0x90f4('0x25')](respondWithFilteredResult(_0xac8cd7,_0x1809d1))[_0x90f4('0x49')](handleError(_0xac8cd7,null));};exports[_0x90f4('0x4a')]=function(_0x21f743,_0xcb26c6){var _0x19575f={'raw':![],'where':{'id':_0x21f743[_0x90f4('0x4b')]['id']}},_0x2eb786={};_0x2eb786[_0x90f4('0x38')]=_[_0x90f4('0x35')](db[_0x90f4('0x45')][_0x90f4('0x31')]);_0x2eb786[_0x90f4('0x36')]=_[_0x90f4('0x35')](_0x21f743['query']);_0x2eb786[_0x90f4('0x40')]=_[_0x90f4('0x37')](_0x2eb786[_0x90f4('0x38')],_0x2eb786[_0x90f4('0x36')]);_0x19575f[_0x90f4('0x39')]=_['intersection'](_0x2eb786[_0x90f4('0x38')],qs[_0x90f4('0x3a')](_0x21f743[_0x90f4('0x36')][_0x90f4('0x3a')]));_0x19575f[_0x90f4('0x39')]=_0x19575f[_0x90f4('0x39')][_0x90f4('0x3b')]?_0x19575f[_0x90f4('0x39')]:_0x2eb786[_0x90f4('0x38')];if(_0x21f743[_0x90f4('0x36')][_0x90f4('0x46')]){_0x19575f[_0x90f4('0x4c')]=[{'all':!![]}];}_0x19575f=_[_0x90f4('0x43')]({},_0x19575f,_0x21f743[_0x90f4('0x44')]);return db['AnalyticCustomReport']['find'](_0x19575f)[_0x90f4('0x25')](handleEntityNotFound(_0xcb26c6,null))[_0x90f4('0x25')](respondWithResult(_0xcb26c6,null))[_0x90f4('0x49')](handleError(_0xcb26c6,null));};exports[_0x90f4('0x4d')]=function(_0x1fae6d,_0x55e420){return db[_0x90f4('0x45')][_0x90f4('0x4d')](_0x1fae6d[_0x90f4('0x4e')],{})[_0x90f4('0x25')](function(_0x45a404){var _0x1ebdb9=_0x1fae6d[_0x90f4('0x4f')][_0x90f4('0x27')]({'plain':!![]});if(!_0x1ebdb9)throw new Error(_0x90f4('0x50'));if(_0x1ebdb9[_0x90f4('0x51')]===_0x90f4('0x4f')){var _0x50227d=_0x45a404[_0x90f4('0x27')]({'plain':!![]});var _0x287630='Reports';return db[_0x90f4('0x52')][_0x90f4('0x53')]({'where':{'name':_0x287630,'userProfileId':_0x1ebdb9[_0x90f4('0x54')]},'raw':!![]})[_0x90f4('0x25')](function(_0x152836){if(_0x152836&&_0x152836[_0x90f4('0x55')]===0x0){return db['UserProfileResource']['create']({'name':_0x50227d['name'],'resourceId':_0x50227d['id'],'type':_0x90f4('0x28'),'sectionId':_0x152836['id']},{})['then'](function(){return _0x45a404;});}else{return _0x45a404;}})[_0x90f4('0x49')](function(_0xaf0190){logger[_0x90f4('0x2b')](_0x90f4('0x56'),_0xaf0190);throw _0xaf0190;});}return _0x45a404;})[_0x90f4('0x25')](respondWithResult(_0x55e420,0xc9))[_0x90f4('0x49')](handleError(_0x55e420,null));};exports[_0x90f4('0x24')]=function(_0x4378a2,_0x4d0970){if(_0x4378a2[_0x90f4('0x4e')]['id']){delete _0x4378a2[_0x90f4('0x4e')]['id'];}return db['AnalyticCustomReport'][_0x90f4('0x53')]({'where':{'id':_0x4378a2[_0x90f4('0x4b')]['id']}})[_0x90f4('0x25')](handleEntityNotFound(_0x4d0970,null))['then'](saveUpdates(_0x4378a2['body'],null))[_0x90f4('0x25')](respondWithResult(_0x4d0970,null))[_0x90f4('0x49')](handleError(_0x4d0970,null));};exports[_0x90f4('0x26')]=function(_0x2cc16a,_0x230346){return db[_0x90f4('0x45')][_0x90f4('0x53')]({'where':{'id':_0x2cc16a[_0x90f4('0x4b')]['id']}})[_0x90f4('0x25')](handleEntityNotFound(_0x230346,null))[_0x90f4('0x25')](removeEntity(_0x230346,null))[_0x90f4('0x49')](handleError(_0x230346,null));};exports['preview']=function(_0x226573,_0x722433){var _0x552249=0xa;var _0x1a0ce6=[_0x90f4('0x57'),'left_join','right_join',_0x90f4('0x58')];var _0x179b0b={'SUM':'SUM(%s)','COUNT':_0x90f4('0x59'),'COUNT DISTINCT':_0x90f4('0x5a'),'MAX':_0x90f4('0x5b'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x90f4('0x5c')};var _0x238b10={'SEC_TO_TIME':_0x90f4('0x5d'),'DATE':_0x90f4('0x5e'),'HOUR':'HOUR(%s)','ROUND':_0x90f4('0x5f'),'UNIX_TIMESTAMP':_0x90f4('0x60')};var _0x46a5bb=function(_0x431bc2){return!_[_0x90f4('0x61')]([_0x90f4('0x62'),_0x90f4('0x63'),'IS\x20EMPTY',_0x90f4('0x64')],_0x431bc2);};var _0x2106d7=function(_0x167949){if(!_0x167949||!_0x167949[_0x90f4('0x65')][_0x90f4('0x3b')]){return'';}for(var _0x3e4a92='(',_0x3a009b=0x0;_0x3a009b<_0x167949[_0x90f4('0x65')]['length'];_0x3a009b+=0x1){_0x3a009b>0x0&&(_0x3e4a92+='\x20'+_0x167949['operator']+'\x20');_0x3e4a92+=_0x167949[_0x90f4('0x65')][_0x3a009b][_0x90f4('0x66')]?_0x2106d7(_0x167949[_0x90f4('0x65')][_0x3a009b]['group']):_0x167949[_0x90f4('0x65')][_0x3a009b][_0x90f4('0x67')]+'\x20'+_0x167949[_0x90f4('0x65')][_0x3a009b][_0x90f4('0x68')]+(_0x46a5bb(_0x167949['rules'][_0x3a009b][_0x90f4('0x68')])?'\x20'+_0x167949[_0x90f4('0x65')][_0x3a009b][_0x90f4('0x69')]:'');}return _0x3e4a92+')';};var _0x564b1b={'where':{'id':_0x226573[_0x90f4('0x4b')]['id']}},_0x484d83,_0xe2c6ed,_0x3139b5,_0x4adf63,_0x1551b5;_0x564b1b=_['merge']({},_0x564b1b,_0x226573[_0x90f4('0x44')]);return db[_0x90f4('0x45')][_0x90f4('0x53')](_0x564b1b)[_0x90f4('0x25')](function(_0x852769){if(_0x852769){_0x484d83=_0x852769;return _0x852769[_0x90f4('0x6a')]();}return null;})[_0x90f4('0x25')](function(_0x406bff){if(_0x406bff){if(!_0x406bff[_0x90f4('0x3b')]){throw new db['Sequelize'][(_0x90f4('0x6b'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0xe2c6ed=_0x406bff;return db[_0x90f4('0x6c')]['findAll']({'raw':!![]});}return null;})[_0x90f4('0x25')](function(_0x590448){if(_0x590448){_0x3139b5=_[_0x90f4('0x6d')](_0x590448,'id');var _0x4da05c;var _0x553e05=squel['select']();_0x553e05[_0x90f4('0x6e')](_0x484d83[_0x90f4('0x6f')]);for(var _0x2ee9cc=0x0;_0x2ee9cc<_0xe2c6ed[_0x90f4('0x3b')];_0x2ee9cc+=0x1){_0x4da05c=_0xe2c6ed[_0x2ee9cc][_0x90f4('0x70')]?_0x3139b5[_0xe2c6ed[_0x2ee9cc][_0x90f4('0x70')]][_0x90f4('0x71')]:_0xe2c6ed[_0x2ee9cc]['field'];_0x4da05c=_0xe2c6ed[_0x2ee9cc][_0x90f4('0x72')]?_[_0x90f4('0x73')](_0x179b0b[_0xe2c6ed[_0x2ee9cc][_0x90f4('0x72')]],'%s',_0x4da05c):_0x4da05c;_0x4da05c=_0xe2c6ed[_0x2ee9cc][_0x90f4('0x74')]?_[_0x90f4('0x73')](_0x238b10[_0xe2c6ed[_0x2ee9cc][_0x90f4('0x74')]],'%s',_0x4da05c):_0x4da05c;if(_0xe2c6ed[_0x2ee9cc][_0x90f4('0x75')]){_0x553e05[_0x90f4('0x66')](_0x4da05c);}_0xe2c6ed[_0x2ee9cc][_0x90f4('0x76')]&&_0x553e05[_0x90f4('0x3e')](_0x4da05c,_0xe2c6ed[_0x2ee9cc][_0x90f4('0x76')]===_0x90f4('0x77')?![]:!![]);_0x553e05[_0x90f4('0x67')](_0x4da05c,_0xe2c6ed[_0x2ee9cc][_0x90f4('0x78')]||_0x4da05c);}if(_0x484d83[_0x90f4('0x79')]){_0x484d83[_0x90f4('0x79')]=JSON[_0x90f4('0x7a')](_0x484d83[_0x90f4('0x79')]);for(var _0xb02667=0x0;_0xb02667<_0x484d83[_0x90f4('0x79')][_0x90f4('0x3b')];_0xb02667+=0x1){if(_0x484d83[_0x90f4('0x79')][_0xb02667][_0x90f4('0x33')]&&_[_0x90f4('0x61')](_0x1a0ce6,_0x484d83['joins'][_0xb02667][_0x90f4('0x33')])&&_0x484d83[_0x90f4('0x79')][_0xb02667]['parentKey']&&_0x484d83[_0x90f4('0x79')][_0xb02667][_0x90f4('0x7b')]&&_0x484d83[_0x90f4('0x79')][_0xb02667]['foreignKey']){_0x553e05[_0x484d83[_0x90f4('0x79')][_0xb02667][_0x90f4('0x33')]](_0x484d83[_0x90f4('0x79')][_0xb02667][_0x90f4('0x7b')],null,util[_0x90f4('0x74')]('%s.%s\x20=\x20%s.%s',_0x484d83[_0x90f4('0x6f')],_0x484d83[_0x90f4('0x79')][_0xb02667][_0x90f4('0x7c')],_0x484d83[_0x90f4('0x79')][_0xb02667][_0x90f4('0x7b')],_0x484d83[_0x90f4('0x79')][_0xb02667][_0x90f4('0x7d')]));}}}if(_0x484d83[_0x90f4('0x7e')]){_0x484d83[_0x90f4('0x7e')]=JSON['parse'](_0x484d83[_0x90f4('0x7e')]);_0x553e05[_0x90f4('0x42')](_0x2106d7(_0x484d83[_0x90f4('0x7e')][_0x90f4('0x66')]));}_0x1551b5=_0x553e05[_0x90f4('0x7f')]();_0x553e05[_0x90f4('0x1f')](_0x552249);_0x553e05[_0x90f4('0x1e')](0x0);logger[_0x90f4('0x80')](_0x90f4('0x81'),_0x553e05[_0x90f4('0x82')]());return dbH[_0x90f4('0x83')][_0x90f4('0x36')](_0x553e05['toString'](),{'type':dbH[_0x90f4('0x83')][_0x90f4('0x84')][_0x90f4('0x85')]});}})[_0x90f4('0x25')](respondWithResult(_0x722433,null))[_0x90f4('0x49')](handleError(_0x722433,null));};function runReport(_0x352608,_0x332884,_0x497140){var _0x1ddd91=_0x332884[_0x90f4('0x2d')];var _0x887446=0xa;var _0x517bbe=[_0x90f4('0x57'),_0x90f4('0x86'),_0x90f4('0x87'),_0x90f4('0x58')];var _0x1ee737={'SUM':_0x90f4('0x88'),'COUNT':_0x90f4('0x59'),'COUNT DISTINCT':_0x90f4('0x5a'),'MAX':_0x90f4('0x5b'),'MIN':'MIN(%s)','AVG':_0x90f4('0x89'),'GROUP_CONCAT':_0x90f4('0x8a'),'GROUP_CONCAT ASC':_0x90f4('0x8b'),'GROUP_CONCAT DESC':_0x90f4('0x5c')};var _0x4fb487={'SEC_TO_TIME':_0x90f4('0x5d'),'DATE':_0x90f4('0x5e'),'HOUR':_0x90f4('0x8c'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x55b8ad=function(_0x48a344){return!_[_0x90f4('0x61')]([_0x90f4('0x62'),_0x90f4('0x63'),'IS\x20EMPTY',_0x90f4('0x64')],_0x48a344);};var _0x5e0792=function(_0x4a73a8){if(!_0x4a73a8||!_0x4a73a8[_0x90f4('0x65')]['length']){return'';}for(var _0x198d97='(',_0x564435=0x0;_0x564435<_0x4a73a8['rules'][_0x90f4('0x3b')];_0x564435+=0x1){_0x564435>0x0&&(_0x198d97+='\x20'+_0x4a73a8[_0x90f4('0x8d')]+'\x20');_0x198d97+=_0x4a73a8[_0x90f4('0x65')][_0x564435][_0x90f4('0x66')]?_0x5e0792(_0x4a73a8[_0x90f4('0x65')][_0x564435][_0x90f4('0x66')]):_0x4a73a8[_0x90f4('0x65')][_0x564435]['field']+'\x20'+_0x4a73a8['rules'][_0x564435]['condition']+(_0x55b8ad(_0x4a73a8['rules'][_0x564435]['condition'])?'\x20'+_0x4a73a8[_0x90f4('0x65')][_0x564435][_0x90f4('0x69')]:'');}return _0x198d97+')';};var _0xa7017={'where':{'id':_0x352608['id']}},_0x383ecb,_0x73a3bc,_0x5b6b8c,_0x3ad40f,_0x40fc3b;_0xa7017=_[_0x90f4('0x43')]({},_0xa7017,_0x497140);return db[_0x90f4('0x45')][_0x90f4('0x53')](_0xa7017)[_0x90f4('0x25')](function(_0x366004){if(_0x366004){_0x383ecb=_0x366004;return _0x366004[_0x90f4('0x6a')]();}return null;})[_0x90f4('0x25')](function(_0x439674){if(_0x439674){if(!_0x439674[_0x90f4('0x3b')]){throw new db[(_0x90f4('0x8e'))][(_0x90f4('0x6b'))](_0x90f4('0x8f'),0x193);}_0x73a3bc=_0x439674;return db[_0x90f4('0x6c')][_0x90f4('0x47')]({'raw':!![]});}return null;})[_0x90f4('0x25')](function(_0x37c8e2){if(_0x37c8e2){_0x5b6b8c=_[_0x90f4('0x6d')](_0x37c8e2,'id');var _0x4c1fe9;var _0x54ea66=squel[_0x90f4('0x90')]();_0x54ea66[_0x90f4('0x6e')](_0x383ecb[_0x90f4('0x6f')]);for(var _0x2553b4=0x0;_0x2553b4<_0x73a3bc[_0x90f4('0x3b')];_0x2553b4+=0x1){_0x4c1fe9=_0x73a3bc[_0x2553b4][_0x90f4('0x70')]?_0x5b6b8c[_0x73a3bc[_0x2553b4]['MetricId']][_0x90f4('0x71')]:_0x73a3bc[_0x2553b4]['field'];_0x4c1fe9=_0x73a3bc[_0x2553b4][_0x90f4('0x72')]?_[_0x90f4('0x73')](_0x1ee737[_0x73a3bc[_0x2553b4][_0x90f4('0x72')]],'%s',_0x4c1fe9):_0x4c1fe9;_0x4c1fe9=_0x73a3bc[_0x2553b4][_0x90f4('0x74')]?_[_0x90f4('0x73')](_0x4fb487[_0x73a3bc[_0x2553b4]['format']],'%s',_0x4c1fe9):_0x4c1fe9;if(_0x73a3bc[_0x2553b4][_0x90f4('0x75')]){_0x54ea66[_0x90f4('0x66')](_0x4c1fe9);}_0x73a3bc[_0x2553b4]['orderBy']&&_0x54ea66[_0x90f4('0x3e')](_0x4c1fe9,_0x73a3bc[_0x2553b4]['orderBy']===_0x90f4('0x77')?![]:!![]);_0x54ea66[_0x90f4('0x67')](_0x4c1fe9,_0x73a3bc[_0x2553b4][_0x90f4('0x78')]||_0x4c1fe9);}if(_0x383ecb[_0x90f4('0x79')]){_0x383ecb[_0x90f4('0x79')]=JSON[_0x90f4('0x7a')](_0x383ecb[_0x90f4('0x79')]);for(var _0x57186d=0x0;_0x57186d<_0x383ecb[_0x90f4('0x79')][_0x90f4('0x3b')];_0x57186d+=0x1){if(_0x383ecb['joins'][_0x57186d][_0x90f4('0x33')]&&_[_0x90f4('0x61')](_0x517bbe,_0x383ecb[_0x90f4('0x79')][_0x57186d]['type'])&&_0x383ecb[_0x90f4('0x79')][_0x57186d]['parentKey']&&_0x383ecb[_0x90f4('0x79')][_0x57186d][_0x90f4('0x7b')]&&_0x383ecb[_0x90f4('0x79')][_0x57186d][_0x90f4('0x7d')]){_0x54ea66[_0x383ecb['joins'][_0x57186d][_0x90f4('0x33')]](_0x383ecb[_0x90f4('0x79')][_0x57186d]['foreignTable'],null,util[_0x90f4('0x74')]('%s.%s\x20=\x20%s.%s',_0x383ecb[_0x90f4('0x6f')],_0x383ecb[_0x90f4('0x79')][_0x57186d][_0x90f4('0x7c')],_0x383ecb[_0x90f4('0x79')][_0x57186d][_0x90f4('0x7b')],_0x383ecb['joins'][_0x57186d][_0x90f4('0x7d')]));}}}if(_0x383ecb[_0x90f4('0x7e')]){_0x383ecb[_0x90f4('0x7e')]=JSON[_0x90f4('0x7a')](_0x383ecb[_0x90f4('0x7e')]);_0x54ea66[_0x90f4('0x42')](_0x5e0792(_0x383ecb[_0x90f4('0x7e')]['group']));}_0x40fc3b=_0x54ea66[_0x90f4('0x7f')]();_0x54ea66['limit'](_0x887446);_0x54ea66['offset'](0x0);return;}})[_0x90f4('0x25')](function(){if(_0x332884[_0x90f4('0x91')]===_0x90f4('0x92')){return null;}var _0x19de8e=_[_0x90f4('0x43')](_0x332884,{'name':_0x332884['fullPath']||_0x332884[_0x90f4('0x2d')]||_0x383ecb[_0x90f4('0x2d')],'basename':_0x1ddd91,'savename':util[_0x90f4('0x74')]('%s-%s.%s',_0x332884[_0x90f4('0x2d')]||_0x383ecb[_0x90f4('0x2d')],require(_0x90f4('0x93'))['generate'](0x4),_0x332884['output']||_0x90f4('0x94')),'reportId':_0x383ecb['id'],'reportType':_0x90f4('0x95')});return db['AnalyticExtractedReport']['create'](_0x19de8e,{'raw':!![]});})['then'](function(_0x23e324){if(_0x383ecb[_0x90f4('0x6f')]==='cdr'){_0x40fc3b[_0x90f4('0x42')](_0x383ecb[_0x90f4('0x6f')]+_0x90f4('0x96'),_0x332884[_0x90f4('0x97')],_0x332884['endDate']);}else{_0x40fc3b[_0x90f4('0x42')](_0x383ecb[_0x90f4('0x6f')]+_0x90f4('0x98'),_0x332884[_0x90f4('0x97')],_0x332884[_0x90f4('0x99')]);}if(_0x23e324){logger[_0x90f4('0x9a')](_0x90f4('0x9b'),_0x40fc3b[_0x90f4('0x82')]());require(_0x90f4('0x9c'))[_0x90f4('0x9d')](path[_0x90f4('0x57')](__dirname,_0x90f4('0x9e'),_0x23e324['output']),[_0x23e324['id'],_0x40fc3b[_0x90f4('0x82')](),path['join'](__dirname,_0x90f4('0x9f'),_0x23e324[_0x90f4('0xa0')]),_0x1ddd91]);return _0x23e324;}else{var _0x55c0ed=squel[_0x90f4('0x90')]();_0x55c0ed[_0x90f4('0x6e')]('('+_0x40fc3b[_0x90f4('0x82')]()+')',_0x90f4('0xa1'));_0x55c0ed['field'](_0x90f4('0xa2'),'count');_0x40fc3b[_0x90f4('0x1f')](_0x332884[_0x90f4('0x1f')]||_0x887446);_0x40fc3b['offset'](_0x332884['offset']||0x0);return dbH['sequelize'][_0x90f4('0x36')](_0x55c0ed[_0x90f4('0x82')](),{'type':dbH[_0x90f4('0x83')]['QueryTypes'][_0x90f4('0x85')]})[_0x90f4('0x25')](function(_0x1544b8){if(!_0x1544b8[_0x90f4('0x3b')]){_0x3ad40f=0x0;}else{_0x3ad40f=_0x1544b8[0x0][_0x90f4('0x1d')]||0x0;}return dbH[_0x90f4('0x83')][_0x90f4('0x36')](_0x40fc3b[_0x90f4('0x82')](),{'type':dbH[_0x90f4('0x83')][_0x90f4('0x84')]['SELECT']});})[_0x90f4('0x25')](function(_0x11c77f){return{'rows':_0x11c77f||[],'count':_0x3ad40f};});}});}exports[_0x90f4('0xa3')]=function(_0x3a6f52,_0x4937c7){return runReport(_0x3a6f52[_0x90f4('0x4b')],_0x3a6f52[_0x90f4('0x36')],_0x3a6f52[_0x90f4('0x44')])[_0x90f4('0x25')](respondWithResult(_0x4937c7,null))[_0x90f4('0x49')](handleError(_0x4937c7,null));};exports[_0x90f4('0xa4')]=runReport;exports['query']=function(_0x274a06,_0x18f1ef){var _0x13f02e=0xa;var _0x4b2868=[_0x90f4('0x57'),_0x90f4('0x86'),'right_join',_0x90f4('0x58')];var _0x528fb9={'SUM':_0x90f4('0x88'),'COUNT':'COUNT(%s)','COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x90f4('0x5b'),'MIN':_0x90f4('0xa5'),'AVG':_0x90f4('0x89'),'GROUP_CONCAT':_0x90f4('0x8a'),'GROUP_CONCAT ASC':_0x90f4('0x8b'),'GROUP_CONCAT DESC':_0x90f4('0x5c')};var _0x27d653={'SEC_TO_TIME':_0x90f4('0x5d'),'DATE':_0x90f4('0x5e'),'HOUR':_0x90f4('0x8c'),'ROUND':_0x90f4('0x5f'),'UNIX_TIMESTAMP':_0x90f4('0x60')};var _0x311833=function(_0x471c98){return!_[_0x90f4('0x61')]([_0x90f4('0x62'),_0x90f4('0x63'),_0x90f4('0xa6'),_0x90f4('0x64')],_0x471c98);};var _0x4f10d9=function(_0x3abe0e){if(!_0x3abe0e||!_0x3abe0e[_0x90f4('0x65')]['length']){return'';}for(var _0x4e5617='(',_0x71f00c=0x0;_0x71f00c<_0x3abe0e[_0x90f4('0x65')][_0x90f4('0x3b')];_0x71f00c+=0x1){_0x71f00c>0x0&&(_0x4e5617+='\x20'+_0x3abe0e['operator']+'\x20');_0x4e5617+=_0x3abe0e[_0x90f4('0x65')][_0x71f00c][_0x90f4('0x66')]?_0x4f10d9(_0x3abe0e['rules'][_0x71f00c]['group']):_0x3abe0e['rules'][_0x71f00c][_0x90f4('0x67')]+'\x20'+_0x3abe0e['rules'][_0x71f00c][_0x90f4('0x68')]+(_0x311833(_0x3abe0e[_0x90f4('0x65')][_0x71f00c]['condition'])?'\x20'+_0x3abe0e[_0x90f4('0x65')][_0x71f00c][_0x90f4('0x69')]:'');}return _0x4e5617+')';};var _0x2f318b={'where':{'id':_0x274a06['params']['id']}},_0x4a2e6b,_0x5bfb8b,_0x2a3e14,_0x4f6bc3,_0x11bcb0;_0x2f318b=_[_0x90f4('0x43')]({},_0x2f318b,_0x274a06[_0x90f4('0x44')]);return db['AnalyticCustomReport'][_0x90f4('0x53')](_0x2f318b)[_0x90f4('0x25')](function(_0x52c878){if(_0x52c878){_0x4a2e6b=_0x52c878;return _0x52c878[_0x90f4('0x6a')]();}return null;})[_0x90f4('0x25')](function(_0x53effb){if(_0x53effb){if(!_0x53effb[_0x90f4('0x3b')]){throw new db[(_0x90f4('0x8e'))][(_0x90f4('0x6b'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x5bfb8b=_0x53effb;return db[_0x90f4('0x6c')][_0x90f4('0x47')]({'raw':!![]});}return null;})[_0x90f4('0x25')](function(_0x458fce){if(_0x458fce){_0x2a3e14=_['keyBy'](_0x458fce,'id');var _0x3eba2c;var _0x3139fc=squel['select']();_0x3139fc['from'](_0x4a2e6b[_0x90f4('0x6f')]);for(var _0x17e3db=0x0;_0x17e3db<_0x5bfb8b['length'];_0x17e3db+=0x1){_0x3eba2c=_0x5bfb8b[_0x17e3db][_0x90f4('0x70')]?_0x2a3e14[_0x5bfb8b[_0x17e3db][_0x90f4('0x70')]]['metric']:_0x5bfb8b[_0x17e3db][_0x90f4('0x67')];_0x3eba2c=_0x5bfb8b[_0x17e3db][_0x90f4('0x72')]?_[_0x90f4('0x73')](_0x528fb9[_0x5bfb8b[_0x17e3db][_0x90f4('0x72')]],'%s',_0x3eba2c):_0x3eba2c;_0x3eba2c=_0x5bfb8b[_0x17e3db]['format']?_[_0x90f4('0x73')](_0x27d653[_0x5bfb8b[_0x17e3db][_0x90f4('0x74')]],'%s',_0x3eba2c):_0x3eba2c;if(_0x5bfb8b[_0x17e3db][_0x90f4('0x75')]){_0x3139fc[_0x90f4('0x66')](_0x3eba2c);}_0x5bfb8b[_0x17e3db]['orderBy']&&_0x3139fc[_0x90f4('0x3e')](_0x3eba2c,_0x5bfb8b[_0x17e3db][_0x90f4('0x76')]===_0x90f4('0x77')?![]:!![]);_0x3139fc[_0x90f4('0x67')](_0x3eba2c,_0x5bfb8b[_0x17e3db][_0x90f4('0x78')]||_0x3eba2c);}if(_0x4a2e6b[_0x90f4('0x79')]){_0x4a2e6b[_0x90f4('0x79')]=JSON[_0x90f4('0x7a')](_0x4a2e6b['joins']);for(var _0x50d38a=0x0;_0x50d38a<_0x4a2e6b[_0x90f4('0x79')]['length'];_0x50d38a+=0x1){if(_0x4a2e6b[_0x90f4('0x79')][_0x50d38a]['type']&&_['includes'](_0x4b2868,_0x4a2e6b[_0x90f4('0x79')][_0x50d38a]['type'])&&_0x4a2e6b['joins'][_0x50d38a][_0x90f4('0x7c')]&&_0x4a2e6b['joins'][_0x50d38a][_0x90f4('0x7b')]&&_0x4a2e6b[_0x90f4('0x79')][_0x50d38a][_0x90f4('0x7d')]){_0x3139fc[_0x4a2e6b[_0x90f4('0x79')][_0x50d38a]['type']](_0x4a2e6b[_0x90f4('0x79')][_0x50d38a]['foreignTable'],null,util[_0x90f4('0x74')](_0x90f4('0xa7'),_0x4a2e6b[_0x90f4('0x6f')],_0x4a2e6b[_0x90f4('0x79')][_0x50d38a][_0x90f4('0x7c')],_0x4a2e6b['joins'][_0x50d38a][_0x90f4('0x7b')],_0x4a2e6b[_0x90f4('0x79')][_0x50d38a][_0x90f4('0x7d')]));}}}if(_0x4a2e6b[_0x90f4('0x7e')]){_0x4a2e6b[_0x90f4('0x7e')]=JSON[_0x90f4('0x7a')](_0x4a2e6b[_0x90f4('0x7e')]);_0x3139fc[_0x90f4('0x42')](_0x4f10d9(_0x4a2e6b[_0x90f4('0x7e')]['group']));}_0x11bcb0=_0x3139fc[_0x90f4('0x7f')]();_0x3139fc['limit'](_0x13f02e);_0x3139fc[_0x90f4('0x1e')](0x0);logger[_0x90f4('0x80')](_0x90f4('0x81'),_0x3139fc[_0x90f4('0x82')]());return dbH[_0x90f4('0x83')][_0x90f4('0x36')](_0x3139fc[_0x90f4('0x82')](),{'type':dbH['sequelize'][_0x90f4('0x84')][_0x90f4('0x85')]});}})[_0x90f4('0x25')](function(){return{'sql':_0x11bcb0[_0x90f4('0x82')]()};})['then'](respondWithResult(_0x18f1ef,null))[_0x90f4('0x49')](handleError(_0x18f1ef,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