Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 13893ab..80ec0d5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb386=['attributes','intersection','length','hasOwnProperty','nolimit','order','sort','where','filters','merge','VIRTUAL','filter','includeAll','include','findAll','rows','catch','show','fields','options','find','create','body','user','role','Reports','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','preview','join','right_join','cross_join','SUM(%s)','MAX(%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\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','value','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','MetricId','metric','function','replace','format','groupBy','orderBy','DESC','alias','joins','parse','parentKey','foreignTable','%s.%s\x20=\x20%s.%s','conditions','debug','toString','sequelize','QueryTypes','SELECT','left_join','COUNT(%s)','COUNT(DISTINCT\x20%s)','MIN(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','ROUND(%s)','IS\x20NULL','table','foreignKey','clone','output','%s-%s.%s','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','runReport','Limited\x20Query:','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','dbH','sendStatus','status','json','count','offset','limit','set','Content-Range','reject','update','then','destroy','get','DefaultReports','UserProfileResource','end','stack','name','send','map','AnalyticDefaultReport','rawAttributes','type','key','model','query','keys'];(function(_0x2130cc,_0x1abfd3){var _0x42a11a=function(_0x284933){while(--_0x284933){_0x2130cc['push'](_0x2130cc['shift']());}};_0x42a11a(++_0x1abfd3);}(_0xb386,0x111));var _0x6b38=function(_0x4b73a2,_0x40b5fe){_0x4b73a2=_0x4b73a2-0x0;var _0x383c66=_0xb386[_0x4b73a2];return _0x383c66;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x6b38('0x0'));var rimraf=require(_0x6b38('0x1'));var zipdir=require(_0x6b38('0x2'));var jsonpatch=require(_0x6b38('0x3'));var rp=require(_0x6b38('0x4'));var moment=require(_0x6b38('0x5'));var BPromise=require(_0x6b38('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0x6b38('0x7'));var sox=require(_0x6b38('0x8'));var csv=require(_0x6b38('0x9'));var ejs=require(_0x6b38('0xa'));var fs=require('fs');var _=require(_0x6b38('0xb'));var squel=require(_0x6b38('0xc'));var crypto=require('crypto');var jsforce=require(_0x6b38('0xd'));var deskjs=require(_0x6b38('0xe'));var toCsv=require(_0x6b38('0x9'));var querystring=require('querystring');var Papa=require(_0x6b38('0xf'));var Redis=require(_0x6b38('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x6b38('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6b38('0x12'));var logger=require(_0x6b38('0x13'))('api');var utils=require(_0x6b38('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x6b38('0x15'));var db=require('../../mysqldb')['db'];var dbH=require(_0x6b38('0x16'))[_0x6b38('0x17')];function respondWithStatusCode(_0x35bc2d,_0x521aba){_0x521aba=_0x521aba||0xcc;return function(_0x59161c){if(_0x59161c){return _0x35bc2d[_0x6b38('0x18')](_0x521aba);}return _0x35bc2d[_0x6b38('0x19')](_0x521aba)['end']();};}function respondWithResult(_0xa45d01,_0x15849d){_0x15849d=_0x15849d||0xc8;return function(_0x157b0e){if(_0x157b0e){return _0xa45d01['status'](_0x15849d)[_0x6b38('0x1a')](_0x157b0e);}};}function respondWithFilteredResult(_0x4948fe,_0x5c3a11){return function(_0x576676){if(_0x576676){var _0x59e092=_0x576676[_0x6b38('0x1b')],_0x472c57=_0x5c3a11[_0x6b38('0x1c')],_0x3db035=_0x5c3a11['offset']+_0x5c3a11[_0x6b38('0x1d')],_0x1e28af;if(_0x3db035>=_0x59e092){_0x3db035=_0x59e092;_0x1e28af=0xc8;}else{_0x1e28af=0xce;}_0x4948fe['status'](_0x1e28af);return _0x4948fe[_0x6b38('0x1e')](_0x6b38('0x1f'),_0x472c57+'-'+_0x3db035+'/'+_0x59e092)[_0x6b38('0x1a')](_0x576676);}return null;};}function patchUpdates(_0xd2009e){return function(_0x4c25b6){try{jsonpatch['apply'](_0x4c25b6,_0xd2009e,!![]);}catch(_0x275dec){return BPromise[_0x6b38('0x20')](_0x275dec);}return _0x4c25b6['save']();};}function saveUpdates(_0x529fc0,_0x15a287){return function(_0x1a8f58){if(_0x1a8f58){return _0x1a8f58[_0x6b38('0x21')](_0x529fc0)[_0x6b38('0x22')](function(_0x54eae7){return _0x54eae7;});}return null;};}function removeEntity(_0x124747,_0x38d29f){return function(_0x53a481){if(_0x53a481){return _0x53a481[_0x6b38('0x23')]()[_0x6b38('0x22')](function(){var _0x5d2b08=_0x53a481[_0x6b38('0x24')]({'plain':!![]});var _0x3a7e5d=_0x6b38('0x25');return db[_0x6b38('0x26')][_0x6b38('0x23')]({'where':{'type':_0x3a7e5d,'resourceId':_0x5d2b08['id']}})[_0x6b38('0x22')](function(){return _0x53a481;});})[_0x6b38('0x22')](function(){_0x124747[_0x6b38('0x19')](0xcc)[_0x6b38('0x27')]();});}};}function handleEntityNotFound(_0x46a82f,_0x527232){return function(_0x3dd353){if(!_0x3dd353){_0x46a82f['sendStatus'](0x194);}return _0x3dd353;};}function handleError(_0x2ba835,_0x3abc3b){_0x3abc3b=_0x3abc3b||0x1f4;return function(_0x227c46){logger['error'](_0x227c46[_0x6b38('0x28')]);if(_0x227c46[_0x6b38('0x29')]){delete _0x227c46[_0x6b38('0x29')];}_0x2ba835[_0x6b38('0x19')](_0x3abc3b)[_0x6b38('0x2a')](_0x227c46);};}exports['index']=function(_0x20fac0,_0x2e9737){var _0x5d9d37={},_0x3601da={},_0x373584={'count':0x0,'rows':[]};var _0x3c9996=_[_0x6b38('0x2b')](db[_0x6b38('0x2c')][_0x6b38('0x2d')],function(_0x4e0674){return{'name':_0x4e0674['fieldName'],'type':_0x4e0674[_0x6b38('0x2e')][_0x6b38('0x2f')]};});_0x3601da[_0x6b38('0x30')]=_['map'](_0x3c9996,_0x6b38('0x29'));_0x3601da[_0x6b38('0x31')]=_[_0x6b38('0x32')](_0x20fac0['query']);_0x3601da['filters']=_['intersection'](_0x3601da[_0x6b38('0x30')],_0x3601da[_0x6b38('0x31')]);_0x5d9d37[_0x6b38('0x33')]=_[_0x6b38('0x34')](_0x3601da[_0x6b38('0x30')],qs['fields'](_0x20fac0['query']['fields']));_0x5d9d37[_0x6b38('0x33')]=_0x5d9d37['attributes'][_0x6b38('0x35')]?_0x5d9d37[_0x6b38('0x33')]:_0x3601da[_0x6b38('0x30')];if(!_0x20fac0[_0x6b38('0x31')][_0x6b38('0x36')](_0x6b38('0x37'))){_0x5d9d37[_0x6b38('0x1d')]=qs[_0x6b38('0x1d')](_0x20fac0[_0x6b38('0x31')][_0x6b38('0x1d')]);_0x5d9d37[_0x6b38('0x1c')]=qs['offset'](_0x20fac0['query'][_0x6b38('0x1c')]);}_0x5d9d37[_0x6b38('0x38')]=qs['sort'](_0x20fac0['query'][_0x6b38('0x39')]);_0x5d9d37[_0x6b38('0x3a')]=qs[_0x6b38('0x3b')](_['pick'](_0x20fac0[_0x6b38('0x31')],_0x3601da[_0x6b38('0x3b')]),_0x3c9996);if(_0x20fac0[_0x6b38('0x31')]['filter']){_0x5d9d37[_0x6b38('0x3a')]=_[_0x6b38('0x3c')](_0x5d9d37['where'],{'$or':_['map'](_0x3c9996,function(_0x3acc5c){if(_0x3acc5c['type']!==_0x6b38('0x3d')){var _0x35bb8d={};_0x35bb8d[_0x3acc5c[_0x6b38('0x29')]]={'$like':'%'+_0x20fac0[_0x6b38('0x31')][_0x6b38('0x3e')]+'%'};return _0x35bb8d;}})});}_0x5d9d37=_[_0x6b38('0x3c')]({},_0x5d9d37,_0x20fac0['options']);var _0x3906b1={'where':_0x5d9d37[_0x6b38('0x3a')]};return db['AnalyticDefaultReport'][_0x6b38('0x1b')](_0x3906b1)[_0x6b38('0x22')](function(_0x1ffd7a){_0x373584[_0x6b38('0x1b')]=_0x1ffd7a;if(_0x20fac0[_0x6b38('0x31')][_0x6b38('0x3f')]){_0x5d9d37[_0x6b38('0x40')]=[{'all':!![]}];}return db[_0x6b38('0x2c')][_0x6b38('0x41')](_0x5d9d37);})[_0x6b38('0x22')](function(_0x58ec5a){_0x373584[_0x6b38('0x42')]=_0x58ec5a;return _0x373584;})[_0x6b38('0x22')](respondWithFilteredResult(_0x2e9737,_0x5d9d37))[_0x6b38('0x43')](handleError(_0x2e9737,null));};exports[_0x6b38('0x44')]=function(_0x262607,_0x40f099){var _0x4cc978={'raw':!![],'where':{'id':_0x262607['params']['id']}},_0x481881={};_0x481881[_0x6b38('0x30')]=_['keys'](db[_0x6b38('0x2c')][_0x6b38('0x2d')]);_0x481881['query']=_['keys'](_0x262607[_0x6b38('0x31')]);_0x481881[_0x6b38('0x3b')]=_['intersection'](_0x481881[_0x6b38('0x30')],_0x481881[_0x6b38('0x31')]);_0x4cc978[_0x6b38('0x33')]=_[_0x6b38('0x34')](_0x481881[_0x6b38('0x30')],qs[_0x6b38('0x45')](_0x262607[_0x6b38('0x31')][_0x6b38('0x45')]));_0x4cc978[_0x6b38('0x33')]=_0x4cc978[_0x6b38('0x33')][_0x6b38('0x35')]?_0x4cc978['attributes']:_0x481881['model'];if(_0x262607[_0x6b38('0x31')]['includeAll']){_0x4cc978[_0x6b38('0x40')]=[{'all':!![]}];}_0x4cc978=_[_0x6b38('0x3c')]({},_0x4cc978,_0x262607[_0x6b38('0x46')]);return db[_0x6b38('0x2c')][_0x6b38('0x47')](_0x4cc978)['then'](handleEntityNotFound(_0x40f099,null))[_0x6b38('0x22')](respondWithResult(_0x40f099,null))['catch'](handleError(_0x40f099,null));};exports[_0x6b38('0x48')]=function(_0x4fe14b,_0x586737){return db[_0x6b38('0x2c')]['create'](_0x4fe14b[_0x6b38('0x49')],{})[_0x6b38('0x22')](function(_0x1e862f){var _0x578b96=_0x4fe14b[_0x6b38('0x4a')][_0x6b38('0x24')]({'plain':!![]});if(!_0x578b96)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x578b96[_0x6b38('0x4b')]===_0x6b38('0x4a')){var _0x3e1d05=_0x1e862f[_0x6b38('0x24')]({'plain':!![]});var _0x225f56=_0x6b38('0x4c');return db['UserProfileSection']['find']({'where':{'name':_0x225f56,'userProfileId':_0x578b96['userProfileId']},'raw':!![]})[_0x6b38('0x22')](function(_0x2e54b4){if(_0x2e54b4&&_0x2e54b4[_0x6b38('0x4d')]===0x0){return db[_0x6b38('0x26')]['create']({'name':_0x3e1d05[_0x6b38('0x29')],'resourceId':_0x3e1d05['id'],'type':_0x6b38('0x25'),'sectionId':_0x2e54b4['id']},{})[_0x6b38('0x22')](function(){return _0x1e862f;});}else{return _0x1e862f;}})[_0x6b38('0x43')](function(_0x1a62fc){logger['error'](_0x6b38('0x4e'),_0x1a62fc);throw _0x1a62fc;});}return _0x1e862f;})['then'](respondWithResult(_0x586737,0xc9))[_0x6b38('0x43')](handleError(_0x586737,null));};exports[_0x6b38('0x21')]=function(_0x1b8580,_0x15afcd){if(_0x1b8580[_0x6b38('0x49')]['id']){delete _0x1b8580['body']['id'];}return db[_0x6b38('0x2c')]['find']({'where':{'id':_0x1b8580[_0x6b38('0x4f')]['id']}})[_0x6b38('0x22')](handleEntityNotFound(_0x15afcd,null))['then'](saveUpdates(_0x1b8580[_0x6b38('0x49')],null))[_0x6b38('0x22')](respondWithResult(_0x15afcd,null))[_0x6b38('0x43')](handleError(_0x15afcd,null));};exports['destroy']=function(_0x465b3a,_0x369bcb){return db[_0x6b38('0x2c')][_0x6b38('0x47')]({'where':{'id':_0x465b3a['params']['id']}})[_0x6b38('0x22')](handleEntityNotFound(_0x369bcb,null))[_0x6b38('0x22')](removeEntity(_0x369bcb,null))[_0x6b38('0x43')](handleError(_0x369bcb,null));};exports[_0x6b38('0x50')]=function(_0x1af520,_0x3e9670){var _0x485d93=0xa;var _0x572453=[_0x6b38('0x51'),'left_join',_0x6b38('0x52'),_0x6b38('0x53')];var _0x5a69a5={'SUM':_0x6b38('0x54'),'COUNT':'COUNT(%s)','COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x6b38('0x55'),'MIN':'MIN(%s)','AVG':_0x6b38('0x56'),'GROUP_CONCAT':_0x6b38('0x57'),'GROUP_CONCAT ASC':_0x6b38('0x58'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x2b9669={'SEC_TO_TIME':_0x6b38('0x59'),'DATE':_0x6b38('0x5a'),'HOUR':_0x6b38('0x5b'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x6b38('0x5c')};var _0x571e29=function(_0x40658b){return!_[_0x6b38('0x5d')](['IS\x20NULL',_0x6b38('0x5e'),_0x6b38('0x5f'),_0x6b38('0x60')],_0x40658b);};var _0x2d7ca8=function(_0x538df6){if(!_0x538df6||!_0x538df6[_0x6b38('0x61')][_0x6b38('0x35')]){return'';}for(var _0x4c682e='(',_0x3c1f24=0x0;_0x3c1f24<_0x538df6[_0x6b38('0x61')][_0x6b38('0x35')];_0x3c1f24+=0x1){_0x3c1f24>0x0&&(_0x4c682e+='\x20'+_0x538df6[_0x6b38('0x62')]+'\x20');_0x4c682e+=_0x538df6['rules'][_0x3c1f24][_0x6b38('0x63')]?_0x2d7ca8(_0x538df6[_0x6b38('0x61')][_0x3c1f24][_0x6b38('0x63')]):_0x538df6[_0x6b38('0x61')][_0x3c1f24][_0x6b38('0x64')]+'\x20'+_0x538df6[_0x6b38('0x61')][_0x3c1f24][_0x6b38('0x65')]+(_0x571e29(_0x538df6[_0x6b38('0x61')][_0x3c1f24]['condition'])?'\x20'+_0x538df6['rules'][_0x3c1f24][_0x6b38('0x66')]:'');}return _0x4c682e+')';};var _0x4e77bf={'where':{'id':_0x1af520[_0x6b38('0x4f')]['id']}},_0x1a50a6,_0x5e6624,_0xf7832f,_0x2035cb,_0x397356;_0x4e77bf=_[_0x6b38('0x3c')]({},_0x4e77bf,_0x1af520[_0x6b38('0x46')]);return db[_0x6b38('0x2c')][_0x6b38('0x47')](_0x4e77bf)[_0x6b38('0x22')](function(_0x19e557){if(_0x19e557){_0x1a50a6=_0x19e557;return _0x19e557[_0x6b38('0x67')]();}return null;})[_0x6b38('0x22')](function(_0x250175){if(_0x250175){if(!_0x250175['length']){throw new db[(_0x6b38('0x68'))][(_0x6b38('0x69'))](_0x6b38('0x6a'),0x193);}_0x5e6624=_0x250175;return db[_0x6b38('0x6b')][_0x6b38('0x41')]({'raw':!![]});}return null;})[_0x6b38('0x22')](function(_0x4ed868){if(_0x4ed868){_0xf7832f=_[_0x6b38('0x6c')](_0x4ed868,'id');var _0x5ee3ee;var _0x5ceca6=squel[_0x6b38('0x6d')]();_0x5ceca6[_0x6b38('0x6e')](_0x1a50a6['table']);for(var _0x319c08=0x0;_0x319c08<_0x5e6624[_0x6b38('0x35')];_0x319c08+=0x1){_0x5ee3ee=_0x5e6624[_0x319c08][_0x6b38('0x6f')]?_0xf7832f[_0x5e6624[_0x319c08]['MetricId']][_0x6b38('0x70')]:_0x5e6624[_0x319c08][_0x6b38('0x64')];_0x5ee3ee=_0x5e6624[_0x319c08][_0x6b38('0x71')]?_[_0x6b38('0x72')](_0x5a69a5[_0x5e6624[_0x319c08][_0x6b38('0x71')]],'%s',_0x5ee3ee):_0x5ee3ee;_0x5ee3ee=_0x5e6624[_0x319c08]['format']?_['replace'](_0x2b9669[_0x5e6624[_0x319c08][_0x6b38('0x73')]],'%s',_0x5ee3ee):_0x5ee3ee;if(_0x5e6624[_0x319c08][_0x6b38('0x74')]){_0x5ceca6[_0x6b38('0x63')](_0x5ee3ee);}_0x5e6624[_0x319c08][_0x6b38('0x75')]&&_0x5ceca6[_0x6b38('0x38')](_0x5ee3ee,_0x5e6624[_0x319c08][_0x6b38('0x75')]===_0x6b38('0x76')?![]:!![]);_0x5ceca6[_0x6b38('0x64')](_0x5ee3ee,_0x5e6624[_0x319c08][_0x6b38('0x77')]||_0x5ee3ee);}if(_0x1a50a6[_0x6b38('0x78')]){_0x1a50a6[_0x6b38('0x78')]=JSON[_0x6b38('0x79')](_0x1a50a6[_0x6b38('0x78')]);for(var _0x1fddb8=0x0;_0x1fddb8<_0x1a50a6['joins']['length'];_0x1fddb8+=0x1){if(_0x1a50a6[_0x6b38('0x78')][_0x1fddb8][_0x6b38('0x2e')]&&_[_0x6b38('0x5d')](_0x572453,_0x1a50a6[_0x6b38('0x78')][_0x1fddb8]['type'])&&_0x1a50a6['joins'][_0x1fddb8][_0x6b38('0x7a')]&&_0x1a50a6['joins'][_0x1fddb8][_0x6b38('0x7b')]&&_0x1a50a6[_0x6b38('0x78')][_0x1fddb8]['foreignKey']){_0x5ceca6[_0x1a50a6[_0x6b38('0x78')][_0x1fddb8][_0x6b38('0x2e')]](_0x1a50a6[_0x6b38('0x78')][_0x1fddb8][_0x6b38('0x7b')],null,util[_0x6b38('0x73')](_0x6b38('0x7c'),_0x1a50a6['table'],_0x1a50a6[_0x6b38('0x78')][_0x1fddb8]['parentKey'],_0x1a50a6['joins'][_0x1fddb8][_0x6b38('0x7b')],_0x1a50a6['joins'][_0x1fddb8]['foreignKey']));}}}if(_0x1a50a6['conditions']){_0x1a50a6[_0x6b38('0x7d')]=JSON[_0x6b38('0x79')](_0x1a50a6[_0x6b38('0x7d')]);_0x5ceca6[_0x6b38('0x3a')](_0x2d7ca8(_0x1a50a6[_0x6b38('0x7d')][_0x6b38('0x63')]));}_0x397356=_0x5ceca6['clone']();_0x5ceca6[_0x6b38('0x1d')](_0x485d93);_0x5ceca6['offset'](0x0);logger[_0x6b38('0x7e')]('Limited\x20Query:',_0x5ceca6[_0x6b38('0x7f')]());return dbH[_0x6b38('0x80')][_0x6b38('0x31')](_0x5ceca6[_0x6b38('0x7f')](),{'type':dbH[_0x6b38('0x80')][_0x6b38('0x81')][_0x6b38('0x82')]});}})[_0x6b38('0x22')](respondWithResult(_0x3e9670,null))['catch'](handleError(_0x3e9670,null));};function runReport(_0x24af9e,_0x287530,_0x515fd7){var _0x523b01=_0x287530['name'];var _0x38b088=0xa;var _0x1c2367=[_0x6b38('0x51'),_0x6b38('0x83'),_0x6b38('0x52'),_0x6b38('0x53')];var _0x5dcf09={'SUM':_0x6b38('0x54'),'COUNT':_0x6b38('0x84'),'COUNT DISTINCT':_0x6b38('0x85'),'MAX':_0x6b38('0x55'),'MIN':_0x6b38('0x86'),'AVG':_0x6b38('0x56'),'GROUP_CONCAT':_0x6b38('0x57'),'GROUP_CONCAT ASC':_0x6b38('0x58'),'GROUP_CONCAT DESC':_0x6b38('0x87')};var _0x4aa2ff={'SEC_TO_TIME':_0x6b38('0x59'),'DATE':_0x6b38('0x5a'),'HOUR':'HOUR(%s)','ROUND':_0x6b38('0x88'),'UNIX_TIMESTAMP':_0x6b38('0x5c')};var _0x4005e7=function(_0x39177e){return!_[_0x6b38('0x5d')]([_0x6b38('0x89'),'IS\x20NOT\x20NULL',_0x6b38('0x5f'),_0x6b38('0x60')],_0x39177e);};var _0x281ee7=function(_0x2902d8){if(!_0x2902d8||!_0x2902d8['rules'][_0x6b38('0x35')]){return'';}for(var _0x2a0cd4='(',_0xac8060=0x0;_0xac8060<_0x2902d8[_0x6b38('0x61')][_0x6b38('0x35')];_0xac8060+=0x1){_0xac8060>0x0&&(_0x2a0cd4+='\x20'+_0x2902d8[_0x6b38('0x62')]+'\x20');_0x2a0cd4+=_0x2902d8[_0x6b38('0x61')][_0xac8060]['group']?_0x281ee7(_0x2902d8[_0x6b38('0x61')][_0xac8060][_0x6b38('0x63')]):_0x2902d8[_0x6b38('0x61')][_0xac8060][_0x6b38('0x64')]+'\x20'+_0x2902d8['rules'][_0xac8060][_0x6b38('0x65')]+(_0x4005e7(_0x2902d8[_0x6b38('0x61')][_0xac8060][_0x6b38('0x65')])?'\x20'+_0x2902d8[_0x6b38('0x61')][_0xac8060]['value']:'');}return _0x2a0cd4+')';};var _0x4fde92={'where':{'id':_0x24af9e['id']}},_0x59b191,_0x4ddc06,_0x44c3bf,_0x50380c,_0x33ca78;_0x4fde92=_['merge']({},_0x4fde92,_0x515fd7);return db[_0x6b38('0x2c')][_0x6b38('0x47')](_0x4fde92)[_0x6b38('0x22')](function(_0x324a7d){if(_0x324a7d){_0x59b191=_0x324a7d;return _0x324a7d['getFields']();}return null;})[_0x6b38('0x22')](function(_0x26120a){if(_0x26120a){if(!_0x26120a[_0x6b38('0x35')]){throw new db[(_0x6b38('0x68'))][(_0x6b38('0x69'))](_0x6b38('0x6a'),0x193);}_0x4ddc06=_0x26120a;return db[_0x6b38('0x6b')][_0x6b38('0x41')]({'raw':!![]});}return null;})[_0x6b38('0x22')](function(_0x5cfc76){if(_0x5cfc76){_0x44c3bf=_[_0x6b38('0x6c')](_0x5cfc76,'id');var _0x5ec554;var _0x3a5aec=squel['select']();_0x3a5aec[_0x6b38('0x6e')](_0x59b191[_0x6b38('0x8a')]);for(var _0x40b329=0x0;_0x40b329<_0x4ddc06[_0x6b38('0x35')];_0x40b329+=0x1){_0x5ec554=_0x4ddc06[_0x40b329][_0x6b38('0x6f')]?_0x44c3bf[_0x4ddc06[_0x40b329]['MetricId']][_0x6b38('0x70')]:_0x4ddc06[_0x40b329][_0x6b38('0x64')];_0x5ec554=_0x4ddc06[_0x40b329][_0x6b38('0x71')]?_[_0x6b38('0x72')](_0x5dcf09[_0x4ddc06[_0x40b329][_0x6b38('0x71')]],'%s',_0x5ec554):_0x5ec554;_0x5ec554=_0x4ddc06[_0x40b329]['format']?_[_0x6b38('0x72')](_0x4aa2ff[_0x4ddc06[_0x40b329][_0x6b38('0x73')]],'%s',_0x5ec554):_0x5ec554;if(_0x4ddc06[_0x40b329]['groupBy']){_0x3a5aec[_0x6b38('0x63')](_0x5ec554);}_0x4ddc06[_0x40b329][_0x6b38('0x75')]&&_0x3a5aec['order'](_0x5ec554,_0x4ddc06[_0x40b329][_0x6b38('0x75')]===_0x6b38('0x76')?![]:!![]);_0x3a5aec[_0x6b38('0x64')](_0x5ec554,_0x4ddc06[_0x40b329][_0x6b38('0x77')]||_0x5ec554);}if(_0x59b191[_0x6b38('0x78')]){_0x59b191[_0x6b38('0x78')]=JSON[_0x6b38('0x79')](_0x59b191[_0x6b38('0x78')]);for(var _0x58552c=0x0;_0x58552c<_0x59b191[_0x6b38('0x78')][_0x6b38('0x35')];_0x58552c+=0x1){if(_0x59b191['joins'][_0x58552c]['type']&&_[_0x6b38('0x5d')](_0x1c2367,_0x59b191['joins'][_0x58552c][_0x6b38('0x2e')])&&_0x59b191[_0x6b38('0x78')][_0x58552c]['parentKey']&&_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x7b')]&&_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x8b')]){_0x3a5aec[_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x2e')]](_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x7b')],null,util['format'](_0x6b38('0x7c'),_0x59b191[_0x6b38('0x8a')],_0x59b191['joins'][_0x58552c][_0x6b38('0x7a')],_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x7b')],_0x59b191[_0x6b38('0x78')][_0x58552c][_0x6b38('0x8b')]));}}}if(_0x59b191['conditions']){_0x59b191[_0x6b38('0x7d')]=JSON[_0x6b38('0x79')](_0x59b191[_0x6b38('0x7d')]);_0x3a5aec['where'](_0x281ee7(_0x59b191[_0x6b38('0x7d')][_0x6b38('0x63')]));}_0x33ca78=_0x3a5aec[_0x6b38('0x8c')]();_0x3a5aec['limit'](_0x38b088);_0x3a5aec[_0x6b38('0x1c')](0x0);return;}})[_0x6b38('0x22')](function(){if(_0x287530[_0x6b38('0x8d')]==='web'){return null;}var _0x12da34=_[_0x6b38('0x3c')](_0x287530,{'name':_0x287530['fullPath']||_0x287530[_0x6b38('0x29')]||_0x59b191[_0x6b38('0x29')],'basename':_0x523b01,'savename':util[_0x6b38('0x73')](_0x6b38('0x8e'),_0x287530[_0x6b38('0x29')]||_0x59b191[_0x6b38('0x29')],require('randomstring')[_0x6b38('0x8f')](0x4),_0x287530[_0x6b38('0x8d')]||_0x6b38('0x90')),'reportId':_0x59b191['id'],'reportType':_0x6b38('0x91')});return db[_0x6b38('0x92')]['create'](_0x12da34,{'raw':!![]});})[_0x6b38('0x22')](function(_0x38ec52){if(_0x59b191[_0x6b38('0x8a')]===_0x6b38('0x93')){_0x33ca78[_0x6b38('0x3a')](_0x59b191[_0x6b38('0x8a')]+_0x6b38('0x94'),_0x287530['startDate'],_0x287530[_0x6b38('0x95')]);}else{_0x33ca78['where'](_0x59b191['table']+_0x6b38('0x96'),_0x287530['startDate'],_0x287530[_0x6b38('0x95')]);}if(_0x38ec52){logger[_0x6b38('0x97')](_0x6b38('0x98'),_0x33ca78[_0x6b38('0x7f')]());require(_0x6b38('0x99'))[_0x6b38('0x9a')](path[_0x6b38('0x51')](__dirname,_0x6b38('0x9b'),_0x38ec52['output']),[_0x38ec52['id'],_0x33ca78[_0x6b38('0x7f')](),path[_0x6b38('0x51')](__dirname,_0x6b38('0x9c'),_0x38ec52[_0x6b38('0x9d')]),_0x523b01]);return _0x38ec52;}else{var _0x2d5b08=squel[_0x6b38('0x6d')]();_0x2d5b08[_0x6b38('0x6e')]('('+_0x33ca78[_0x6b38('0x7f')]()+')',_0x6b38('0x9e'));_0x2d5b08[_0x6b38('0x64')](_0x6b38('0x9f'),_0x6b38('0x1b'));_0x33ca78[_0x6b38('0x1d')](_0x287530[_0x6b38('0x1d')]||_0x38b088);_0x33ca78[_0x6b38('0x1c')](_0x287530[_0x6b38('0x1c')]||0x0);return dbH['sequelize']['query'](_0x2d5b08[_0x6b38('0x7f')](),{'type':dbH['sequelize'][_0x6b38('0x81')][_0x6b38('0x82')]})[_0x6b38('0x22')](function(_0x36c6d0){if(!_0x36c6d0[_0x6b38('0x35')]){_0x50380c=0x0;}else{_0x50380c=_0x36c6d0[0x0][_0x6b38('0x1b')]||0x0;}return dbH[_0x6b38('0x80')]['query'](_0x33ca78['toString'](),{'type':dbH[_0x6b38('0x80')][_0x6b38('0x81')]['SELECT']});})[_0x6b38('0x22')](function(_0x26d5b2){return{'rows':_0x26d5b2||[],'count':_0x50380c};});}});}exports['run']=function(_0x44e9f7,_0x3cc91a){return runReport(_0x44e9f7[_0x6b38('0x4f')],_0x44e9f7[_0x6b38('0x31')],_0x44e9f7['options'])['then'](respondWithResult(_0x3cc91a,null))[_0x6b38('0x43')](handleError(_0x3cc91a,null));};exports[_0x6b38('0xa0')]=runReport;exports[_0x6b38('0x31')]=function(_0x1a1ce2,_0x743c7d){var _0x399053=0xa;var _0x218195=[_0x6b38('0x51'),'left_join','right_join','cross_join'];var _0xf3e3ed={'SUM':_0x6b38('0x54'),'COUNT':_0x6b38('0x84'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x6b38('0x55'),'MIN':'MIN(%s)','AVG':_0x6b38('0x56'),'GROUP_CONCAT':_0x6b38('0x57'),'GROUP_CONCAT ASC':_0x6b38('0x58'),'GROUP_CONCAT DESC':_0x6b38('0x87')};var _0x5080c0={'SEC_TO_TIME':_0x6b38('0x59'),'DATE':_0x6b38('0x5a'),'HOUR':_0x6b38('0x5b'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x6b38('0x5c')};var _0x4f3c6f=function(_0x477d65){return!_[_0x6b38('0x5d')]([_0x6b38('0x89'),'IS\x20NOT\x20NULL',_0x6b38('0x5f'),_0x6b38('0x60')],_0x477d65);};var _0x482de9=function(_0x6cc615){if(!_0x6cc615||!_0x6cc615[_0x6b38('0x61')][_0x6b38('0x35')]){return'';}for(var _0x4300f2='(',_0x4f3db2=0x0;_0x4f3db2<_0x6cc615['rules'][_0x6b38('0x35')];_0x4f3db2+=0x1){_0x4f3db2>0x0&&(_0x4300f2+='\x20'+_0x6cc615['operator']+'\x20');_0x4300f2+=_0x6cc615['rules'][_0x4f3db2][_0x6b38('0x63')]?_0x482de9(_0x6cc615[_0x6b38('0x61')][_0x4f3db2]['group']):_0x6cc615['rules'][_0x4f3db2][_0x6b38('0x64')]+'\x20'+_0x6cc615['rules'][_0x4f3db2][_0x6b38('0x65')]+(_0x4f3c6f(_0x6cc615[_0x6b38('0x61')][_0x4f3db2][_0x6b38('0x65')])?'\x20'+_0x6cc615['rules'][_0x4f3db2][_0x6b38('0x66')]:'');}return _0x4300f2+')';};var _0x2f8802={'where':{'id':_0x1a1ce2[_0x6b38('0x4f')]['id']}},_0x5ce487,_0x458c68,_0x1b9c4e,_0x4ce0a6,_0x22b76a;_0x2f8802=_[_0x6b38('0x3c')]({},_0x2f8802,_0x1a1ce2[_0x6b38('0x46')]);return db['AnalyticDefaultReport'][_0x6b38('0x47')](_0x2f8802)['then'](function(_0x4ac1bb){if(_0x4ac1bb){_0x5ce487=_0x4ac1bb;return _0x4ac1bb[_0x6b38('0x67')]();}return null;})[_0x6b38('0x22')](function(_0x14f99a){if(_0x14f99a){if(!_0x14f99a[_0x6b38('0x35')]){throw new db[(_0x6b38('0x68'))]['ValidationErrorItem'](_0x6b38('0x6a'),0x193);}_0x458c68=_0x14f99a;return db[_0x6b38('0x6b')][_0x6b38('0x41')]({'raw':!![]});}return null;})[_0x6b38('0x22')](function(_0xacd734){if(_0xacd734){_0x1b9c4e=_[_0x6b38('0x6c')](_0xacd734,'id');var _0x45153b;var _0x916df=squel[_0x6b38('0x6d')]();_0x916df[_0x6b38('0x6e')](_0x5ce487[_0x6b38('0x8a')]);for(var _0x2a8615=0x0;_0x2a8615<_0x458c68[_0x6b38('0x35')];_0x2a8615+=0x1){_0x45153b=_0x458c68[_0x2a8615]['MetricId']?_0x1b9c4e[_0x458c68[_0x2a8615]['MetricId']][_0x6b38('0x70')]:_0x458c68[_0x2a8615][_0x6b38('0x64')];_0x45153b=_0x458c68[_0x2a8615][_0x6b38('0x71')]?_[_0x6b38('0x72')](_0xf3e3ed[_0x458c68[_0x2a8615]['function']],'%s',_0x45153b):_0x45153b;_0x45153b=_0x458c68[_0x2a8615][_0x6b38('0x73')]?_[_0x6b38('0x72')](_0x5080c0[_0x458c68[_0x2a8615][_0x6b38('0x73')]],'%s',_0x45153b):_0x45153b;if(_0x458c68[_0x2a8615][_0x6b38('0x74')]){_0x916df['group'](_0x45153b);}_0x458c68[_0x2a8615]['orderBy']&&_0x916df[_0x6b38('0x38')](_0x45153b,_0x458c68[_0x2a8615][_0x6b38('0x75')]===_0x6b38('0x76')?![]:!![]);_0x916df[_0x6b38('0x64')](_0x45153b,_0x458c68[_0x2a8615][_0x6b38('0x77')]||_0x45153b);}if(_0x5ce487[_0x6b38('0x78')]){_0x5ce487[_0x6b38('0x78')]=JSON[_0x6b38('0x79')](_0x5ce487[_0x6b38('0x78')]);for(var _0x523ed0=0x0;_0x523ed0<_0x5ce487[_0x6b38('0x78')][_0x6b38('0x35')];_0x523ed0+=0x1){if(_0x5ce487[_0x6b38('0x78')][_0x523ed0]['type']&&_[_0x6b38('0x5d')](_0x218195,_0x5ce487[_0x6b38('0x78')][_0x523ed0][_0x6b38('0x2e')])&&_0x5ce487[_0x6b38('0x78')][_0x523ed0]['parentKey']&&_0x5ce487[_0x6b38('0x78')][_0x523ed0]['foreignTable']&&_0x5ce487['joins'][_0x523ed0][_0x6b38('0x8b')]){_0x916df[_0x5ce487[_0x6b38('0x78')][_0x523ed0]['type']](_0x5ce487[_0x6b38('0x78')][_0x523ed0][_0x6b38('0x7b')],null,util[_0x6b38('0x73')](_0x6b38('0x7c'),_0x5ce487['table'],_0x5ce487[_0x6b38('0x78')][_0x523ed0][_0x6b38('0x7a')],_0x5ce487[_0x6b38('0x78')][_0x523ed0][_0x6b38('0x7b')],_0x5ce487['joins'][_0x523ed0][_0x6b38('0x8b')]));}}}if(_0x5ce487[_0x6b38('0x7d')]){_0x5ce487['conditions']=JSON[_0x6b38('0x79')](_0x5ce487['conditions']);_0x916df[_0x6b38('0x3a')](_0x482de9(_0x5ce487['conditions'][_0x6b38('0x63')]));}_0x22b76a=_0x916df[_0x6b38('0x8c')]();_0x916df['limit'](_0x399053);_0x916df[_0x6b38('0x1c')](0x0);logger[_0x6b38('0x7e')](_0x6b38('0xa1'),_0x916df[_0x6b38('0x7f')]());return dbH[_0x6b38('0x80')]['query'](_0x916df[_0x6b38('0x7f')](),{'type':dbH['sequelize'][_0x6b38('0x81')][_0x6b38('0x82')]});}})[_0x6b38('0x22')](function(){return{'sql':_0x22b76a[_0x6b38('0x7f')]()};})[_0x6b38('0x22')](respondWithResult(_0x743c7d,null))[_0x6b38('0x43')](handleError(_0x743c7d,null));};
\ No newline at end of file
+var _0x326f=['order','orderBy','DESC','joins','foreignTable','foreignKey','parentKey','conditions','Limited\x20Query:','toString','sequelize','SELECT','SUM(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','AVG(%s)','UNIX_TIMESTAMP(%s)','operator','AnalyticMetric','select','from','function','parse','%s.%s\x20=\x20%s.%s','output','web','fullPath','%s-%s.%s','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','Run\x20Query:','child_process','fork','join','../../files/reports','savename','countTable','COUNT(*)','QueryTypes','SEC_TO_TIME(%s)','debug','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','dbH','sendStatus','status','json','offset','undefined','count','apply','update','then','get','DefaultReports','UserProfileResource','destroy','end','error','name','send','index','map','AnalyticDefaultReport','fieldName','type','model','query','filters','intersection','attributes','fields','hasOwnProperty','limit','sort','where','pick','filter','merge','options','includeAll','include','findAll','catch','show','params','rawAttributes','keys','length','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','preview','left_join','right_join','cross_join','COUNT(%s)','MIN(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','DATE(%s)','HOUR(%s)','ROUND(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','group','field','condition','value','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','keyBy','table','MetricId','metric','format','replace','groupBy'];(function(_0x4b369d,_0x265eb8){var _0x571a98=function(_0x56341a){while(--_0x56341a){_0x4b369d['push'](_0x4b369d['shift']());}};_0x571a98(++_0x265eb8);}(_0x326f,0xd1));var _0xf326=function(_0x5a83ad,_0x36b446){_0x5a83ad=_0x5a83ad-0x0;var _0x1ce418=_0x326f[_0x5a83ad];return _0x1ce418;};'use strict';var emlformat=require(_0xf326('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xf326('0x1'));var rp=require(_0xf326('0x2'));var moment=require(_0xf326('0x3'));var BPromise=require(_0xf326('0x4'));var Mustache=require(_0xf326('0x5'));var util=require(_0xf326('0x6'));var path=require(_0xf326('0x7'));var sox=require(_0xf326('0x8'));var csv=require(_0xf326('0x9'));var ejs=require(_0xf326('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf326('0xb'));var squel=require(_0xf326('0xc'));var crypto=require(_0xf326('0xd'));var jsforce=require(_0xf326('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf326('0xf'));var Redis=require(_0xf326('0x10'));var authService=require(_0xf326('0x11'));var qs=require(_0xf326('0x12'));var as=require(_0xf326('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf326('0x14'))('api');var utils=require(_0xf326('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf326('0x16'));var db=require('../../mysqldb')['db'];var dbH=require(_0xf326('0x17'))[_0xf326('0x18')];function respondWithStatusCode(_0x4b3966,_0x342fe5){_0x342fe5=_0x342fe5||0xcc;return function(_0x472632){if(_0x472632){return _0x4b3966[_0xf326('0x19')](_0x342fe5);}return _0x4b3966[_0xf326('0x1a')](_0x342fe5)['end']();};}function respondWithResult(_0x45c1b6,_0x5204ee){_0x5204ee=_0x5204ee||0xc8;return function(_0x54bd1a){if(_0x54bd1a){return _0x45c1b6[_0xf326('0x1a')](_0x5204ee)[_0xf326('0x1b')](_0x54bd1a);}};}function respondWithFilteredResult(_0x1f2e5a,_0xa63d1a){return function(_0x292f4b){if(_0x292f4b){var _0x287a2a=typeof _0xa63d1a[_0xf326('0x1c')]===_0xf326('0x1d')&&typeof _0xa63d1a['limit']===_0xf326('0x1d');var _0x453100=_0x292f4b[_0xf326('0x1e')];var _0x31ffb9=_0x287a2a?0x0:_0xa63d1a[_0xf326('0x1c')];var _0x311af0=_0x287a2a?_0x292f4b['count']:_0xa63d1a['offset']+_0xa63d1a['limit'];var _0x16e605;if(_0x311af0>=_0x453100){_0x311af0=_0x453100;_0x16e605=0xc8;}else{_0x16e605=0xce;}_0x1f2e5a[_0xf326('0x1a')](_0x16e605);return _0x1f2e5a['set']('Content-Range',_0x31ffb9+'-'+_0x311af0+'/'+_0x453100)[_0xf326('0x1b')](_0x292f4b);}return null;};}function patchUpdates(_0x4dfa76){return function(_0x5b6d3c){try{jsonpatch[_0xf326('0x1f')](_0x5b6d3c,_0x4dfa76,!![]);}catch(_0x18ead3){return BPromise['reject'](_0x18ead3);}return _0x5b6d3c['save']();};}function saveUpdates(_0x19b8ba,_0xb1efcf){return function(_0x5f21a2){if(_0x5f21a2){return _0x5f21a2[_0xf326('0x20')](_0x19b8ba)[_0xf326('0x21')](function(_0x43c53e){return _0x43c53e;});}return null;};}function removeEntity(_0x295752,_0x17c157){return function(_0x2049ec){if(_0x2049ec){return _0x2049ec['destroy']()['then'](function(){var _0x4f31f6=_0x2049ec[_0xf326('0x22')]({'plain':!![]});var _0x1a2c4e=_0xf326('0x23');return db[_0xf326('0x24')][_0xf326('0x25')]({'where':{'type':_0x1a2c4e,'resourceId':_0x4f31f6['id']}})[_0xf326('0x21')](function(){return _0x2049ec;});})['then'](function(){_0x295752[_0xf326('0x1a')](0xcc)[_0xf326('0x26')]();});}};}function handleEntityNotFound(_0x212d5d,_0x581531){return function(_0x1617d2){if(!_0x1617d2){_0x212d5d['sendStatus'](0x194);}return _0x1617d2;};}function handleError(_0x4a9abf,_0x6a8e89){_0x6a8e89=_0x6a8e89||0x1f4;return function(_0x1ae23a){logger[_0xf326('0x27')](_0x1ae23a['stack']);if(_0x1ae23a[_0xf326('0x28')]){delete _0x1ae23a[_0xf326('0x28')];}_0x4a9abf['status'](_0x6a8e89)[_0xf326('0x29')](_0x1ae23a);};}exports[_0xf326('0x2a')]=function(_0xd77aba,_0x18d110){var _0xa80156={},_0x269be9={},_0x161143={'count':0x0,'rows':[]};var _0x39a1e2=_[_0xf326('0x2b')](db[_0xf326('0x2c')]['rawAttributes'],function(_0x1035ed){return{'name':_0x1035ed[_0xf326('0x2d')],'type':_0x1035ed[_0xf326('0x2e')]['key']};});_0x269be9[_0xf326('0x2f')]=_[_0xf326('0x2b')](_0x39a1e2,_0xf326('0x28'));_0x269be9['query']=_['keys'](_0xd77aba[_0xf326('0x30')]);_0x269be9[_0xf326('0x31')]=_[_0xf326('0x32')](_0x269be9[_0xf326('0x2f')],_0x269be9[_0xf326('0x30')]);_0xa80156[_0xf326('0x33')]=_[_0xf326('0x32')](_0x269be9[_0xf326('0x2f')],qs['fields'](_0xd77aba[_0xf326('0x30')][_0xf326('0x34')]));_0xa80156['attributes']=_0xa80156[_0xf326('0x33')]['length']?_0xa80156[_0xf326('0x33')]:_0x269be9['model'];if(!_0xd77aba['query'][_0xf326('0x35')]('nolimit')){_0xa80156[_0xf326('0x36')]=qs['limit'](_0xd77aba[_0xf326('0x30')][_0xf326('0x36')]);_0xa80156[_0xf326('0x1c')]=qs['offset'](_0xd77aba[_0xf326('0x30')][_0xf326('0x1c')]);}_0xa80156['order']=qs[_0xf326('0x37')](_0xd77aba[_0xf326('0x30')][_0xf326('0x37')]);_0xa80156[_0xf326('0x38')]=qs['filters'](_[_0xf326('0x39')](_0xd77aba[_0xf326('0x30')],_0x269be9[_0xf326('0x31')]),_0x39a1e2);if(_0xd77aba[_0xf326('0x30')][_0xf326('0x3a')]){_0xa80156['where']=_[_0xf326('0x3b')](_0xa80156[_0xf326('0x38')],{'$or':_['map'](_0x39a1e2,function(_0x4dd361){if(_0x4dd361[_0xf326('0x2e')]!=='VIRTUAL'){var _0x55dfa8={};_0x55dfa8[_0x4dd361[_0xf326('0x28')]]={'$like':'%'+_0xd77aba['query'][_0xf326('0x3a')]+'%'};return _0x55dfa8;}})});}_0xa80156=_[_0xf326('0x3b')]({},_0xa80156,_0xd77aba[_0xf326('0x3c')]);var _0x39611e={'where':_0xa80156['where']};return db[_0xf326('0x2c')][_0xf326('0x1e')](_0x39611e)[_0xf326('0x21')](function(_0x365627){_0x161143[_0xf326('0x1e')]=_0x365627;if(_0xd77aba[_0xf326('0x30')][_0xf326('0x3d')]){_0xa80156[_0xf326('0x3e')]=[{'all':!![]}];}return db[_0xf326('0x2c')][_0xf326('0x3f')](_0xa80156);})[_0xf326('0x21')](function(_0x2bab13){_0x161143['rows']=_0x2bab13;return _0x161143;})[_0xf326('0x21')](respondWithFilteredResult(_0x18d110,_0xa80156))[_0xf326('0x40')](handleError(_0x18d110,null));};exports[_0xf326('0x41')]=function(_0x270288,_0x1dd262){var _0x1a2d0d={'raw':!![],'where':{'id':_0x270288[_0xf326('0x42')]['id']}},_0x4f4c51={};_0x4f4c51[_0xf326('0x2f')]=_['keys'](db[_0xf326('0x2c')][_0xf326('0x43')]);_0x4f4c51[_0xf326('0x30')]=_[_0xf326('0x44')](_0x270288[_0xf326('0x30')]);_0x4f4c51['filters']=_['intersection'](_0x4f4c51[_0xf326('0x2f')],_0x4f4c51[_0xf326('0x30')]);_0x1a2d0d['attributes']=_['intersection'](_0x4f4c51[_0xf326('0x2f')],qs[_0xf326('0x34')](_0x270288[_0xf326('0x30')]['fields']));_0x1a2d0d[_0xf326('0x33')]=_0x1a2d0d[_0xf326('0x33')][_0xf326('0x45')]?_0x1a2d0d[_0xf326('0x33')]:_0x4f4c51[_0xf326('0x2f')];if(_0x270288[_0xf326('0x30')][_0xf326('0x3d')]){_0x1a2d0d[_0xf326('0x3e')]=[{'all':!![]}];}_0x1a2d0d=_[_0xf326('0x3b')]({},_0x1a2d0d,_0x270288[_0xf326('0x3c')]);return db[_0xf326('0x2c')][_0xf326('0x46')](_0x1a2d0d)[_0xf326('0x21')](handleEntityNotFound(_0x1dd262,null))[_0xf326('0x21')](respondWithResult(_0x1dd262,null))[_0xf326('0x40')](handleError(_0x1dd262,null));};exports['create']=function(_0x199f8b,_0x1b0e03){return db[_0xf326('0x2c')][_0xf326('0x47')](_0x199f8b['body'],{})[_0xf326('0x21')](function(_0x2f5511){var _0xca88e=_0x199f8b[_0xf326('0x48')]['get']({'plain':!![]});if(!_0xca88e)throw new Error(_0xf326('0x49'));if(_0xca88e[_0xf326('0x4a')]===_0xf326('0x48')){var _0x451ac7=_0x2f5511[_0xf326('0x22')]({'plain':!![]});var _0x4970fb='Reports';return db[_0xf326('0x4b')][_0xf326('0x46')]({'where':{'name':_0x4970fb,'userProfileId':_0xca88e[_0xf326('0x4c')]},'raw':!![]})['then'](function(_0x102fba){if(_0x102fba&&_0x102fba[_0xf326('0x4d')]===0x0){return db[_0xf326('0x24')]['create']({'name':_0x451ac7['name'],'resourceId':_0x451ac7['id'],'type':_0xf326('0x23'),'sectionId':_0x102fba['id']},{})['then'](function(){return _0x2f5511;});}else{return _0x2f5511;}})[_0xf326('0x40')](function(_0x554277){logger[_0xf326('0x27')](_0xf326('0x4e'),_0x554277);throw _0x554277;});}return _0x2f5511;})[_0xf326('0x21')](respondWithResult(_0x1b0e03,0xc9))[_0xf326('0x40')](handleError(_0x1b0e03,null));};exports[_0xf326('0x20')]=function(_0x35d3c8,_0x7f7ece){if(_0x35d3c8['body']['id']){delete _0x35d3c8[_0xf326('0x4f')]['id'];}return db[_0xf326('0x2c')][_0xf326('0x46')]({'where':{'id':_0x35d3c8['params']['id']}})[_0xf326('0x21')](handleEntityNotFound(_0x7f7ece,null))[_0xf326('0x21')](saveUpdates(_0x35d3c8[_0xf326('0x4f')],null))[_0xf326('0x21')](respondWithResult(_0x7f7ece,null))[_0xf326('0x40')](handleError(_0x7f7ece,null));};exports['destroy']=function(_0x161fb3,_0x21eac7){return db[_0xf326('0x2c')][_0xf326('0x46')]({'where':{'id':_0x161fb3['params']['id']}})[_0xf326('0x21')](handleEntityNotFound(_0x21eac7,null))[_0xf326('0x21')](removeEntity(_0x21eac7,null))[_0xf326('0x40')](handleError(_0x21eac7,null));};exports[_0xf326('0x50')]=function(_0x4d3b9e,_0x5be2b1){var _0x18b46e=0xa;var _0x44d2ed=['join',_0xf326('0x51'),_0xf326('0x52'),_0xf326('0x53')];var _0x1258d1={'SUM':'SUM(%s)','COUNT':_0xf326('0x54'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':'MAX(%s)','MIN':_0xf326('0x55'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xf326('0x56'),'GROUP_CONCAT ASC':_0xf326('0x57'),'GROUP_CONCAT DESC':_0xf326('0x58')};var _0x4eef49={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xf326('0x59'),'HOUR':_0xf326('0x5a'),'ROUND':_0xf326('0x5b'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x2759d7=function(_0x487020){return!_[_0xf326('0x5c')]([_0xf326('0x5d'),_0xf326('0x5e'),_0xf326('0x5f'),_0xf326('0x60')],_0x487020);};var _0x18dbfc=function(_0x23a9e8){if(!_0x23a9e8||!_0x23a9e8[_0xf326('0x61')][_0xf326('0x45')]){return'';}for(var _0x33f9dd='(',_0x33ffb8=0x0;_0x33ffb8<_0x23a9e8[_0xf326('0x61')][_0xf326('0x45')];_0x33ffb8+=0x1){_0x33ffb8>0x0&&(_0x33f9dd+='\x20'+_0x23a9e8['operator']+'\x20');_0x33f9dd+=_0x23a9e8[_0xf326('0x61')][_0x33ffb8]['group']?_0x18dbfc(_0x23a9e8[_0xf326('0x61')][_0x33ffb8][_0xf326('0x62')]):_0x23a9e8['rules'][_0x33ffb8][_0xf326('0x63')]+'\x20'+_0x23a9e8['rules'][_0x33ffb8][_0xf326('0x64')]+(_0x2759d7(_0x23a9e8[_0xf326('0x61')][_0x33ffb8][_0xf326('0x64')])?'\x20'+_0x23a9e8[_0xf326('0x61')][_0x33ffb8][_0xf326('0x65')]:'');}return _0x33f9dd+')';};var _0x51ff5e={'where':{'id':_0x4d3b9e[_0xf326('0x42')]['id']}},_0x4ec099,_0x1209ca,_0x32fe3a,_0x15a538,_0x21b3cc;_0x51ff5e=_['merge']({},_0x51ff5e,_0x4d3b9e[_0xf326('0x3c')]);return db[_0xf326('0x2c')]['find'](_0x51ff5e)['then'](function(_0x5b25ca){if(_0x5b25ca){_0x4ec099=_0x5b25ca;return _0x5b25ca[_0xf326('0x66')]();}return null;})[_0xf326('0x21')](function(_0x4150fa){if(_0x4150fa){if(!_0x4150fa[_0xf326('0x45')]){throw new db[(_0xf326('0x67'))][(_0xf326('0x68'))](_0xf326('0x69'),0x193);}_0x1209ca=_0x4150fa;return db['AnalyticMetric'][_0xf326('0x3f')]({'raw':!![]});}return null;})[_0xf326('0x21')](function(_0x3c3379){if(_0x3c3379){_0x32fe3a=_[_0xf326('0x6a')](_0x3c3379,'id');var _0x58de1e;var _0x3717fe=squel['select']();_0x3717fe['from'](_0x4ec099[_0xf326('0x6b')]);for(var _0x540fa0=0x0;_0x540fa0<_0x1209ca[_0xf326('0x45')];_0x540fa0+=0x1){_0x58de1e=_0x1209ca[_0x540fa0][_0xf326('0x6c')]?_0x32fe3a[_0x1209ca[_0x540fa0][_0xf326('0x6c')]][_0xf326('0x6d')]:_0x1209ca[_0x540fa0][_0xf326('0x63')];_0x58de1e=_0x1209ca[_0x540fa0]['function']?_['replace'](_0x1258d1[_0x1209ca[_0x540fa0]['function']],'%s',_0x58de1e):_0x58de1e;_0x58de1e=_0x1209ca[_0x540fa0][_0xf326('0x6e')]?_[_0xf326('0x6f')](_0x4eef49[_0x1209ca[_0x540fa0][_0xf326('0x6e')]],'%s',_0x58de1e):_0x58de1e;if(_0x1209ca[_0x540fa0][_0xf326('0x70')]){_0x3717fe[_0xf326('0x62')](_0x58de1e);}_0x1209ca[_0x540fa0]['orderBy']&&_0x3717fe[_0xf326('0x71')](_0x58de1e,_0x1209ca[_0x540fa0][_0xf326('0x72')]===_0xf326('0x73')?![]:!![]);_0x3717fe['field'](_0x58de1e,_0x1209ca[_0x540fa0]['alias']||_0x58de1e);}if(_0x4ec099[_0xf326('0x74')]){_0x4ec099[_0xf326('0x74')]=JSON['parse'](_0x4ec099['joins']);for(var _0x2497fd=0x0;_0x2497fd<_0x4ec099['joins'][_0xf326('0x45')];_0x2497fd+=0x1){if(_0x4ec099['joins'][_0x2497fd]['type']&&_['includes'](_0x44d2ed,_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x2e')])&&_0x4ec099[_0xf326('0x74')][_0x2497fd]['parentKey']&&_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x75')]&&_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x76')]){_0x3717fe[_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x2e')]](_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x75')],null,util[_0xf326('0x6e')]('%s.%s\x20=\x20%s.%s',_0x4ec099[_0xf326('0x6b')],_0x4ec099['joins'][_0x2497fd][_0xf326('0x77')],_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x75')],_0x4ec099['joins'][_0x2497fd][_0xf326('0x76')]));}}}if(_0x4ec099[_0xf326('0x78')]){_0x4ec099[_0xf326('0x78')]=JSON['parse'](_0x4ec099[_0xf326('0x78')]);_0x3717fe[_0xf326('0x38')](_0x18dbfc(_0x4ec099[_0xf326('0x78')][_0xf326('0x62')]));}_0x21b3cc=_0x3717fe['clone']();_0x3717fe[_0xf326('0x36')](_0x18b46e);_0x3717fe['offset'](0x0);logger['debug'](_0xf326('0x79'),_0x3717fe[_0xf326('0x7a')]());return dbH['sequelize']['query'](_0x3717fe['toString'](),{'type':dbH[_0xf326('0x7b')]['QueryTypes'][_0xf326('0x7c')]});}})[_0xf326('0x21')](respondWithResult(_0x5be2b1,null))[_0xf326('0x40')](handleError(_0x5be2b1,null));};function runReport(_0x2ec314,_0xf76a89,_0x25b56c){var _0x5d23f0=_0xf76a89[_0xf326('0x28')];var _0x323926=0xa;var _0x5f1724=['join',_0xf326('0x51'),'right_join',_0xf326('0x53')];var _0x147d51={'SUM':_0xf326('0x7d'),'COUNT':_0xf326('0x54'),'COUNT DISTINCT':_0xf326('0x7e'),'MAX':_0xf326('0x7f'),'MIN':_0xf326('0x55'),'AVG':_0xf326('0x80'),'GROUP_CONCAT':_0xf326('0x56'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xf326('0x58')};var _0x26bbb1={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xf326('0x59'),'HOUR':'HOUR(%s)','ROUND':_0xf326('0x5b'),'UNIX_TIMESTAMP':_0xf326('0x81')};var _0x14e8c0=function(_0x5814ad){return!_[_0xf326('0x5c')]([_0xf326('0x5d'),_0xf326('0x5e'),_0xf326('0x5f'),_0xf326('0x60')],_0x5814ad);};var _0x1e50aa=function(_0x148779){if(!_0x148779||!_0x148779[_0xf326('0x61')][_0xf326('0x45')]){return'';}for(var _0x38b696='(',_0x384b46=0x0;_0x384b46<_0x148779[_0xf326('0x61')][_0xf326('0x45')];_0x384b46+=0x1){_0x384b46>0x0&&(_0x38b696+='\x20'+_0x148779[_0xf326('0x82')]+'\x20');_0x38b696+=_0x148779[_0xf326('0x61')][_0x384b46]['group']?_0x1e50aa(_0x148779[_0xf326('0x61')][_0x384b46][_0xf326('0x62')]):_0x148779['rules'][_0x384b46][_0xf326('0x63')]+'\x20'+_0x148779[_0xf326('0x61')][_0x384b46]['condition']+(_0x14e8c0(_0x148779[_0xf326('0x61')][_0x384b46][_0xf326('0x64')])?'\x20'+_0x148779[_0xf326('0x61')][_0x384b46][_0xf326('0x65')]:'');}return _0x38b696+')';};var _0x2ab607={'where':{'id':_0x2ec314['id']}},_0x35c228,_0x1bb7cc,_0x5794d0,_0x15d61e,_0x107c00;_0x2ab607=_[_0xf326('0x3b')]({},_0x2ab607,_0x25b56c);return db[_0xf326('0x2c')][_0xf326('0x46')](_0x2ab607)[_0xf326('0x21')](function(_0x204002){if(_0x204002){_0x35c228=_0x204002;return _0x204002[_0xf326('0x66')]();}return null;})['then'](function(_0xa8e05b){if(_0xa8e05b){if(!_0xa8e05b[_0xf326('0x45')]){throw new db['Sequelize'][(_0xf326('0x68'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x1bb7cc=_0xa8e05b;return db[_0xf326('0x83')][_0xf326('0x3f')]({'raw':!![]});}return null;})[_0xf326('0x21')](function(_0x2a0f36){if(_0x2a0f36){_0x5794d0=_[_0xf326('0x6a')](_0x2a0f36,'id');var _0x3097cf;var _0xf66b70=squel[_0xf326('0x84')]();_0xf66b70[_0xf326('0x85')](_0x35c228[_0xf326('0x6b')]);for(var _0x3f073c=0x0;_0x3f073c<_0x1bb7cc[_0xf326('0x45')];_0x3f073c+=0x1){_0x3097cf=_0x1bb7cc[_0x3f073c][_0xf326('0x6c')]?_0x5794d0[_0x1bb7cc[_0x3f073c][_0xf326('0x6c')]]['metric']:_0x1bb7cc[_0x3f073c][_0xf326('0x63')];_0x3097cf=_0x1bb7cc[_0x3f073c][_0xf326('0x86')]?_[_0xf326('0x6f')](_0x147d51[_0x1bb7cc[_0x3f073c][_0xf326('0x86')]],'%s',_0x3097cf):_0x3097cf;_0x3097cf=_0x1bb7cc[_0x3f073c][_0xf326('0x6e')]?_['replace'](_0x26bbb1[_0x1bb7cc[_0x3f073c][_0xf326('0x6e')]],'%s',_0x3097cf):_0x3097cf;if(_0x1bb7cc[_0x3f073c][_0xf326('0x70')]){_0xf66b70[_0xf326('0x62')](_0x3097cf);}_0x1bb7cc[_0x3f073c][_0xf326('0x72')]&&_0xf66b70[_0xf326('0x71')](_0x3097cf,_0x1bb7cc[_0x3f073c]['orderBy']==='DESC'?![]:!![]);_0xf66b70[_0xf326('0x63')](_0x3097cf,_0x1bb7cc[_0x3f073c]['alias']||_0x3097cf);}if(_0x35c228[_0xf326('0x74')]){_0x35c228[_0xf326('0x74')]=JSON[_0xf326('0x87')](_0x35c228['joins']);for(var _0x54b023=0x0;_0x54b023<_0x35c228[_0xf326('0x74')][_0xf326('0x45')];_0x54b023+=0x1){if(_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x2e')]&&_[_0xf326('0x5c')](_0x5f1724,_0x35c228['joins'][_0x54b023][_0xf326('0x2e')])&&_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x77')]&&_0x35c228['joins'][_0x54b023]['foreignTable']&&_0x35c228['joins'][_0x54b023][_0xf326('0x76')]){_0xf66b70[_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x2e')]](_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x75')],null,util[_0xf326('0x6e')](_0xf326('0x88'),_0x35c228['table'],_0x35c228['joins'][_0x54b023][_0xf326('0x77')],_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x75')],_0x35c228['joins'][_0x54b023][_0xf326('0x76')]));}}}if(_0x35c228[_0xf326('0x78')]){_0x35c228[_0xf326('0x78')]=JSON['parse'](_0x35c228[_0xf326('0x78')]);_0xf66b70[_0xf326('0x38')](_0x1e50aa(_0x35c228[_0xf326('0x78')][_0xf326('0x62')]));}_0x107c00=_0xf66b70['clone']();_0xf66b70['limit'](_0x323926);_0xf66b70['offset'](0x0);return;}})[_0xf326('0x21')](function(){if(_0xf76a89[_0xf326('0x89')]===_0xf326('0x8a')){return null;}var _0x5f0b45=_[_0xf326('0x3b')](_0xf76a89,{'name':_0xf76a89[_0xf326('0x8b')]||_0xf76a89[_0xf326('0x28')]||_0x35c228['name'],'basename':_0x5d23f0,'savename':util[_0xf326('0x6e')](_0xf326('0x8c'),_0xf76a89[_0xf326('0x28')]||_0x35c228[_0xf326('0x28')],require('randomstring')[_0xf326('0x8d')](0x4),_0xf76a89['output']||_0xf326('0x8e')),'reportId':_0x35c228['id'],'reportType':_0xf326('0x8f')});return db[_0xf326('0x90')][_0xf326('0x47')](_0x5f0b45,{'raw':!![]});})['then'](function(_0x2e2f70){if(_0x35c228['table']===_0xf326('0x91')){_0x107c00[_0xf326('0x38')](_0x35c228[_0xf326('0x6b')]+_0xf326('0x92'),_0xf76a89[_0xf326('0x93')],_0xf76a89['endDate']);}else{_0x107c00['where'](_0x35c228[_0xf326('0x6b')]+_0xf326('0x94'),_0xf76a89[_0xf326('0x93')],_0xf76a89[_0xf326('0x95')]);}if(_0x2e2f70){logger['info'](_0xf326('0x96'),_0x107c00['toString']());require(_0xf326('0x97'))[_0xf326('0x98')](path[_0xf326('0x99')](__dirname,'../../components/export/',_0x2e2f70[_0xf326('0x89')]),[_0x2e2f70['id'],_0x107c00[_0xf326('0x7a')](),path[_0xf326('0x99')](__dirname,_0xf326('0x9a'),_0x2e2f70[_0xf326('0x9b')]),_0x5d23f0]);return _0x2e2f70;}else{var _0x4dc4bc=squel[_0xf326('0x84')]();_0x4dc4bc[_0xf326('0x85')]('('+_0x107c00['toString']()+')',_0xf326('0x9c'));_0x4dc4bc[_0xf326('0x63')](_0xf326('0x9d'),_0xf326('0x1e'));_0x107c00['limit'](_0xf76a89['limit']||_0x323926);_0x107c00[_0xf326('0x1c')](_0xf76a89[_0xf326('0x1c')]||0x0);return dbH['sequelize'][_0xf326('0x30')](_0x4dc4bc['toString'](),{'type':dbH['sequelize'][_0xf326('0x9e')][_0xf326('0x7c')]})[_0xf326('0x21')](function(_0x37cd6f){if(!_0x37cd6f[_0xf326('0x45')]){_0x15d61e=0x0;}else{_0x15d61e=_0x37cd6f[0x0][_0xf326('0x1e')]||0x0;}return dbH[_0xf326('0x7b')][_0xf326('0x30')](_0x107c00[_0xf326('0x7a')](),{'type':dbH['sequelize'][_0xf326('0x9e')][_0xf326('0x7c')]});})[_0xf326('0x21')](function(_0x1c7f81){return{'rows':_0x1c7f81||[],'count':_0x15d61e};});}});}exports['run']=function(_0x3e6a5d,_0x20020c){return runReport(_0x3e6a5d[_0xf326('0x42')],_0x3e6a5d[_0xf326('0x30')],_0x3e6a5d[_0xf326('0x3c')])['then'](respondWithResult(_0x20020c,null))[_0xf326('0x40')](handleError(_0x20020c,null));};exports['runReport']=runReport;exports[_0xf326('0x30')]=function(_0x14d255,_0xffd165){var _0x2bc501=0xa;var _0x4bd216=[_0xf326('0x99'),_0xf326('0x51'),_0xf326('0x52'),'cross_join'];var _0x23451e={'SUM':_0xf326('0x7d'),'COUNT':_0xf326('0x54'),'COUNT DISTINCT':_0xf326('0x7e'),'MAX':'MAX(%s)','MIN':_0xf326('0x55'),'AVG':_0xf326('0x80'),'GROUP_CONCAT':_0xf326('0x56'),'GROUP_CONCAT ASC':_0xf326('0x57'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x310223={'SEC_TO_TIME':_0xf326('0x9f'),'DATE':_0xf326('0x59'),'HOUR':'HOUR(%s)','ROUND':_0xf326('0x5b'),'UNIX_TIMESTAMP':_0xf326('0x81')};var _0x539d23=function(_0x171c53){return!_[_0xf326('0x5c')]([_0xf326('0x5d'),_0xf326('0x5e'),_0xf326('0x5f'),_0xf326('0x60')],_0x171c53);};var _0x4c7fc0=function(_0x4ffde1){if(!_0x4ffde1||!_0x4ffde1[_0xf326('0x61')][_0xf326('0x45')]){return'';}for(var _0x4307d9='(',_0x2fa05b=0x0;_0x2fa05b<_0x4ffde1[_0xf326('0x61')][_0xf326('0x45')];_0x2fa05b+=0x1){_0x2fa05b>0x0&&(_0x4307d9+='\x20'+_0x4ffde1['operator']+'\x20');_0x4307d9+=_0x4ffde1[_0xf326('0x61')][_0x2fa05b][_0xf326('0x62')]?_0x4c7fc0(_0x4ffde1[_0xf326('0x61')][_0x2fa05b][_0xf326('0x62')]):_0x4ffde1[_0xf326('0x61')][_0x2fa05b][_0xf326('0x63')]+'\x20'+_0x4ffde1[_0xf326('0x61')][_0x2fa05b][_0xf326('0x64')]+(_0x539d23(_0x4ffde1[_0xf326('0x61')][_0x2fa05b]['condition'])?'\x20'+_0x4ffde1[_0xf326('0x61')][_0x2fa05b]['value']:'');}return _0x4307d9+')';};var _0x590dc0={'where':{'id':_0x14d255[_0xf326('0x42')]['id']}},_0x32fc6e,_0x549a1f,_0x1f37f9,_0x3e0918,_0x3398fd;_0x590dc0=_[_0xf326('0x3b')]({},_0x590dc0,_0x14d255[_0xf326('0x3c')]);return db[_0xf326('0x2c')][_0xf326('0x46')](_0x590dc0)[_0xf326('0x21')](function(_0x314442){if(_0x314442){_0x32fc6e=_0x314442;return _0x314442[_0xf326('0x66')]();}return null;})[_0xf326('0x21')](function(_0x4c1fcd){if(_0x4c1fcd){if(!_0x4c1fcd[_0xf326('0x45')]){throw new db[(_0xf326('0x67'))][(_0xf326('0x68'))](_0xf326('0x69'),0x193);}_0x549a1f=_0x4c1fcd;return db[_0xf326('0x83')][_0xf326('0x3f')]({'raw':!![]});}return null;})[_0xf326('0x21')](function(_0x5429a2){if(_0x5429a2){_0x1f37f9=_[_0xf326('0x6a')](_0x5429a2,'id');var _0x15f799;var _0x320ab3=squel[_0xf326('0x84')]();_0x320ab3[_0xf326('0x85')](_0x32fc6e[_0xf326('0x6b')]);for(var _0x2094bf=0x0;_0x2094bf<_0x549a1f['length'];_0x2094bf+=0x1){_0x15f799=_0x549a1f[_0x2094bf][_0xf326('0x6c')]?_0x1f37f9[_0x549a1f[_0x2094bf][_0xf326('0x6c')]][_0xf326('0x6d')]:_0x549a1f[_0x2094bf][_0xf326('0x63')];_0x15f799=_0x549a1f[_0x2094bf][_0xf326('0x86')]?_[_0xf326('0x6f')](_0x23451e[_0x549a1f[_0x2094bf][_0xf326('0x86')]],'%s',_0x15f799):_0x15f799;_0x15f799=_0x549a1f[_0x2094bf][_0xf326('0x6e')]?_[_0xf326('0x6f')](_0x310223[_0x549a1f[_0x2094bf][_0xf326('0x6e')]],'%s',_0x15f799):_0x15f799;if(_0x549a1f[_0x2094bf][_0xf326('0x70')]){_0x320ab3[_0xf326('0x62')](_0x15f799);}_0x549a1f[_0x2094bf]['orderBy']&&_0x320ab3[_0xf326('0x71')](_0x15f799,_0x549a1f[_0x2094bf][_0xf326('0x72')]===_0xf326('0x73')?![]:!![]);_0x320ab3['field'](_0x15f799,_0x549a1f[_0x2094bf]['alias']||_0x15f799);}if(_0x32fc6e[_0xf326('0x74')]){_0x32fc6e[_0xf326('0x74')]=JSON[_0xf326('0x87')](_0x32fc6e[_0xf326('0x74')]);for(var _0x5384a5=0x0;_0x5384a5<_0x32fc6e[_0xf326('0x74')][_0xf326('0x45')];_0x5384a5+=0x1){if(_0x32fc6e[_0xf326('0x74')][_0x5384a5]['type']&&_['includes'](_0x4bd216,_0x32fc6e['joins'][_0x5384a5][_0xf326('0x2e')])&&_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x77')]&&_0x32fc6e['joins'][_0x5384a5][_0xf326('0x75')]&&_0x32fc6e['joins'][_0x5384a5][_0xf326('0x76')]){_0x320ab3[_0x32fc6e['joins'][_0x5384a5][_0xf326('0x2e')]](_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x75')],null,util[_0xf326('0x6e')](_0xf326('0x88'),_0x32fc6e[_0xf326('0x6b')],_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x77')],_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x75')],_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x76')]));}}}if(_0x32fc6e[_0xf326('0x78')]){_0x32fc6e[_0xf326('0x78')]=JSON['parse'](_0x32fc6e[_0xf326('0x78')]);_0x320ab3[_0xf326('0x38')](_0x4c7fc0(_0x32fc6e[_0xf326('0x78')]['group']));}_0x3398fd=_0x320ab3['clone']();_0x320ab3['limit'](_0x2bc501);_0x320ab3[_0xf326('0x1c')](0x0);logger[_0xf326('0xa0')](_0xf326('0x79'),_0x320ab3[_0xf326('0x7a')]());return dbH[_0xf326('0x7b')][_0xf326('0x30')](_0x320ab3['toString'](),{'type':dbH[_0xf326('0x7b')][_0xf326('0x9e')][_0xf326('0x7c')]});}})[_0xf326('0x21')](function(){return{'sql':_0x3398fd[_0xf326('0x7a')]()};})['then'](respondWithResult(_0xffd165,null))[_0xf326('0x40')](handleError(_0xffd165,null));};
\ No newline at end of file