Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / analyticCustomReport / analyticCustomReport.controller.js
index 72bf784..dcd928d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x77bb=['moment','mustache','util','path','sox','to-csv','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','end','status','offset','set','json','apply','reject','update','then','destroy','CustomReports','UserProfileResource','error','stack','name','send','index','map','AnalyticCustomReport','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','where','merge','VIRTUAL','count','include','findAll','show','intersection','length','includeAll','options','find','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','Reports','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','preview','join','left_join','right_join','SUM(%s)','COUNT(%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','DATE(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','operator','rules','condition','value','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','select','from','MetricId','field','function','format','replace','groupBy','orderBy','DESC','alias','joins','parse','parentKey','foreignTable','foreignKey','table','conditions','group','clone','debug','Limited\x20Query:','toString','sequelize','QueryTypes','SELECT','cross_join','COUNT(DISTINCT\x20%s)','ROUND(%s)','AnalyticMetric','metric','%s.%s\x20=\x20%s.%s','No\x20available\x20data','output','%s-%s.%s','randomstring','generate','custom','cdr','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','startDate','info','Run\x20Query:','child_process','fork','../../files/reports','savename','countTable','COUNT(*)','run','SEC_TO_TIME(%s)','html-pdf','rimraf','fast-json-patch'];(function(_0x195c21,_0x332612){var _0x3576a8=function(_0xa4bde2){while(--_0xa4bde2){_0x195c21['push'](_0x195c21['shift']());}};_0x3576a8(++_0x332612);}(_0x77bb,0xa0));var _0xb77b=function(_0x34e0ec,_0x4f524f){_0x34e0ec=_0x34e0ec-0x0;var _0x104790=_0x77bb[_0x34e0ec];return _0x104790;};'use strict';var pdf=require(_0xb77b('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xb77b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb77b('0x2'));var rp=require('request-promise');var moment=require(_0xb77b('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xb77b('0x4'));var util=require(_0xb77b('0x5'));var path=require(_0xb77b('0x6'));var sox=require(_0xb77b('0x7'));var csv=require(_0xb77b('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xb77b('0x9'));var jsforce=require(_0xb77b('0xa'));var deskjs=require(_0xb77b('0xb'));var toCsv=require(_0xb77b('0x8'));var querystring=require(_0xb77b('0xc'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xb77b('0xd'));var qs=require(_0xb77b('0xe'));var as=require(_0xb77b('0xf'));var hardwareService=require(_0xb77b('0x10'));var logger=require(_0xb77b('0x11'))(_0xb77b('0x12'));var utils=require(_0xb77b('0x13'));var config=require(_0xb77b('0x14'));var licenseUtil=require(_0xb77b('0x15'));var db=require(_0xb77b('0x16'))['db'];var dbH=require(_0xb77b('0x16'))[_0xb77b('0x17')];function respondWithStatusCode(_0x399bb1,_0x36bf01){_0x36bf01=_0x36bf01||0xcc;return function(_0x11ec30){if(_0x11ec30){return _0x399bb1[_0xb77b('0x18')](_0x36bf01);}return _0x399bb1['status'](_0x36bf01)[_0xb77b('0x19')]();};}function respondWithResult(_0x300640,_0x78a774){_0x78a774=_0x78a774||0xc8;return function(_0x17100d){if(_0x17100d){return _0x300640[_0xb77b('0x1a')](_0x78a774)['json'](_0x17100d);}};}function respondWithFilteredResult(_0x4e9318,_0x35c0d1){return function(_0x28e6f6){if(_0x28e6f6){var _0x37e905=_0x28e6f6['count'],_0x28af9b=_0x35c0d1['offset'],_0x376deb=_0x35c0d1[_0xb77b('0x1b')]+_0x35c0d1['limit'],_0x4d43a2;if(_0x376deb>=_0x37e905){_0x376deb=_0x37e905;_0x4d43a2=0xc8;}else{_0x4d43a2=0xce;}_0x4e9318[_0xb77b('0x1a')](_0x4d43a2);return _0x4e9318[_0xb77b('0x1c')]('Content-Range',_0x28af9b+'-'+_0x376deb+'/'+_0x37e905)[_0xb77b('0x1d')](_0x28e6f6);}return null;};}function patchUpdates(_0x3d99b4){return function(_0x55fdf0){try{jsonpatch[_0xb77b('0x1e')](_0x55fdf0,_0x3d99b4,!![]);}catch(_0x555c73){return BPromise[_0xb77b('0x1f')](_0x555c73);}return _0x55fdf0['save']();};}function saveUpdates(_0x27c68a,_0x5f5201){return function(_0x5c6e75){if(_0x5c6e75){return _0x5c6e75[_0xb77b('0x20')](_0x27c68a)[_0xb77b('0x21')](function(_0x43d771){return _0x43d771;});}return null;};}function removeEntity(_0x551815,_0x227743){return function(_0x540d5f){if(_0x540d5f){return _0x540d5f[_0xb77b('0x22')]()[_0xb77b('0x21')](function(){var _0x476ec4=_0x540d5f['get']({'plain':!![]});var _0x59d70e=_0xb77b('0x23');return db[_0xb77b('0x24')][_0xb77b('0x22')]({'where':{'type':_0x59d70e,'resourceId':_0x476ec4['id']}})[_0xb77b('0x21')](function(){return _0x540d5f;});})[_0xb77b('0x21')](function(){_0x551815[_0xb77b('0x1a')](0xcc)[_0xb77b('0x19')]();});}};}function handleEntityNotFound(_0x93ab4,_0x11e275){return function(_0x45dec4){if(!_0x45dec4){_0x93ab4[_0xb77b('0x18')](0x194);}return _0x45dec4;};}function handleError(_0x1c6a11,_0x5bb757){_0x5bb757=_0x5bb757||0x1f4;return function(_0x408182){logger[_0xb77b('0x25')](_0x408182[_0xb77b('0x26')]);if(_0x408182[_0xb77b('0x27')]){delete _0x408182[_0xb77b('0x27')];}_0x1c6a11[_0xb77b('0x1a')](_0x5bb757)[_0xb77b('0x28')](_0x408182);};}exports[_0xb77b('0x29')]=function(_0x556a9b,_0x292e96){var _0x4d6cb2={},_0x5c7265={},_0x5102bd={'count':0x0,'rows':[]};var _0x103d35=_[_0xb77b('0x2a')](db[_0xb77b('0x2b')][_0xb77b('0x2c')],function(_0x21a1a2){return{'name':_0x21a1a2[_0xb77b('0x2d')],'type':_0x21a1a2[_0xb77b('0x2e')][_0xb77b('0x2f')]};});_0x5c7265[_0xb77b('0x30')]=_[_0xb77b('0x2a')](_0x103d35,_0xb77b('0x27'));_0x5c7265['query']=_[_0xb77b('0x31')](_0x556a9b[_0xb77b('0x32')]);_0x5c7265[_0xb77b('0x33')]=_['intersection'](_0x5c7265[_0xb77b('0x30')],_0x5c7265[_0xb77b('0x32')]);_0x4d6cb2[_0xb77b('0x34')]=_['intersection'](_0x5c7265[_0xb77b('0x30')],qs[_0xb77b('0x35')](_0x556a9b[_0xb77b('0x32')][_0xb77b('0x35')]));_0x4d6cb2['attributes']=_0x4d6cb2[_0xb77b('0x34')]['length']?_0x4d6cb2[_0xb77b('0x34')]:_0x5c7265[_0xb77b('0x30')];if(!_0x556a9b[_0xb77b('0x32')][_0xb77b('0x36')](_0xb77b('0x37'))){_0x4d6cb2[_0xb77b('0x38')]=qs['limit'](_0x556a9b['query'][_0xb77b('0x38')]);_0x4d6cb2[_0xb77b('0x1b')]=qs[_0xb77b('0x1b')](_0x556a9b[_0xb77b('0x32')][_0xb77b('0x1b')]);}_0x4d6cb2[_0xb77b('0x39')]=qs[_0xb77b('0x3a')](_0x556a9b[_0xb77b('0x32')][_0xb77b('0x3a')]);_0x4d6cb2[_0xb77b('0x3b')]=qs[_0xb77b('0x33')](_['pick'](_0x556a9b['query'],_0x5c7265[_0xb77b('0x33')]),_0x103d35);if(_0x556a9b[_0xb77b('0x32')]['filter']){_0x4d6cb2['where']=_[_0xb77b('0x3c')](_0x4d6cb2[_0xb77b('0x3b')],{'$or':_[_0xb77b('0x2a')](_0x103d35,function(_0x5f2eda){if(_0x5f2eda[_0xb77b('0x2e')]!==_0xb77b('0x3d')){var _0x46dc9e={};_0x46dc9e[_0x5f2eda[_0xb77b('0x27')]]={'$like':'%'+_0x556a9b[_0xb77b('0x32')]['filter']+'%'};return _0x46dc9e;}})});}_0x4d6cb2=_[_0xb77b('0x3c')]({},_0x4d6cb2,_0x556a9b['options']);var _0x13c4fb={'where':_0x4d6cb2['where']};return db[_0xb77b('0x2b')][_0xb77b('0x3e')](_0x13c4fb)['then'](function(_0xbc78e1){_0x5102bd['count']=_0xbc78e1;if(_0x556a9b[_0xb77b('0x32')]['includeAll']){_0x4d6cb2[_0xb77b('0x3f')]=[{'all':!![]}];}return db[_0xb77b('0x2b')][_0xb77b('0x40')](_0x4d6cb2);})['then'](function(_0x2653d){_0x5102bd['rows']=_0x2653d;return _0x5102bd;})[_0xb77b('0x21')](respondWithFilteredResult(_0x292e96,_0x4d6cb2))['catch'](handleError(_0x292e96,null));};exports[_0xb77b('0x41')]=function(_0x3e61cd,_0x3521df){var _0x141228={'raw':![],'where':{'id':_0x3e61cd['params']['id']}},_0x1e9f01={};_0x1e9f01[_0xb77b('0x30')]=_['keys'](db[_0xb77b('0x2b')][_0xb77b('0x2c')]);_0x1e9f01[_0xb77b('0x32')]=_[_0xb77b('0x31')](_0x3e61cd['query']);_0x1e9f01[_0xb77b('0x33')]=_['intersection'](_0x1e9f01[_0xb77b('0x30')],_0x1e9f01[_0xb77b('0x32')]);_0x141228['attributes']=_[_0xb77b('0x42')](_0x1e9f01[_0xb77b('0x30')],qs[_0xb77b('0x35')](_0x3e61cd[_0xb77b('0x32')][_0xb77b('0x35')]));_0x141228[_0xb77b('0x34')]=_0x141228['attributes'][_0xb77b('0x43')]?_0x141228[_0xb77b('0x34')]:_0x1e9f01['model'];if(_0x3e61cd[_0xb77b('0x32')][_0xb77b('0x44')]){_0x141228[_0xb77b('0x3f')]=[{'all':!![]}];}_0x141228=_[_0xb77b('0x3c')]({},_0x141228,_0x3e61cd[_0xb77b('0x45')]);return db[_0xb77b('0x2b')][_0xb77b('0x46')](_0x141228)['then'](handleEntityNotFound(_0x3521df,null))[_0xb77b('0x21')](respondWithResult(_0x3521df,null))[_0xb77b('0x47')](handleError(_0x3521df,null));};exports[_0xb77b('0x48')]=function(_0x29c8f2,_0x4337aa){return db[_0xb77b('0x2b')][_0xb77b('0x48')](_0x29c8f2[_0xb77b('0x49')],{})[_0xb77b('0x21')](function(_0x8bdc15){var _0x38286a=_0x29c8f2[_0xb77b('0x4a')][_0xb77b('0x4b')]({'plain':!![]});if(!_0x38286a)throw new Error(_0xb77b('0x4c'));if(_0x38286a['role']==='user'){var _0x55f7bd=_0x8bdc15[_0xb77b('0x4b')]({'plain':!![]});var _0x1ffffb=_0xb77b('0x4d');return db[_0xb77b('0x4e')][_0xb77b('0x46')]({'where':{'name':_0x1ffffb,'userProfileId':_0x38286a[_0xb77b('0x4f')]},'raw':!![]})[_0xb77b('0x21')](function(_0x45c1cb){if(_0x45c1cb&&_0x45c1cb[_0xb77b('0x50')]===0x0){return db[_0xb77b('0x24')][_0xb77b('0x48')]({'name':_0x55f7bd[_0xb77b('0x27')],'resourceId':_0x55f7bd['id'],'type':_0xb77b('0x23'),'sectionId':_0x45c1cb['id']},{})[_0xb77b('0x21')](function(){return _0x8bdc15;});}else{return _0x8bdc15;}})[_0xb77b('0x47')](function(_0x52bc46){logger[_0xb77b('0x25')](_0xb77b('0x51'),_0x52bc46);throw _0x52bc46;});}return _0x8bdc15;})[_0xb77b('0x21')](respondWithResult(_0x4337aa,0xc9))[_0xb77b('0x47')](handleError(_0x4337aa,null));};exports['update']=function(_0x11d932,_0x30b200){if(_0x11d932['body']['id']){delete _0x11d932['body']['id'];}return db[_0xb77b('0x2b')]['find']({'where':{'id':_0x11d932[_0xb77b('0x52')]['id']}})[_0xb77b('0x21')](handleEntityNotFound(_0x30b200,null))[_0xb77b('0x21')](saveUpdates(_0x11d932[_0xb77b('0x49')],null))[_0xb77b('0x21')](respondWithResult(_0x30b200,null))[_0xb77b('0x47')](handleError(_0x30b200,null));};exports[_0xb77b('0x22')]=function(_0x3ac787,_0x5120a9){return db[_0xb77b('0x2b')][_0xb77b('0x46')]({'where':{'id':_0x3ac787['params']['id']}})[_0xb77b('0x21')](handleEntityNotFound(_0x5120a9,null))[_0xb77b('0x21')](removeEntity(_0x5120a9,null))[_0xb77b('0x47')](handleError(_0x5120a9,null));};exports[_0xb77b('0x53')]=function(_0x35cf80,_0x4a6b6d){var _0x23db08=0xa;var _0x4b920f=[_0xb77b('0x54'),_0xb77b('0x55'),_0xb77b('0x56'),'cross_join'];var _0x5d5e17={'SUM':_0xb77b('0x57'),'COUNT':_0xb77b('0x58'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xb77b('0x59'),'MIN':_0xb77b('0x5a'),'AVG':_0xb77b('0x5b'),'GROUP_CONCAT':_0xb77b('0x5c'),'GROUP_CONCAT ASC':_0xb77b('0x5d'),'GROUP_CONCAT DESC':_0xb77b('0x5e')};var _0x145bee={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xb77b('0x5f'),'HOUR':_0xb77b('0x60'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xb77b('0x61')};var _0x115959=function(_0x560001){return!_[_0xb77b('0x62')]([_0xb77b('0x63'),_0xb77b('0x64'),_0xb77b('0x65'),_0xb77b('0x66')],_0x560001);};var _0x1b005d=function(_0x2d71ae){if(!_0x2d71ae||!_0x2d71ae['rules'][_0xb77b('0x43')]){return'';}for(var _0x4995a9='(',_0xa3610=0x0;_0xa3610<_0x2d71ae['rules'][_0xb77b('0x43')];_0xa3610+=0x1){_0xa3610>0x0&&(_0x4995a9+='\x20'+_0x2d71ae[_0xb77b('0x67')]+'\x20');_0x4995a9+=_0x2d71ae[_0xb77b('0x68')][_0xa3610]['group']?_0x1b005d(_0x2d71ae['rules'][_0xa3610]['group']):_0x2d71ae[_0xb77b('0x68')][_0xa3610]['field']+'\x20'+_0x2d71ae[_0xb77b('0x68')][_0xa3610][_0xb77b('0x69')]+(_0x115959(_0x2d71ae['rules'][_0xa3610][_0xb77b('0x69')])?'\x20'+_0x2d71ae[_0xb77b('0x68')][_0xa3610][_0xb77b('0x6a')]:'');}return _0x4995a9+')';};var _0x2ede99={'where':{'id':_0x35cf80[_0xb77b('0x52')]['id']}},_0x58e833,_0x4506c4,_0x2233b1,_0x3f36e3,_0x4eb6e0;_0x2ede99=_['merge']({},_0x2ede99,_0x35cf80[_0xb77b('0x45')]);return db['AnalyticCustomReport'][_0xb77b('0x46')](_0x2ede99)[_0xb77b('0x21')](function(_0xdc9577){if(_0xdc9577){_0x58e833=_0xdc9577;return _0xdc9577[_0xb77b('0x6b')]();}return null;})[_0xb77b('0x21')](function(_0x31f31c){if(_0x31f31c){if(!_0x31f31c[_0xb77b('0x43')]){throw new db[(_0xb77b('0x6c'))][(_0xb77b('0x6d'))](_0xb77b('0x6e'),0x193);}_0x4506c4=_0x31f31c;return db['AnalyticMetric'][_0xb77b('0x40')]({'raw':!![]});}return null;})[_0xb77b('0x21')](function(_0x244f3a){if(_0x244f3a){_0x2233b1=_['keyBy'](_0x244f3a,'id');var _0x1d5b87;var _0xfd359c=squel[_0xb77b('0x6f')]();_0xfd359c[_0xb77b('0x70')](_0x58e833['table']);for(var _0x26871d=0x0;_0x26871d<_0x4506c4[_0xb77b('0x43')];_0x26871d+=0x1){_0x1d5b87=_0x4506c4[_0x26871d][_0xb77b('0x71')]?_0x2233b1[_0x4506c4[_0x26871d]['MetricId']]['metric']:_0x4506c4[_0x26871d][_0xb77b('0x72')];_0x1d5b87=_0x4506c4[_0x26871d][_0xb77b('0x73')]?_['replace'](_0x5d5e17[_0x4506c4[_0x26871d][_0xb77b('0x73')]],'%s',_0x1d5b87):_0x1d5b87;_0x1d5b87=_0x4506c4[_0x26871d][_0xb77b('0x74')]?_[_0xb77b('0x75')](_0x145bee[_0x4506c4[_0x26871d][_0xb77b('0x74')]],'%s',_0x1d5b87):_0x1d5b87;if(_0x4506c4[_0x26871d][_0xb77b('0x76')]){_0xfd359c['group'](_0x1d5b87);}_0x4506c4[_0x26871d][_0xb77b('0x77')]&&_0xfd359c['order'](_0x1d5b87,_0x4506c4[_0x26871d][_0xb77b('0x77')]===_0xb77b('0x78')?![]:!![]);_0xfd359c['field'](_0x1d5b87,_0x4506c4[_0x26871d][_0xb77b('0x79')]||_0x1d5b87);}if(_0x58e833['joins']){_0x58e833[_0xb77b('0x7a')]=JSON[_0xb77b('0x7b')](_0x58e833[_0xb77b('0x7a')]);for(var _0x1c748f=0x0;_0x1c748f<_0x58e833[_0xb77b('0x7a')][_0xb77b('0x43')];_0x1c748f+=0x1){if(_0x58e833['joins'][_0x1c748f]['type']&&_[_0xb77b('0x62')](_0x4b920f,_0x58e833[_0xb77b('0x7a')][_0x1c748f][_0xb77b('0x2e')])&&_0x58e833[_0xb77b('0x7a')][_0x1c748f][_0xb77b('0x7c')]&&_0x58e833['joins'][_0x1c748f][_0xb77b('0x7d')]&&_0x58e833[_0xb77b('0x7a')][_0x1c748f][_0xb77b('0x7e')]){_0xfd359c[_0x58e833[_0xb77b('0x7a')][_0x1c748f][_0xb77b('0x2e')]](_0x58e833[_0xb77b('0x7a')][_0x1c748f]['foreignTable'],null,util[_0xb77b('0x74')]('%s.%s\x20=\x20%s.%s',_0x58e833[_0xb77b('0x7f')],_0x58e833[_0xb77b('0x7a')][_0x1c748f]['parentKey'],_0x58e833['joins'][_0x1c748f][_0xb77b('0x7d')],_0x58e833[_0xb77b('0x7a')][_0x1c748f][_0xb77b('0x7e')]));}}}if(_0x58e833[_0xb77b('0x80')]){_0x58e833[_0xb77b('0x80')]=JSON[_0xb77b('0x7b')](_0x58e833[_0xb77b('0x80')]);_0xfd359c[_0xb77b('0x3b')](_0x1b005d(_0x58e833[_0xb77b('0x80')][_0xb77b('0x81')]));}_0x4eb6e0=_0xfd359c[_0xb77b('0x82')]();_0xfd359c[_0xb77b('0x38')](_0x23db08);_0xfd359c[_0xb77b('0x1b')](0x0);logger[_0xb77b('0x83')](_0xb77b('0x84'),_0xfd359c[_0xb77b('0x85')]());return db[_0xb77b('0x86')][_0xb77b('0x32')](_0xfd359c[_0xb77b('0x85')](),{'type':db[_0xb77b('0x86')][_0xb77b('0x87')][_0xb77b('0x88')]});}})[_0xb77b('0x21')](respondWithResult(_0x4a6b6d,null))[_0xb77b('0x47')](handleError(_0x4a6b6d,null));};function runReport(_0x557aa8,_0x4be44d,_0x46c593){var _0x268ed5=_0x4be44d[_0xb77b('0x27')];var _0x13d9f9=0xa;var _0x203be4=[_0xb77b('0x54'),_0xb77b('0x55'),_0xb77b('0x56'),_0xb77b('0x89')];var _0x33f3f4={'SUM':_0xb77b('0x57'),'COUNT':_0xb77b('0x58'),'COUNT DISTINCT':_0xb77b('0x8a'),'MAX':_0xb77b('0x59'),'MIN':_0xb77b('0x5a'),'AVG':_0xb77b('0x5b'),'GROUP_CONCAT':_0xb77b('0x5c'),'GROUP_CONCAT ASC':_0xb77b('0x5d'),'GROUP_CONCAT DESC':_0xb77b('0x5e')};var _0x3b8834={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xb77b('0x5f'),'HOUR':_0xb77b('0x60'),'ROUND':_0xb77b('0x8b'),'UNIX_TIMESTAMP':_0xb77b('0x61')};var _0x198ab3=function(_0x105559){return!_['includes'](['IS\x20NULL',_0xb77b('0x64'),_0xb77b('0x65'),_0xb77b('0x66')],_0x105559);};var _0x4988c9=function(_0x202423){if(!_0x202423||!_0x202423[_0xb77b('0x68')][_0xb77b('0x43')]){return'';}for(var _0x1c97c9='(',_0xe5bb5d=0x0;_0xe5bb5d<_0x202423['rules']['length'];_0xe5bb5d+=0x1){_0xe5bb5d>0x0&&(_0x1c97c9+='\x20'+_0x202423[_0xb77b('0x67')]+'\x20');_0x1c97c9+=_0x202423[_0xb77b('0x68')][_0xe5bb5d]['group']?_0x4988c9(_0x202423[_0xb77b('0x68')][_0xe5bb5d][_0xb77b('0x81')]):_0x202423['rules'][_0xe5bb5d]['field']+'\x20'+_0x202423[_0xb77b('0x68')][_0xe5bb5d][_0xb77b('0x69')]+(_0x198ab3(_0x202423[_0xb77b('0x68')][_0xe5bb5d][_0xb77b('0x69')])?'\x20'+_0x202423[_0xb77b('0x68')][_0xe5bb5d][_0xb77b('0x6a')]:'');}return _0x1c97c9+')';};var _0x43d6e8={'where':{'id':_0x557aa8['id']}},_0x3bfe8d,_0x56776c,_0x146731,_0x448ac0,_0x4d0918;_0x43d6e8=_[_0xb77b('0x3c')]({},_0x43d6e8,_0x46c593);return db[_0xb77b('0x2b')]['find'](_0x43d6e8)[_0xb77b('0x21')](function(_0x7a98ed){if(_0x7a98ed){_0x3bfe8d=_0x7a98ed;return _0x7a98ed[_0xb77b('0x6b')]();}return null;})['then'](function(_0x442989){if(_0x442989){if(!_0x442989[_0xb77b('0x43')]){throw new db[(_0xb77b('0x6c'))][(_0xb77b('0x6d'))](_0xb77b('0x6e'),0x193);}_0x56776c=_0x442989;return db[_0xb77b('0x8c')][_0xb77b('0x40')]({'raw':!![]});}return null;})['then'](function(_0x1092be){if(_0x1092be){_0x146731=_['keyBy'](_0x1092be,'id');var _0x2969c3;var _0x3a0555=squel[_0xb77b('0x6f')]();_0x3a0555[_0xb77b('0x70')](_0x3bfe8d[_0xb77b('0x7f')]);for(var _0x2a4b67=0x0;_0x2a4b67<_0x56776c['length'];_0x2a4b67+=0x1){_0x2969c3=_0x56776c[_0x2a4b67][_0xb77b('0x71')]?_0x146731[_0x56776c[_0x2a4b67][_0xb77b('0x71')]][_0xb77b('0x8d')]:_0x56776c[_0x2a4b67][_0xb77b('0x72')];_0x2969c3=_0x56776c[_0x2a4b67][_0xb77b('0x73')]?_[_0xb77b('0x75')](_0x33f3f4[_0x56776c[_0x2a4b67]['function']],'%s',_0x2969c3):_0x2969c3;_0x2969c3=_0x56776c[_0x2a4b67][_0xb77b('0x74')]?_['replace'](_0x3b8834[_0x56776c[_0x2a4b67]['format']],'%s',_0x2969c3):_0x2969c3;if(_0x56776c[_0x2a4b67][_0xb77b('0x76')]){_0x3a0555[_0xb77b('0x81')](_0x2969c3);}_0x56776c[_0x2a4b67][_0xb77b('0x77')]&&_0x3a0555[_0xb77b('0x39')](_0x2969c3,_0x56776c[_0x2a4b67][_0xb77b('0x77')]==='DESC'?![]:!![]);_0x3a0555['field'](_0x2969c3,_0x56776c[_0x2a4b67][_0xb77b('0x79')]||_0x2969c3);}if(_0x3bfe8d[_0xb77b('0x7a')]){_0x3bfe8d[_0xb77b('0x7a')]=JSON[_0xb77b('0x7b')](_0x3bfe8d['joins']);for(var _0x1b4b7e=0x0;_0x1b4b7e<_0x3bfe8d[_0xb77b('0x7a')][_0xb77b('0x43')];_0x1b4b7e+=0x1){if(_0x3bfe8d[_0xb77b('0x7a')][_0x1b4b7e][_0xb77b('0x2e')]&&_['includes'](_0x203be4,_0x3bfe8d[_0xb77b('0x7a')][_0x1b4b7e][_0xb77b('0x2e')])&&_0x3bfe8d[_0xb77b('0x7a')][_0x1b4b7e]['parentKey']&&_0x3bfe8d['joins'][_0x1b4b7e][_0xb77b('0x7d')]&&_0x3bfe8d['joins'][_0x1b4b7e]['foreignKey']){_0x3a0555[_0x3bfe8d[_0xb77b('0x7a')][_0x1b4b7e][_0xb77b('0x2e')]](_0x3bfe8d[_0xb77b('0x7a')][_0x1b4b7e][_0xb77b('0x7d')],null,util[_0xb77b('0x74')](_0xb77b('0x8e'),_0x3bfe8d[_0xb77b('0x7f')],_0x3bfe8d[_0xb77b('0x7a')][_0x1b4b7e][_0xb77b('0x7c')],_0x3bfe8d[_0xb77b('0x7a')][_0x1b4b7e][_0xb77b('0x7d')],_0x3bfe8d[_0xb77b('0x7a')][_0x1b4b7e][_0xb77b('0x7e')]));}}}if(_0x3bfe8d[_0xb77b('0x80')]){_0x3bfe8d[_0xb77b('0x80')]=JSON[_0xb77b('0x7b')](_0x3bfe8d[_0xb77b('0x80')]);_0x3a0555[_0xb77b('0x3b')](_0x4988c9(_0x3bfe8d['conditions'][_0xb77b('0x81')]));}_0x4d0918=_0x3a0555[_0xb77b('0x82')]();_0x3a0555[_0xb77b('0x38')](_0x13d9f9);_0x3a0555[_0xb77b('0x1b')](0x0);logger[_0xb77b('0x83')]('Limited\x20Query:',_0x3a0555[_0xb77b('0x85')]());return db['sequelize'][_0xb77b('0x32')](_0x3a0555[_0xb77b('0x85')](),{'type':db['sequelize']['QueryTypes'][_0xb77b('0x88')]});}})[_0xb77b('0x21')](function(_0x2f51db){if(!_0x2f51db[_0xb77b('0x43')]){throw new db[(_0xb77b('0x6c'))][(_0xb77b('0x6d'))](_0xb77b('0x8f'),0xcc);}if(_0x4be44d[_0xb77b('0x90')]==='web'){return null;}var _0x5da56e=_[_0xb77b('0x3c')](_0x4be44d,{'name':_0x4be44d['fullPath']||_0x4be44d['name']||_0x3bfe8d[_0xb77b('0x27')],'basename':_0x268ed5,'savename':util[_0xb77b('0x74')](_0xb77b('0x91'),_0x4be44d[_0xb77b('0x27')]||_0x3bfe8d['name'],require(_0xb77b('0x92'))[_0xb77b('0x93')](0x4),_0x4be44d[_0xb77b('0x90')]||'csv'),'reportId':_0x3bfe8d['id'],'reportType':_0xb77b('0x94')});return db['AnalyticExtractedReport']['create'](_0x5da56e,{'raw':!![]});})[_0xb77b('0x21')](function(_0x3a920a){if(_0x3bfe8d[_0xb77b('0x7f')]===_0xb77b('0x95')){_0x4d0918[_0xb77b('0x3b')](_0x3bfe8d[_0xb77b('0x7f')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x4be44d['startDate'],_0x4be44d[_0xb77b('0x96')]);}else{_0x4d0918['where'](_0x3bfe8d['table']+_0xb77b('0x97'),_0x4be44d[_0xb77b('0x98')],_0x4be44d[_0xb77b('0x96')]);}if(_0x3a920a){logger[_0xb77b('0x99')](_0xb77b('0x9a'),_0x4d0918[_0xb77b('0x85')]());require(_0xb77b('0x9b'))[_0xb77b('0x9c')](path[_0xb77b('0x54')](__dirname,'../../components/export/',_0x3a920a['output']),[_0x3a920a['id'],_0x4d0918[_0xb77b('0x85')](),path[_0xb77b('0x54')](__dirname,_0xb77b('0x9d'),_0x3a920a[_0xb77b('0x9e')]),_0x268ed5]);return _0x3a920a;}else{var _0x3e665d=squel[_0xb77b('0x6f')]();_0x3e665d[_0xb77b('0x70')]('('+_0x4d0918[_0xb77b('0x85')]()+')',_0xb77b('0x9f'));_0x3e665d[_0xb77b('0x72')](_0xb77b('0xa0'),'count');_0x4d0918[_0xb77b('0x38')](_0x4be44d['limit']||_0x13d9f9);_0x4d0918[_0xb77b('0x1b')](_0x4be44d['offset']||0x0);return dbH['sequelize'][_0xb77b('0x32')](_0x3e665d['toString'](),{'type':dbH[_0xb77b('0x86')][_0xb77b('0x87')][_0xb77b('0x88')]})[_0xb77b('0x21')](function(_0x452304){if(!_0x452304[_0xb77b('0x43')]){_0x448ac0=0x0;}else{_0x448ac0=_0x452304[0x0][_0xb77b('0x3e')]||0x0;}return dbH[_0xb77b('0x86')]['query'](_0x4d0918[_0xb77b('0x85')](),{'type':dbH[_0xb77b('0x86')][_0xb77b('0x87')][_0xb77b('0x88')]});})[_0xb77b('0x21')](function(_0x50e910){return{'rows':_0x50e910||[],'count':_0x448ac0};});}});}exports[_0xb77b('0xa1')]=function(_0x9233c7,_0xe75566){return runReport(_0x9233c7['params'],_0x9233c7[_0xb77b('0x32')],_0x9233c7[_0xb77b('0x45')])[_0xb77b('0x21')](respondWithResult(_0xe75566,null))[_0xb77b('0x47')](handleError(_0xe75566,null));};exports['runReport']=runReport;exports[_0xb77b('0x32')]=function(_0x4c1019,_0x13114b){var _0xef7fdc=0xa;var _0x412449=[_0xb77b('0x54'),_0xb77b('0x55'),_0xb77b('0x56'),_0xb77b('0x89')];var _0x2882cc={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xb77b('0x59'),'MIN':_0xb77b('0x5a'),'AVG':_0xb77b('0x5b'),'GROUP_CONCAT':_0xb77b('0x5c'),'GROUP_CONCAT ASC':_0xb77b('0x5d'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x2a9aa6={'SEC_TO_TIME':_0xb77b('0xa2'),'DATE':_0xb77b('0x5f'),'HOUR':_0xb77b('0x60'),'ROUND':_0xb77b('0x8b'),'UNIX_TIMESTAMP':_0xb77b('0x61')};var _0x29d334=function(_0x5df1c3){return!_[_0xb77b('0x62')](['IS\x20NULL',_0xb77b('0x64'),_0xb77b('0x65'),_0xb77b('0x66')],_0x5df1c3);};var _0x539497=function(_0x266b7f){if(!_0x266b7f||!_0x266b7f['rules']['length']){return'';}for(var _0xd3af4f='(',_0x1da3db=0x0;_0x1da3db<_0x266b7f['rules'][_0xb77b('0x43')];_0x1da3db+=0x1){_0x1da3db>0x0&&(_0xd3af4f+='\x20'+_0x266b7f[_0xb77b('0x67')]+'\x20');_0xd3af4f+=_0x266b7f[_0xb77b('0x68')][_0x1da3db][_0xb77b('0x81')]?_0x539497(_0x266b7f[_0xb77b('0x68')][_0x1da3db][_0xb77b('0x81')]):_0x266b7f[_0xb77b('0x68')][_0x1da3db][_0xb77b('0x72')]+'\x20'+_0x266b7f[_0xb77b('0x68')][_0x1da3db][_0xb77b('0x69')]+(_0x29d334(_0x266b7f[_0xb77b('0x68')][_0x1da3db][_0xb77b('0x69')])?'\x20'+_0x266b7f[_0xb77b('0x68')][_0x1da3db][_0xb77b('0x6a')]:'');}return _0xd3af4f+')';};var _0x26b193={'where':{'id':_0x4c1019[_0xb77b('0x52')]['id']}},_0x3d42b0,_0x4504c6,_0x412ede,_0x43aaa0,_0x5973d4;_0x26b193=_[_0xb77b('0x3c')]({},_0x26b193,_0x4c1019[_0xb77b('0x45')]);return db[_0xb77b('0x2b')]['find'](_0x26b193)[_0xb77b('0x21')](function(_0x738ddd){if(_0x738ddd){_0x3d42b0=_0x738ddd;return _0x738ddd[_0xb77b('0x6b')]();}return null;})[_0xb77b('0x21')](function(_0x509db0){if(_0x509db0){if(!_0x509db0[_0xb77b('0x43')]){throw new db[(_0xb77b('0x6c'))][(_0xb77b('0x6d'))](_0xb77b('0x6e'),0x193);}_0x4504c6=_0x509db0;return db[_0xb77b('0x8c')]['findAll']({'raw':!![]});}return null;})[_0xb77b('0x21')](function(_0x4099c5){if(_0x4099c5){_0x412ede=_['keyBy'](_0x4099c5,'id');var _0x361103;var _0x17cf4a=squel[_0xb77b('0x6f')]();_0x17cf4a[_0xb77b('0x70')](_0x3d42b0['table']);for(var _0x49a5e3=0x0;_0x49a5e3<_0x4504c6['length'];_0x49a5e3+=0x1){_0x361103=_0x4504c6[_0x49a5e3]['MetricId']?_0x412ede[_0x4504c6[_0x49a5e3][_0xb77b('0x71')]]['metric']:_0x4504c6[_0x49a5e3][_0xb77b('0x72')];_0x361103=_0x4504c6[_0x49a5e3][_0xb77b('0x73')]?_[_0xb77b('0x75')](_0x2882cc[_0x4504c6[_0x49a5e3][_0xb77b('0x73')]],'%s',_0x361103):_0x361103;_0x361103=_0x4504c6[_0x49a5e3][_0xb77b('0x74')]?_[_0xb77b('0x75')](_0x2a9aa6[_0x4504c6[_0x49a5e3][_0xb77b('0x74')]],'%s',_0x361103):_0x361103;if(_0x4504c6[_0x49a5e3][_0xb77b('0x76')]){_0x17cf4a[_0xb77b('0x81')](_0x361103);}_0x4504c6[_0x49a5e3][_0xb77b('0x77')]&&_0x17cf4a['order'](_0x361103,_0x4504c6[_0x49a5e3][_0xb77b('0x77')]==='DESC'?![]:!![]);_0x17cf4a[_0xb77b('0x72')](_0x361103,_0x4504c6[_0x49a5e3][_0xb77b('0x79')]||_0x361103);}if(_0x3d42b0['joins']){_0x3d42b0[_0xb77b('0x7a')]=JSON[_0xb77b('0x7b')](_0x3d42b0[_0xb77b('0x7a')]);for(var _0x129c0b=0x0;_0x129c0b<_0x3d42b0[_0xb77b('0x7a')][_0xb77b('0x43')];_0x129c0b+=0x1){if(_0x3d42b0[_0xb77b('0x7a')][_0x129c0b][_0xb77b('0x2e')]&&_[_0xb77b('0x62')](_0x412449,_0x3d42b0['joins'][_0x129c0b]['type'])&&_0x3d42b0['joins'][_0x129c0b]['parentKey']&&_0x3d42b0[_0xb77b('0x7a')][_0x129c0b][_0xb77b('0x7d')]&&_0x3d42b0[_0xb77b('0x7a')][_0x129c0b][_0xb77b('0x7e')]){_0x17cf4a[_0x3d42b0[_0xb77b('0x7a')][_0x129c0b][_0xb77b('0x2e')]](_0x3d42b0[_0xb77b('0x7a')][_0x129c0b]['foreignTable'],null,util[_0xb77b('0x74')]('%s.%s\x20=\x20%s.%s',_0x3d42b0[_0xb77b('0x7f')],_0x3d42b0['joins'][_0x129c0b]['parentKey'],_0x3d42b0[_0xb77b('0x7a')][_0x129c0b][_0xb77b('0x7d')],_0x3d42b0[_0xb77b('0x7a')][_0x129c0b]['foreignKey']));}}}if(_0x3d42b0['conditions']){_0x3d42b0[_0xb77b('0x80')]=JSON[_0xb77b('0x7b')](_0x3d42b0['conditions']);_0x17cf4a[_0xb77b('0x3b')](_0x539497(_0x3d42b0['conditions'][_0xb77b('0x81')]));}_0x5973d4=_0x17cf4a[_0xb77b('0x82')]();_0x17cf4a[_0xb77b('0x38')](_0xef7fdc);_0x17cf4a['offset'](0x0);logger['debug']('Limited\x20Query:',_0x17cf4a[_0xb77b('0x85')]());return db[_0xb77b('0x86')][_0xb77b('0x32')](_0x17cf4a[_0xb77b('0x85')](),{'type':db[_0xb77b('0x86')][_0xb77b('0x87')][_0xb77b('0x88')]});}})[_0xb77b('0x21')](function(){return{'sql':_0x5973d4[_0xb77b('0x85')]()};})[_0xb77b('0x21')](respondWithResult(_0x13114b,null))['catch'](handleError(_0x13114b,null));};
\ No newline at end of file
+var _0x5522=['type','key','model','query','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','include','findAll','show','params','keys','rawAttributes','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','Reports','UserProfileSection','find','userProfileId','autoAssociation','CustomReports','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','preview','join','right_join','cross_join','COUNT(DISTINCT\x20%s)','MAX(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','DATE(%s)','HOUR(%s)','ROUND(%s)','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','rules','group','condition','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','table','MetricId','metric','field','function','replace','format','groupBy','orderBy','DESC','joins','parse','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','Limited\x20Query:','sequelize','toString','QueryTypes','SELECT','SUM(%s)','COUNT(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','SEC_TO_TIME(%s)','UNIX_TIMESTAMP(%s)','IS\x20NOT\x20EMPTY','operator','value','alias','includes','clone','output','web','fullPath','%s-%s.%s','randomstring','generate','csv','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','endDate','startDate','child_process','fork','countTable','COUNT(*)','run','runReport','left_join','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','dbH','sendStatus','end','status','json','limit','offset','count','Content-Range','reject','save','then','destroy','get','UserProfileResource','error','stack','name','send','index','map','AnalyticCustomReport','fieldName'];(function(_0x5326ba,_0x156aca){var _0x6afc=function(_0x42c82d){while(--_0x42c82d){_0x5326ba['push'](_0x5326ba['shift']());}};_0x6afc(++_0x156aca);}(_0x5522,0x1bd));var _0x2552=function(_0x432682,_0x253044){_0x432682=_0x432682-0x0;var _0x463d05=_0x5522[_0x432682];return _0x463d05;};'use strict';var emlformat=require(_0x2552('0x0'));var rimraf=require(_0x2552('0x1'));var zipdir=require(_0x2552('0x2'));var jsonpatch=require(_0x2552('0x3'));var rp=require(_0x2552('0x4'));var moment=require('moment');var BPromise=require(_0x2552('0x5'));var Mustache=require(_0x2552('0x6'));var util=require(_0x2552('0x7'));var path=require('path');var sox=require(_0x2552('0x8'));var csv=require(_0x2552('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x2552('0xa'));var _=require(_0x2552('0xb'));var squel=require(_0x2552('0xc'));var crypto=require(_0x2552('0xd'));var jsforce=require(_0x2552('0xe'));var deskjs=require(_0x2552('0xf'));var toCsv=require(_0x2552('0x9'));var querystring=require(_0x2552('0x10'));var Papa=require(_0x2552('0x11'));var Redis=require(_0x2552('0x12'));var authService=require(_0x2552('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0x2552('0x14'));var hardwareService=require(_0x2552('0x15'));var logger=require(_0x2552('0x16'))(_0x2552('0x17'));var utils=require(_0x2552('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x2552('0x19'));var db=require(_0x2552('0x1a'))['db'];var dbH=require(_0x2552('0x1a'))[_0x2552('0x1b')];function respondWithStatusCode(_0x5fb831,_0x220fdb){_0x220fdb=_0x220fdb||0xcc;return function(_0x3ed7ed){if(_0x3ed7ed){return _0x5fb831[_0x2552('0x1c')](_0x220fdb);}return _0x5fb831['status'](_0x220fdb)[_0x2552('0x1d')]();};}function respondWithResult(_0x260d4a,_0x28db8b){_0x28db8b=_0x28db8b||0xc8;return function(_0x1cbbe7){if(_0x1cbbe7){return _0x260d4a[_0x2552('0x1e')](_0x28db8b)[_0x2552('0x1f')](_0x1cbbe7);}};}function respondWithFilteredResult(_0x2672cc,_0x27fff0){return function(_0x381b91){if(_0x381b91){var _0x217569=typeof _0x27fff0['offset']==='undefined'&&typeof _0x27fff0[_0x2552('0x20')]==='undefined';var _0x45de77=_0x381b91['count'];var _0x5beec8=_0x217569?0x0:_0x27fff0[_0x2552('0x21')];var _0x405986=_0x217569?_0x381b91[_0x2552('0x22')]:_0x27fff0[_0x2552('0x21')]+_0x27fff0[_0x2552('0x20')];var _0x1c1af4;if(_0x405986>=_0x45de77){_0x405986=_0x45de77;_0x1c1af4=0xc8;}else{_0x1c1af4=0xce;}_0x2672cc[_0x2552('0x1e')](_0x1c1af4);return _0x2672cc['set'](_0x2552('0x23'),_0x5beec8+'-'+_0x405986+'/'+_0x45de77)['json'](_0x381b91);}return null;};}function patchUpdates(_0x3489b1){return function(_0x38576d){try{jsonpatch['apply'](_0x38576d,_0x3489b1,!![]);}catch(_0x992b1d){return BPromise[_0x2552('0x24')](_0x992b1d);}return _0x38576d[_0x2552('0x25')]();};}function saveUpdates(_0x4e8a8b,_0x421280){return function(_0x11bd17){if(_0x11bd17){return _0x11bd17['update'](_0x4e8a8b)[_0x2552('0x26')](function(_0x3ea83d){return _0x3ea83d;});}return null;};}function removeEntity(_0x361c0e,_0x5bd7d8){return function(_0x408874){if(_0x408874){return _0x408874[_0x2552('0x27')]()[_0x2552('0x26')](function(){var _0x147c62=_0x408874[_0x2552('0x28')]({'plain':!![]});var _0x4ea485='CustomReports';return db[_0x2552('0x29')][_0x2552('0x27')]({'where':{'type':_0x4ea485,'resourceId':_0x147c62['id']}})[_0x2552('0x26')](function(){return _0x408874;});})[_0x2552('0x26')](function(){_0x361c0e[_0x2552('0x1e')](0xcc)[_0x2552('0x1d')]();});}};}function handleEntityNotFound(_0x27ba54,_0x51a228){return function(_0xd92ab4){if(!_0xd92ab4){_0x27ba54[_0x2552('0x1c')](0x194);}return _0xd92ab4;};}function handleError(_0x5597c2,_0x24a7f3){_0x24a7f3=_0x24a7f3||0x1f4;return function(_0x261b6c){logger[_0x2552('0x2a')](_0x261b6c[_0x2552('0x2b')]);if(_0x261b6c[_0x2552('0x2c')]){delete _0x261b6c[_0x2552('0x2c')];}_0x5597c2[_0x2552('0x1e')](_0x24a7f3)[_0x2552('0x2d')](_0x261b6c);};}exports[_0x2552('0x2e')]=function(_0x1dae94,_0x19772c){var _0xb640f5={},_0x2f7d2c={},_0x4ee39d={'count':0x0,'rows':[]};var _0x575dcd=_[_0x2552('0x2f')](db[_0x2552('0x30')]['rawAttributes'],function(_0x3e5829){return{'name':_0x3e5829[_0x2552('0x31')],'type':_0x3e5829[_0x2552('0x32')][_0x2552('0x33')]};});_0x2f7d2c[_0x2552('0x34')]=_[_0x2552('0x2f')](_0x575dcd,_0x2552('0x2c'));_0x2f7d2c[_0x2552('0x35')]=_['keys'](_0x1dae94['query']);_0x2f7d2c['filters']=_['intersection'](_0x2f7d2c[_0x2552('0x34')],_0x2f7d2c['query']);_0xb640f5[_0x2552('0x36')]=_[_0x2552('0x37')](_0x2f7d2c['model'],qs[_0x2552('0x38')](_0x1dae94[_0x2552('0x35')][_0x2552('0x38')]));_0xb640f5['attributes']=_0xb640f5[_0x2552('0x36')][_0x2552('0x39')]?_0xb640f5[_0x2552('0x36')]:_0x2f7d2c['model'];if(!_0x1dae94[_0x2552('0x35')][_0x2552('0x3a')](_0x2552('0x3b'))){_0xb640f5[_0x2552('0x20')]=qs[_0x2552('0x20')](_0x1dae94[_0x2552('0x35')]['limit']);_0xb640f5['offset']=qs[_0x2552('0x21')](_0x1dae94['query'][_0x2552('0x21')]);}_0xb640f5[_0x2552('0x3c')]=qs[_0x2552('0x3d')](_0x1dae94['query'][_0x2552('0x3d')]);_0xb640f5[_0x2552('0x3e')]=qs[_0x2552('0x3f')](_[_0x2552('0x40')](_0x1dae94[_0x2552('0x35')],_0x2f7d2c[_0x2552('0x3f')]),_0x575dcd);if(_0x1dae94[_0x2552('0x35')][_0x2552('0x41')]){_0xb640f5['where']=_[_0x2552('0x42')](_0xb640f5[_0x2552('0x3e')],{'$or':_[_0x2552('0x2f')](_0x575dcd,function(_0x4fb187){if(_0x4fb187[_0x2552('0x32')]!==_0x2552('0x43')){var _0x2dfd3e={};_0x2dfd3e[_0x4fb187[_0x2552('0x2c')]]={'$like':'%'+_0x1dae94[_0x2552('0x35')][_0x2552('0x41')]+'%'};return _0x2dfd3e;}})});}_0xb640f5=_['merge']({},_0xb640f5,_0x1dae94[_0x2552('0x44')]);var _0x348b8b={'where':_0xb640f5['where']};return db[_0x2552('0x30')]['count'](_0x348b8b)['then'](function(_0x15adac){_0x4ee39d[_0x2552('0x22')]=_0x15adac;if(_0x1dae94[_0x2552('0x35')]['includeAll']){_0xb640f5[_0x2552('0x45')]=[{'all':!![]}];}return db[_0x2552('0x30')][_0x2552('0x46')](_0xb640f5);})[_0x2552('0x26')](function(_0x576124){_0x4ee39d['rows']=_0x576124;return _0x4ee39d;})[_0x2552('0x26')](respondWithFilteredResult(_0x19772c,_0xb640f5))['catch'](handleError(_0x19772c,null));};exports[_0x2552('0x47')]=function(_0x4744e9,_0x43dd04){var _0x46ab1a={'raw':![],'where':{'id':_0x4744e9[_0x2552('0x48')]['id']}},_0xb89c6={};_0xb89c6[_0x2552('0x34')]=_[_0x2552('0x49')](db['AnalyticCustomReport'][_0x2552('0x4a')]);_0xb89c6[_0x2552('0x35')]=_['keys'](_0x4744e9['query']);_0xb89c6[_0x2552('0x3f')]=_[_0x2552('0x37')](_0xb89c6[_0x2552('0x34')],_0xb89c6[_0x2552('0x35')]);_0x46ab1a[_0x2552('0x36')]=_[_0x2552('0x37')](_0xb89c6['model'],qs['fields'](_0x4744e9['query'][_0x2552('0x38')]));_0x46ab1a[_0x2552('0x36')]=_0x46ab1a[_0x2552('0x36')]['length']?_0x46ab1a[_0x2552('0x36')]:_0xb89c6[_0x2552('0x34')];if(_0x4744e9[_0x2552('0x35')]['includeAll']){_0x46ab1a[_0x2552('0x45')]=[{'all':!![]}];}_0x46ab1a=_['merge']({},_0x46ab1a,_0x4744e9[_0x2552('0x44')]);return db['AnalyticCustomReport']['find'](_0x46ab1a)[_0x2552('0x26')](handleEntityNotFound(_0x43dd04,null))['then'](respondWithResult(_0x43dd04,null))[_0x2552('0x4b')](handleError(_0x43dd04,null));};exports[_0x2552('0x4c')]=function(_0x4379df,_0x92e16d){return db['AnalyticCustomReport'][_0x2552('0x4c')](_0x4379df[_0x2552('0x4d')],{})[_0x2552('0x26')](function(_0x5f33f3){var _0x14c63d=_0x4379df[_0x2552('0x4e')][_0x2552('0x28')]({'plain':!![]});if(!_0x14c63d)throw new Error(_0x2552('0x4f'));if(_0x14c63d['role']===_0x2552('0x4e')){var _0x313ea5=_0x5f33f3[_0x2552('0x28')]({'plain':!![]});var _0x137bf1=_0x2552('0x50');return db[_0x2552('0x51')][_0x2552('0x52')]({'where':{'name':_0x137bf1,'userProfileId':_0x14c63d[_0x2552('0x53')]},'raw':!![]})[_0x2552('0x26')](function(_0x49a446){if(_0x49a446&&_0x49a446[_0x2552('0x54')]===0x0){return db[_0x2552('0x29')][_0x2552('0x4c')]({'name':_0x313ea5[_0x2552('0x2c')],'resourceId':_0x313ea5['id'],'type':_0x2552('0x55'),'sectionId':_0x49a446['id']},{})[_0x2552('0x26')](function(){return _0x5f33f3;});}else{return _0x5f33f3;}})[_0x2552('0x4b')](function(_0x4fe312){logger['error'](_0x2552('0x56'),_0x4fe312);throw _0x4fe312;});}return _0x5f33f3;})[_0x2552('0x26')](respondWithResult(_0x92e16d,0xc9))['catch'](handleError(_0x92e16d,null));};exports['update']=function(_0xa06e88,_0x4fc7a0){if(_0xa06e88[_0x2552('0x4d')]['id']){delete _0xa06e88['body']['id'];}return db['AnalyticCustomReport'][_0x2552('0x52')]({'where':{'id':_0xa06e88[_0x2552('0x48')]['id']}})['then'](handleEntityNotFound(_0x4fc7a0,null))[_0x2552('0x26')](saveUpdates(_0xa06e88[_0x2552('0x4d')],null))[_0x2552('0x26')](respondWithResult(_0x4fc7a0,null))['catch'](handleError(_0x4fc7a0,null));};exports[_0x2552('0x27')]=function(_0x5f41a1,_0x503914){return db[_0x2552('0x30')][_0x2552('0x52')]({'where':{'id':_0x5f41a1[_0x2552('0x48')]['id']}})[_0x2552('0x26')](handleEntityNotFound(_0x503914,null))[_0x2552('0x26')](removeEntity(_0x503914,null))['catch'](handleError(_0x503914,null));};exports[_0x2552('0x57')]=function(_0x570faf,_0x4dff3e){var _0x3e9750=0xa;var _0x478b24=[_0x2552('0x58'),'left_join',_0x2552('0x59'),_0x2552('0x5a')];var _0x51be9f={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':_0x2552('0x5b'),'MAX':_0x2552('0x5c'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0x2552('0x5d'),'GROUP_CONCAT DESC':_0x2552('0x5e')};var _0x41b55c={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x2552('0x5f'),'HOUR':_0x2552('0x60'),'ROUND':_0x2552('0x61'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x1cf315=function(_0x53024){return!_['includes']([_0x2552('0x62'),_0x2552('0x63'),_0x2552('0x64'),'IS\x20NOT\x20EMPTY'],_0x53024);};var _0x5bb69e=function(_0x3b55b2){if(!_0x3b55b2||!_0x3b55b2[_0x2552('0x65')]['length']){return'';}for(var _0x5753f2='(',_0x28171a=0x0;_0x28171a<_0x3b55b2[_0x2552('0x65')][_0x2552('0x39')];_0x28171a+=0x1){_0x28171a>0x0&&(_0x5753f2+='\x20'+_0x3b55b2['operator']+'\x20');_0x5753f2+=_0x3b55b2['rules'][_0x28171a][_0x2552('0x66')]?_0x5bb69e(_0x3b55b2['rules'][_0x28171a][_0x2552('0x66')]):_0x3b55b2['rules'][_0x28171a]['field']+'\x20'+_0x3b55b2[_0x2552('0x65')][_0x28171a][_0x2552('0x67')]+(_0x1cf315(_0x3b55b2[_0x2552('0x65')][_0x28171a][_0x2552('0x67')])?'\x20'+_0x3b55b2[_0x2552('0x65')][_0x28171a]['value']:'');}return _0x5753f2+')';};var _0x9ba1a0={'where':{'id':_0x570faf[_0x2552('0x48')]['id']}},_0x3b4beb,_0x21faa3,_0x96069e,_0x5afd04,_0x343518;_0x9ba1a0=_['merge']({},_0x9ba1a0,_0x570faf[_0x2552('0x44')]);return db[_0x2552('0x30')]['find'](_0x9ba1a0)[_0x2552('0x26')](function(_0x8b4865){if(_0x8b4865){_0x3b4beb=_0x8b4865;return _0x8b4865[_0x2552('0x68')]();}return null;})[_0x2552('0x26')](function(_0x1c689b){if(_0x1c689b){if(!_0x1c689b[_0x2552('0x39')]){throw new db[(_0x2552('0x69'))][(_0x2552('0x6a'))](_0x2552('0x6b'),0x193);}_0x21faa3=_0x1c689b;return db[_0x2552('0x6c')][_0x2552('0x46')]({'raw':!![]});}return null;})['then'](function(_0x3aa7d6){if(_0x3aa7d6){_0x96069e=_[_0x2552('0x6d')](_0x3aa7d6,'id');var _0x5f2227;var _0x48e2d8=squel[_0x2552('0x6e')]();_0x48e2d8[_0x2552('0x6f')](_0x3b4beb[_0x2552('0x70')]);for(var _0x25e99f=0x0;_0x25e99f<_0x21faa3[_0x2552('0x39')];_0x25e99f+=0x1){_0x5f2227=_0x21faa3[_0x25e99f][_0x2552('0x71')]?_0x96069e[_0x21faa3[_0x25e99f]['MetricId']][_0x2552('0x72')]:_0x21faa3[_0x25e99f][_0x2552('0x73')];_0x5f2227=_0x21faa3[_0x25e99f][_0x2552('0x74')]?_[_0x2552('0x75')](_0x51be9f[_0x21faa3[_0x25e99f][_0x2552('0x74')]],'%s',_0x5f2227):_0x5f2227;_0x5f2227=_0x21faa3[_0x25e99f][_0x2552('0x76')]?_[_0x2552('0x75')](_0x41b55c[_0x21faa3[_0x25e99f][_0x2552('0x76')]],'%s',_0x5f2227):_0x5f2227;if(_0x21faa3[_0x25e99f][_0x2552('0x77')]){_0x48e2d8['group'](_0x5f2227);}_0x21faa3[_0x25e99f][_0x2552('0x78')]&&_0x48e2d8['order'](_0x5f2227,_0x21faa3[_0x25e99f][_0x2552('0x78')]===_0x2552('0x79')?![]:!![]);_0x48e2d8['field'](_0x5f2227,_0x21faa3[_0x25e99f]['alias']||_0x5f2227);}if(_0x3b4beb[_0x2552('0x7a')]){_0x3b4beb['joins']=JSON[_0x2552('0x7b')](_0x3b4beb[_0x2552('0x7a')]);for(var _0x1c9685=0x0;_0x1c9685<_0x3b4beb[_0x2552('0x7a')][_0x2552('0x39')];_0x1c9685+=0x1){if(_0x3b4beb[_0x2552('0x7a')][_0x1c9685][_0x2552('0x32')]&&_['includes'](_0x478b24,_0x3b4beb['joins'][_0x1c9685][_0x2552('0x32')])&&_0x3b4beb[_0x2552('0x7a')][_0x1c9685][_0x2552('0x7c')]&&_0x3b4beb[_0x2552('0x7a')][_0x1c9685][_0x2552('0x7d')]&&_0x3b4beb[_0x2552('0x7a')][_0x1c9685][_0x2552('0x7e')]){_0x48e2d8[_0x3b4beb[_0x2552('0x7a')][_0x1c9685]['type']](_0x3b4beb['joins'][_0x1c9685][_0x2552('0x7d')],null,util[_0x2552('0x76')](_0x2552('0x7f'),_0x3b4beb[_0x2552('0x70')],_0x3b4beb[_0x2552('0x7a')][_0x1c9685]['parentKey'],_0x3b4beb['joins'][_0x1c9685][_0x2552('0x7d')],_0x3b4beb[_0x2552('0x7a')][_0x1c9685][_0x2552('0x7e')]));}}}if(_0x3b4beb[_0x2552('0x80')]){_0x3b4beb[_0x2552('0x80')]=JSON[_0x2552('0x7b')](_0x3b4beb[_0x2552('0x80')]);_0x48e2d8['where'](_0x5bb69e(_0x3b4beb[_0x2552('0x80')][_0x2552('0x66')]));}_0x343518=_0x48e2d8['clone']();_0x48e2d8['limit'](_0x3e9750);_0x48e2d8['offset'](0x0);logger['debug'](_0x2552('0x81'),_0x48e2d8['toString']());return dbH[_0x2552('0x82')]['query'](_0x48e2d8[_0x2552('0x83')](),{'type':dbH['sequelize'][_0x2552('0x84')][_0x2552('0x85')]});}})[_0x2552('0x26')](respondWithResult(_0x4dff3e,null))[_0x2552('0x4b')](handleError(_0x4dff3e,null));};function runReport(_0x2ddb58,_0x3a427d,_0x2c7945){var _0x2f0157=_0x3a427d[_0x2552('0x2c')];var _0x11dcb9=0xa;var _0x4a173c=[_0x2552('0x58'),'left_join',_0x2552('0x59'),'cross_join'];var _0x3dfa44={'SUM':_0x2552('0x86'),'COUNT':_0x2552('0x87'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x2552('0x5c'),'MIN':_0x2552('0x88'),'AVG':_0x2552('0x89'),'GROUP_CONCAT':_0x2552('0x8a'),'GROUP_CONCAT ASC':_0x2552('0x5d'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x21224e={'SEC_TO_TIME':_0x2552('0x8b'),'DATE':_0x2552('0x5f'),'HOUR':_0x2552('0x60'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x2552('0x8c')};var _0x5a9882=function(_0x447b40){return!_['includes']([_0x2552('0x62'),_0x2552('0x63'),_0x2552('0x64'),_0x2552('0x8d')],_0x447b40);};var _0x21a12f=function(_0x22b455){if(!_0x22b455||!_0x22b455[_0x2552('0x65')]['length']){return'';}for(var _0x54b8b9='(',_0x26b594=0x0;_0x26b594<_0x22b455[_0x2552('0x65')][_0x2552('0x39')];_0x26b594+=0x1){_0x26b594>0x0&&(_0x54b8b9+='\x20'+_0x22b455[_0x2552('0x8e')]+'\x20');_0x54b8b9+=_0x22b455[_0x2552('0x65')][_0x26b594]['group']?_0x21a12f(_0x22b455[_0x2552('0x65')][_0x26b594][_0x2552('0x66')]):_0x22b455[_0x2552('0x65')][_0x26b594][_0x2552('0x73')]+'\x20'+_0x22b455['rules'][_0x26b594][_0x2552('0x67')]+(_0x5a9882(_0x22b455['rules'][_0x26b594][_0x2552('0x67')])?'\x20'+_0x22b455[_0x2552('0x65')][_0x26b594][_0x2552('0x8f')]:'');}return _0x54b8b9+')';};var _0x4a9c6f={'where':{'id':_0x2ddb58['id']}},_0xf0ed9c,_0x4b7764,_0x3725a0,_0x1deec9,_0x5d6521;_0x4a9c6f=_[_0x2552('0x42')]({},_0x4a9c6f,_0x2c7945);return db[_0x2552('0x30')]['find'](_0x4a9c6f)['then'](function(_0x5304aa){if(_0x5304aa){_0xf0ed9c=_0x5304aa;return _0x5304aa[_0x2552('0x68')]();}return null;})[_0x2552('0x26')](function(_0x406795){if(_0x406795){if(!_0x406795['length']){throw new db[(_0x2552('0x69'))][(_0x2552('0x6a'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x4b7764=_0x406795;return db[_0x2552('0x6c')][_0x2552('0x46')]({'raw':!![]});}return null;})[_0x2552('0x26')](function(_0x302e95){if(_0x302e95){_0x3725a0=_[_0x2552('0x6d')](_0x302e95,'id');var _0x2b211c;var _0x296784=squel['select']();_0x296784[_0x2552('0x6f')](_0xf0ed9c[_0x2552('0x70')]);for(var _0x2ff89c=0x0;_0x2ff89c<_0x4b7764[_0x2552('0x39')];_0x2ff89c+=0x1){_0x2b211c=_0x4b7764[_0x2ff89c][_0x2552('0x71')]?_0x3725a0[_0x4b7764[_0x2ff89c][_0x2552('0x71')]][_0x2552('0x72')]:_0x4b7764[_0x2ff89c][_0x2552('0x73')];_0x2b211c=_0x4b7764[_0x2ff89c]['function']?_[_0x2552('0x75')](_0x3dfa44[_0x4b7764[_0x2ff89c][_0x2552('0x74')]],'%s',_0x2b211c):_0x2b211c;_0x2b211c=_0x4b7764[_0x2ff89c][_0x2552('0x76')]?_[_0x2552('0x75')](_0x21224e[_0x4b7764[_0x2ff89c][_0x2552('0x76')]],'%s',_0x2b211c):_0x2b211c;if(_0x4b7764[_0x2ff89c][_0x2552('0x77')]){_0x296784[_0x2552('0x66')](_0x2b211c);}_0x4b7764[_0x2ff89c][_0x2552('0x78')]&&_0x296784[_0x2552('0x3c')](_0x2b211c,_0x4b7764[_0x2ff89c][_0x2552('0x78')]==='DESC'?![]:!![]);_0x296784[_0x2552('0x73')](_0x2b211c,_0x4b7764[_0x2ff89c][_0x2552('0x90')]||_0x2b211c);}if(_0xf0ed9c['joins']){_0xf0ed9c[_0x2552('0x7a')]=JSON[_0x2552('0x7b')](_0xf0ed9c[_0x2552('0x7a')]);for(var _0x11ff79=0x0;_0x11ff79<_0xf0ed9c['joins'][_0x2552('0x39')];_0x11ff79+=0x1){if(_0xf0ed9c[_0x2552('0x7a')][_0x11ff79][_0x2552('0x32')]&&_[_0x2552('0x91')](_0x4a173c,_0xf0ed9c['joins'][_0x11ff79]['type'])&&_0xf0ed9c['joins'][_0x11ff79][_0x2552('0x7c')]&&_0xf0ed9c[_0x2552('0x7a')][_0x11ff79][_0x2552('0x7d')]&&_0xf0ed9c[_0x2552('0x7a')][_0x11ff79][_0x2552('0x7e')]){_0x296784[_0xf0ed9c['joins'][_0x11ff79][_0x2552('0x32')]](_0xf0ed9c[_0x2552('0x7a')][_0x11ff79][_0x2552('0x7d')],null,util[_0x2552('0x76')]('%s.%s\x20=\x20%s.%s',_0xf0ed9c[_0x2552('0x70')],_0xf0ed9c['joins'][_0x11ff79][_0x2552('0x7c')],_0xf0ed9c['joins'][_0x11ff79][_0x2552('0x7d')],_0xf0ed9c[_0x2552('0x7a')][_0x11ff79][_0x2552('0x7e')]));}}}if(_0xf0ed9c[_0x2552('0x80')]){_0xf0ed9c['conditions']=JSON[_0x2552('0x7b')](_0xf0ed9c[_0x2552('0x80')]);_0x296784[_0x2552('0x3e')](_0x21a12f(_0xf0ed9c[_0x2552('0x80')]['group']));}_0x5d6521=_0x296784[_0x2552('0x92')]();_0x296784['limit'](_0x11dcb9);_0x296784[_0x2552('0x21')](0x0);return;}})[_0x2552('0x26')](function(){if(_0x3a427d[_0x2552('0x93')]===_0x2552('0x94')){return null;}var _0x9b441c=_[_0x2552('0x42')](_0x3a427d,{'name':_0x3a427d[_0x2552('0x95')]||_0x3a427d[_0x2552('0x2c')]||_0xf0ed9c['name'],'basename':_0x2f0157,'savename':util[_0x2552('0x76')](_0x2552('0x96'),_0x3a427d[_0x2552('0x2c')]||_0xf0ed9c['name'],require(_0x2552('0x97'))[_0x2552('0x98')](0x4),_0x3a427d[_0x2552('0x93')]||_0x2552('0x99')),'reportId':_0xf0ed9c['id'],'reportType':'custom'});return db['AnalyticExtractedReport'][_0x2552('0x4c')](_0x9b441c,{'raw':!![]});})[_0x2552('0x26')](function(_0x91782c){if(_0xf0ed9c[_0x2552('0x70')]===_0x2552('0x9a')){_0x5d6521[_0x2552('0x3e')](_0xf0ed9c[_0x2552('0x70')]+_0x2552('0x9b'),_0x3a427d['startDate'],_0x3a427d[_0x2552('0x9c')]);}else{_0x5d6521['where'](_0xf0ed9c[_0x2552('0x70')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x3a427d[_0x2552('0x9d')],_0x3a427d['endDate']);}if(_0x91782c){logger['info']('Run\x20Query:',_0x5d6521['toString']());require(_0x2552('0x9e'))[_0x2552('0x9f')](path[_0x2552('0x58')](__dirname,'../../components/export/',_0x91782c[_0x2552('0x93')]),[_0x91782c['id'],_0x5d6521['toString'](),path[_0x2552('0x58')](__dirname,'../../files/reports',_0x91782c['savename']),_0x2f0157]);return _0x91782c;}else{var _0x1fdf6a=squel[_0x2552('0x6e')]();_0x1fdf6a['from']('('+_0x5d6521[_0x2552('0x83')]()+')',_0x2552('0xa0'));_0x1fdf6a[_0x2552('0x73')](_0x2552('0xa1'),'count');_0x5d6521[_0x2552('0x20')](_0x3a427d[_0x2552('0x20')]||_0x11dcb9);_0x5d6521[_0x2552('0x21')](_0x3a427d[_0x2552('0x21')]||0x0);return dbH[_0x2552('0x82')][_0x2552('0x35')](_0x1fdf6a[_0x2552('0x83')](),{'type':dbH['sequelize'][_0x2552('0x84')][_0x2552('0x85')]})[_0x2552('0x26')](function(_0x469385){if(!_0x469385['length']){_0x1deec9=0x0;}else{_0x1deec9=_0x469385[0x0][_0x2552('0x22')]||0x0;}return dbH[_0x2552('0x82')][_0x2552('0x35')](_0x5d6521[_0x2552('0x83')](),{'type':dbH[_0x2552('0x82')][_0x2552('0x84')][_0x2552('0x85')]});})[_0x2552('0x26')](function(_0x2e6953){return{'rows':_0x2e6953||[],'count':_0x1deec9};});}});}exports[_0x2552('0xa2')]=function(_0x4cbfbb,_0x4eed14){return runReport(_0x4cbfbb[_0x2552('0x48')],_0x4cbfbb[_0x2552('0x35')],_0x4cbfbb[_0x2552('0x44')])[_0x2552('0x26')](respondWithResult(_0x4eed14,null))[_0x2552('0x4b')](handleError(_0x4eed14,null));};exports[_0x2552('0xa3')]=runReport;exports[_0x2552('0x35')]=function(_0x228083,_0x5dddb4){var _0x31514a=0xa;var _0x1c4fba=['join',_0x2552('0xa4'),_0x2552('0x59'),_0x2552('0x5a')];var _0x23a5b={'SUM':_0x2552('0x86'),'COUNT':_0x2552('0x87'),'COUNT DISTINCT':_0x2552('0x5b'),'MAX':_0x2552('0x5c'),'MIN':_0x2552('0x88'),'AVG':_0x2552('0x89'),'GROUP_CONCAT':_0x2552('0x8a'),'GROUP_CONCAT ASC':_0x2552('0x5d'),'GROUP_CONCAT DESC':_0x2552('0x5e')};var _0x2dfe5f={'SEC_TO_TIME':_0x2552('0x8b'),'DATE':'DATE(%s)','HOUR':_0x2552('0x60'),'ROUND':_0x2552('0x61'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x42e615=function(_0x251c37){return!_[_0x2552('0x91')]([_0x2552('0x62'),_0x2552('0x63'),'IS\x20EMPTY','IS\x20NOT\x20EMPTY'],_0x251c37);};var _0x249a48=function(_0x3d9c22){if(!_0x3d9c22||!_0x3d9c22[_0x2552('0x65')][_0x2552('0x39')]){return'';}for(var _0x4ba2e1='(',_0x31b798=0x0;_0x31b798<_0x3d9c22[_0x2552('0x65')][_0x2552('0x39')];_0x31b798+=0x1){_0x31b798>0x0&&(_0x4ba2e1+='\x20'+_0x3d9c22[_0x2552('0x8e')]+'\x20');_0x4ba2e1+=_0x3d9c22[_0x2552('0x65')][_0x31b798]['group']?_0x249a48(_0x3d9c22[_0x2552('0x65')][_0x31b798][_0x2552('0x66')]):_0x3d9c22[_0x2552('0x65')][_0x31b798][_0x2552('0x73')]+'\x20'+_0x3d9c22[_0x2552('0x65')][_0x31b798]['condition']+(_0x42e615(_0x3d9c22[_0x2552('0x65')][_0x31b798][_0x2552('0x67')])?'\x20'+_0x3d9c22[_0x2552('0x65')][_0x31b798][_0x2552('0x8f')]:'');}return _0x4ba2e1+')';};var _0x1b6e0c={'where':{'id':_0x228083['params']['id']}},_0x5bb3e8,_0x45c9ac,_0x143416,_0x45b36a,_0x4ab55;_0x1b6e0c=_[_0x2552('0x42')]({},_0x1b6e0c,_0x228083[_0x2552('0x44')]);return db[_0x2552('0x30')][_0x2552('0x52')](_0x1b6e0c)[_0x2552('0x26')](function(_0x3cc40a){if(_0x3cc40a){_0x5bb3e8=_0x3cc40a;return _0x3cc40a['getFields']();}return null;})[_0x2552('0x26')](function(_0x173f2a){if(_0x173f2a){if(!_0x173f2a['length']){throw new db[(_0x2552('0x69'))][(_0x2552('0x6a'))](_0x2552('0x6b'),0x193);}_0x45c9ac=_0x173f2a;return db[_0x2552('0x6c')][_0x2552('0x46')]({'raw':!![]});}return null;})['then'](function(_0x365a4a){if(_0x365a4a){_0x143416=_[_0x2552('0x6d')](_0x365a4a,'id');var _0x135108;var _0x3622ba=squel[_0x2552('0x6e')]();_0x3622ba[_0x2552('0x6f')](_0x5bb3e8[_0x2552('0x70')]);for(var _0x96105d=0x0;_0x96105d<_0x45c9ac[_0x2552('0x39')];_0x96105d+=0x1){_0x135108=_0x45c9ac[_0x96105d][_0x2552('0x71')]?_0x143416[_0x45c9ac[_0x96105d][_0x2552('0x71')]]['metric']:_0x45c9ac[_0x96105d]['field'];_0x135108=_0x45c9ac[_0x96105d][_0x2552('0x74')]?_['replace'](_0x23a5b[_0x45c9ac[_0x96105d][_0x2552('0x74')]],'%s',_0x135108):_0x135108;_0x135108=_0x45c9ac[_0x96105d][_0x2552('0x76')]?_['replace'](_0x2dfe5f[_0x45c9ac[_0x96105d][_0x2552('0x76')]],'%s',_0x135108):_0x135108;if(_0x45c9ac[_0x96105d][_0x2552('0x77')]){_0x3622ba[_0x2552('0x66')](_0x135108);}_0x45c9ac[_0x96105d]['orderBy']&&_0x3622ba[_0x2552('0x3c')](_0x135108,_0x45c9ac[_0x96105d][_0x2552('0x78')]===_0x2552('0x79')?![]:!![]);_0x3622ba['field'](_0x135108,_0x45c9ac[_0x96105d][_0x2552('0x90')]||_0x135108);}if(_0x5bb3e8['joins']){_0x5bb3e8[_0x2552('0x7a')]=JSON[_0x2552('0x7b')](_0x5bb3e8[_0x2552('0x7a')]);for(var _0x5aafed=0x0;_0x5aafed<_0x5bb3e8[_0x2552('0x7a')][_0x2552('0x39')];_0x5aafed+=0x1){if(_0x5bb3e8['joins'][_0x5aafed][_0x2552('0x32')]&&_[_0x2552('0x91')](_0x1c4fba,_0x5bb3e8[_0x2552('0x7a')][_0x5aafed][_0x2552('0x32')])&&_0x5bb3e8[_0x2552('0x7a')][_0x5aafed]['parentKey']&&_0x5bb3e8['joins'][_0x5aafed][_0x2552('0x7d')]&&_0x5bb3e8[_0x2552('0x7a')][_0x5aafed]['foreignKey']){_0x3622ba[_0x5bb3e8[_0x2552('0x7a')][_0x5aafed]['type']](_0x5bb3e8[_0x2552('0x7a')][_0x5aafed]['foreignTable'],null,util[_0x2552('0x76')](_0x2552('0x7f'),_0x5bb3e8['table'],_0x5bb3e8[_0x2552('0x7a')][_0x5aafed][_0x2552('0x7c')],_0x5bb3e8[_0x2552('0x7a')][_0x5aafed][_0x2552('0x7d')],_0x5bb3e8[_0x2552('0x7a')][_0x5aafed][_0x2552('0x7e')]));}}}if(_0x5bb3e8[_0x2552('0x80')]){_0x5bb3e8[_0x2552('0x80')]=JSON['parse'](_0x5bb3e8['conditions']);_0x3622ba[_0x2552('0x3e')](_0x249a48(_0x5bb3e8['conditions'][_0x2552('0x66')]));}_0x4ab55=_0x3622ba[_0x2552('0x92')]();_0x3622ba[_0x2552('0x20')](_0x31514a);_0x3622ba[_0x2552('0x21')](0x0);logger['debug'](_0x2552('0x81'),_0x3622ba['toString']());return dbH['sequelize'][_0x2552('0x35')](_0x3622ba[_0x2552('0x83')](),{'type':dbH[_0x2552('0x82')]['QueryTypes'][_0x2552('0x85')]});}})[_0x2552('0x26')](function(){return{'sql':_0x4ab55['toString']()};})[_0x2552('0x26')](respondWithResult(_0x5dddb4,null))[_0x2552('0x4b')](handleError(_0x5dddb4,null));};
\ No newline at end of file