Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index d5bd480..80ec0d5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2bf6=['index','map','AnalyticDefaultReport','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','catch','show','fields','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','Reports','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','preview','join','right_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','SEC_TO_TIME(%s)','DATE(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','value','getFields','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','findAll','keyBy','select','table','MetricId','function','replace','format','groupBy','orderBy','DESC','alias','joins','parse','includes','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','clone','Limited\x20Query:','toString','sequelize','QueryTypes','SELECT','left_join','cross_join','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','HOUR(%s)','from','parentKey','output','web','%s-%s.%s','randomstring','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','endDate','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','countTable','run','runReport','Sequelize','debug','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','path','lodash','squel','crypto','to-csv','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','status','end','json','count','offset','limit','set','apply','reject','save','then','get','DefaultReports','UserProfileResource','destroy','sendStatus','stack','name','send'];(function(_0x511b17,_0xe6b453){var _0x4fa333=function(_0x5f13e3){while(--_0x5f13e3){_0x511b17['push'](_0x511b17['shift']());}};_0x4fa333(++_0xe6b453);}(_0x2bf6,0x11c));var _0x62bf=function(_0x130148,_0x5a2500){_0x130148=_0x130148-0x0;var _0xe4ebfb=_0x2bf6[_0x130148];return _0xe4ebfb;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x62bf('0x0'));var rimraf=require(_0x62bf('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x62bf('0x2'));var rp=require(_0x62bf('0x3'));var moment=require(_0x62bf('0x4'));var BPromise=require(_0x62bf('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x62bf('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x62bf('0x7'));var squel=require(_0x62bf('0x8'));var crypto=require(_0x62bf('0x9'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x62bf('0xa'));var querystring=require(_0x62bf('0xb'));var Papa=require(_0x62bf('0xc'));var Redis=require(_0x62bf('0xd'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x62bf('0xe'));var hardwareService=require(_0x62bf('0xf'));var logger=require(_0x62bf('0x10'))(_0x62bf('0x11'));var utils=require(_0x62bf('0x12'));var config=require(_0x62bf('0x13'));var licenseUtil=require(_0x62bf('0x14'));var db=require(_0x62bf('0x15'))['db'];var dbH=require(_0x62bf('0x15'))[_0x62bf('0x16')];function respondWithStatusCode(_0x7e2c2c,_0x294cc3){_0x294cc3=_0x294cc3||0xcc;return function(_0x2b112b){if(_0x2b112b){return _0x7e2c2c['sendStatus'](_0x294cc3);}return _0x7e2c2c[_0x62bf('0x17')](_0x294cc3)[_0x62bf('0x18')]();};}function respondWithResult(_0x42a627,_0x5658c2){_0x5658c2=_0x5658c2||0xc8;return function(_0x387ebf){if(_0x387ebf){return _0x42a627[_0x62bf('0x17')](_0x5658c2)[_0x62bf('0x19')](_0x387ebf);}};}function respondWithFilteredResult(_0x345914,_0x4c88d5){return function(_0x1ba80a){if(_0x1ba80a){var _0xaf25fa=_0x1ba80a[_0x62bf('0x1a')],_0x44a6df=_0x4c88d5[_0x62bf('0x1b')],_0x4c2585=_0x4c88d5[_0x62bf('0x1b')]+_0x4c88d5[_0x62bf('0x1c')],_0x53a587;if(_0x4c2585>=_0xaf25fa){_0x4c2585=_0xaf25fa;_0x53a587=0xc8;}else{_0x53a587=0xce;}_0x345914[_0x62bf('0x17')](_0x53a587);return _0x345914[_0x62bf('0x1d')]('Content-Range',_0x44a6df+'-'+_0x4c2585+'/'+_0xaf25fa)[_0x62bf('0x19')](_0x1ba80a);}return null;};}function patchUpdates(_0xf079e){return function(_0x1e8762){try{jsonpatch[_0x62bf('0x1e')](_0x1e8762,_0xf079e,!![]);}catch(_0x2142e2){return BPromise[_0x62bf('0x1f')](_0x2142e2);}return _0x1e8762[_0x62bf('0x20')]();};}function saveUpdates(_0x1b6788,_0x237d1a){return function(_0x32c3dc){if(_0x32c3dc){return _0x32c3dc['update'](_0x1b6788)[_0x62bf('0x21')](function(_0x18a2d6){return _0x18a2d6;});}return null;};}function removeEntity(_0x46de16,_0x10a1c9){return function(_0x4dba85){if(_0x4dba85){return _0x4dba85['destroy']()[_0x62bf('0x21')](function(){var _0x352fbd=_0x4dba85[_0x62bf('0x22')]({'plain':!![]});var _0x34f69b=_0x62bf('0x23');return db[_0x62bf('0x24')][_0x62bf('0x25')]({'where':{'type':_0x34f69b,'resourceId':_0x352fbd['id']}})[_0x62bf('0x21')](function(){return _0x4dba85;});})[_0x62bf('0x21')](function(){_0x46de16['status'](0xcc)[_0x62bf('0x18')]();});}};}function handleEntityNotFound(_0x8756d3,_0x363975){return function(_0x2ec213){if(!_0x2ec213){_0x8756d3[_0x62bf('0x26')](0x194);}return _0x2ec213;};}function handleError(_0x4bd573,_0x1a638f){_0x1a638f=_0x1a638f||0x1f4;return function(_0x2820cb){logger['error'](_0x2820cb[_0x62bf('0x27')]);if(_0x2820cb[_0x62bf('0x28')]){delete _0x2820cb['name'];}_0x4bd573[_0x62bf('0x17')](_0x1a638f)[_0x62bf('0x29')](_0x2820cb);};}exports[_0x62bf('0x2a')]=function(_0xf0f657,_0x27420f){var _0x3d6804={},_0x379285={},_0x1b781d={'count':0x0,'rows':[]};var _0x339240=_[_0x62bf('0x2b')](db[_0x62bf('0x2c')][_0x62bf('0x2d')],function(_0x1a8d9f){return{'name':_0x1a8d9f[_0x62bf('0x2e')],'type':_0x1a8d9f[_0x62bf('0x2f')][_0x62bf('0x30')]};});_0x379285[_0x62bf('0x31')]=_[_0x62bf('0x2b')](_0x339240,_0x62bf('0x28'));_0x379285['query']=_[_0x62bf('0x32')](_0xf0f657[_0x62bf('0x33')]);_0x379285[_0x62bf('0x34')]=_[_0x62bf('0x35')](_0x379285[_0x62bf('0x31')],_0x379285[_0x62bf('0x33')]);_0x3d6804[_0x62bf('0x36')]=_[_0x62bf('0x35')](_0x379285[_0x62bf('0x31')],qs['fields'](_0xf0f657[_0x62bf('0x33')]['fields']));_0x3d6804['attributes']=_0x3d6804[_0x62bf('0x36')][_0x62bf('0x37')]?_0x3d6804[_0x62bf('0x36')]:_0x379285[_0x62bf('0x31')];if(!_0xf0f657['query'][_0x62bf('0x38')](_0x62bf('0x39'))){_0x3d6804[_0x62bf('0x1c')]=qs[_0x62bf('0x1c')](_0xf0f657[_0x62bf('0x33')][_0x62bf('0x1c')]);_0x3d6804[_0x62bf('0x1b')]=qs[_0x62bf('0x1b')](_0xf0f657['query']['offset']);}_0x3d6804[_0x62bf('0x3a')]=qs[_0x62bf('0x3b')](_0xf0f657['query'][_0x62bf('0x3b')]);_0x3d6804[_0x62bf('0x3c')]=qs[_0x62bf('0x34')](_[_0x62bf('0x3d')](_0xf0f657[_0x62bf('0x33')],_0x379285[_0x62bf('0x34')]),_0x339240);if(_0xf0f657['query'][_0x62bf('0x3e')]){_0x3d6804[_0x62bf('0x3c')]=_[_0x62bf('0x3f')](_0x3d6804[_0x62bf('0x3c')],{'$or':_[_0x62bf('0x2b')](_0x339240,function(_0x37f639){if(_0x37f639['type']!==_0x62bf('0x40')){var _0x30b7ca={};_0x30b7ca[_0x37f639[_0x62bf('0x28')]]={'$like':'%'+_0xf0f657[_0x62bf('0x33')]['filter']+'%'};return _0x30b7ca;}})});}_0x3d6804=_['merge']({},_0x3d6804,_0xf0f657[_0x62bf('0x41')]);var _0x4e513c={'where':_0x3d6804[_0x62bf('0x3c')]};return db[_0x62bf('0x2c')]['count'](_0x4e513c)['then'](function(_0x22ffbb){_0x1b781d['count']=_0x22ffbb;if(_0xf0f657[_0x62bf('0x33')]['includeAll']){_0x3d6804[_0x62bf('0x42')]=[{'all':!![]}];}return db[_0x62bf('0x2c')]['findAll'](_0x3d6804);})[_0x62bf('0x21')](function(_0x44d82c){_0x1b781d[_0x62bf('0x43')]=_0x44d82c;return _0x1b781d;})[_0x62bf('0x21')](respondWithFilteredResult(_0x27420f,_0x3d6804))[_0x62bf('0x44')](handleError(_0x27420f,null));};exports[_0x62bf('0x45')]=function(_0xff4bb6,_0x4d1209){var _0x376704={'raw':!![],'where':{'id':_0xff4bb6['params']['id']}},_0x295e52={};_0x295e52[_0x62bf('0x31')]=_[_0x62bf('0x32')](db['AnalyticDefaultReport'][_0x62bf('0x2d')]);_0x295e52[_0x62bf('0x33')]=_[_0x62bf('0x32')](_0xff4bb6[_0x62bf('0x33')]);_0x295e52[_0x62bf('0x34')]=_['intersection'](_0x295e52[_0x62bf('0x31')],_0x295e52['query']);_0x376704['attributes']=_[_0x62bf('0x35')](_0x295e52[_0x62bf('0x31')],qs[_0x62bf('0x46')](_0xff4bb6['query'][_0x62bf('0x46')]));_0x376704[_0x62bf('0x36')]=_0x376704['attributes'][_0x62bf('0x37')]?_0x376704[_0x62bf('0x36')]:_0x295e52['model'];if(_0xff4bb6[_0x62bf('0x33')][_0x62bf('0x47')]){_0x376704['include']=[{'all':!![]}];}_0x376704=_[_0x62bf('0x3f')]({},_0x376704,_0xff4bb6['options']);return db[_0x62bf('0x2c')][_0x62bf('0x48')](_0x376704)[_0x62bf('0x21')](handleEntityNotFound(_0x4d1209,null))[_0x62bf('0x21')](respondWithResult(_0x4d1209,null))[_0x62bf('0x44')](handleError(_0x4d1209,null));};exports['create']=function(_0xea09d5,_0x2b9d20){return db[_0x62bf('0x2c')][_0x62bf('0x49')](_0xea09d5[_0x62bf('0x4a')],{})['then'](function(_0x3b6a57){var _0x272b1e=_0xea09d5[_0x62bf('0x4b')][_0x62bf('0x22')]({'plain':!![]});if(!_0x272b1e)throw new Error(_0x62bf('0x4c'));if(_0x272b1e['role']==='user'){var _0x3aa3fc=_0x3b6a57[_0x62bf('0x22')]({'plain':!![]});var _0x26436e=_0x62bf('0x4d');return db[_0x62bf('0x4e')]['find']({'where':{'name':_0x26436e,'userProfileId':_0x272b1e['userProfileId']},'raw':!![]})[_0x62bf('0x21')](function(_0x4020f4){if(_0x4020f4&&_0x4020f4[_0x62bf('0x4f')]===0x0){return db['UserProfileResource']['create']({'name':_0x3aa3fc['name'],'resourceId':_0x3aa3fc['id'],'type':_0x62bf('0x23'),'sectionId':_0x4020f4['id']},{})['then'](function(){return _0x3b6a57;});}else{return _0x3b6a57;}})[_0x62bf('0x44')](function(_0x44a75f){logger['error'](_0x62bf('0x50'),_0x44a75f);throw _0x44a75f;});}return _0x3b6a57;})[_0x62bf('0x21')](respondWithResult(_0x2b9d20,0xc9))[_0x62bf('0x44')](handleError(_0x2b9d20,null));};exports['update']=function(_0x33297f,_0x2d30a3){if(_0x33297f[_0x62bf('0x4a')]['id']){delete _0x33297f[_0x62bf('0x4a')]['id'];}return db['AnalyticDefaultReport'][_0x62bf('0x48')]({'where':{'id':_0x33297f[_0x62bf('0x51')]['id']}})[_0x62bf('0x21')](handleEntityNotFound(_0x2d30a3,null))['then'](saveUpdates(_0x33297f[_0x62bf('0x4a')],null))[_0x62bf('0x21')](respondWithResult(_0x2d30a3,null))[_0x62bf('0x44')](handleError(_0x2d30a3,null));};exports[_0x62bf('0x25')]=function(_0x553254,_0x1fa210){return db[_0x62bf('0x2c')][_0x62bf('0x48')]({'where':{'id':_0x553254[_0x62bf('0x51')]['id']}})[_0x62bf('0x21')](handleEntityNotFound(_0x1fa210,null))[_0x62bf('0x21')](removeEntity(_0x1fa210,null))[_0x62bf('0x44')](handleError(_0x1fa210,null));};exports[_0x62bf('0x52')]=function(_0x17a930,_0x5ee23c){var _0x370eb2=0xa;var _0x57713a=[_0x62bf('0x53'),'left_join',_0x62bf('0x54'),'cross_join'];var _0x4eee79={'SUM':_0x62bf('0x55'),'COUNT':_0x62bf('0x56'),'COUNT DISTINCT':_0x62bf('0x57'),'MAX':_0x62bf('0x58'),'MIN':_0x62bf('0x59'),'AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x351520={'SEC_TO_TIME':_0x62bf('0x5a'),'DATE':_0x62bf('0x5b'),'HOUR':'HOUR(%s)','ROUND':_0x62bf('0x5c'),'UNIX_TIMESTAMP':_0x62bf('0x5d')};var _0x21472b=function(_0x4bba9f){return!_['includes']([_0x62bf('0x5e'),_0x62bf('0x5f'),_0x62bf('0x60'),_0x62bf('0x61')],_0x4bba9f);};var _0xa07fbe=function(_0x4dc423){if(!_0x4dc423||!_0x4dc423[_0x62bf('0x62')][_0x62bf('0x37')]){return'';}for(var _0x3dd2bc='(',_0x52e537=0x0;_0x52e537<_0x4dc423[_0x62bf('0x62')][_0x62bf('0x37')];_0x52e537+=0x1){_0x52e537>0x0&&(_0x3dd2bc+='\x20'+_0x4dc423[_0x62bf('0x63')]+'\x20');_0x3dd2bc+=_0x4dc423['rules'][_0x52e537][_0x62bf('0x64')]?_0xa07fbe(_0x4dc423[_0x62bf('0x62')][_0x52e537][_0x62bf('0x64')]):_0x4dc423[_0x62bf('0x62')][_0x52e537][_0x62bf('0x65')]+'\x20'+_0x4dc423['rules'][_0x52e537]['condition']+(_0x21472b(_0x4dc423[_0x62bf('0x62')][_0x52e537][_0x62bf('0x66')])?'\x20'+_0x4dc423[_0x62bf('0x62')][_0x52e537][_0x62bf('0x67')]:'');}return _0x3dd2bc+')';};var _0x5635d1={'where':{'id':_0x17a930['params']['id']}},_0xe5d024,_0x1db842,_0x2419df,_0x4d11ae,_0x105fa1;_0x5635d1=_[_0x62bf('0x3f')]({},_0x5635d1,_0x17a930[_0x62bf('0x41')]);return db[_0x62bf('0x2c')][_0x62bf('0x48')](_0x5635d1)[_0x62bf('0x21')](function(_0x5aa7a0){if(_0x5aa7a0){_0xe5d024=_0x5aa7a0;return _0x5aa7a0[_0x62bf('0x68')]();}return null;})[_0x62bf('0x21')](function(_0x183f7b){if(_0x183f7b){if(!_0x183f7b[_0x62bf('0x37')]){throw new db['Sequelize'][(_0x62bf('0x69'))](_0x62bf('0x6a'),0x193);}_0x1db842=_0x183f7b;return db[_0x62bf('0x6b')][_0x62bf('0x6c')]({'raw':!![]});}return null;})[_0x62bf('0x21')](function(_0x2ff772){if(_0x2ff772){_0x2419df=_[_0x62bf('0x6d')](_0x2ff772,'id');var _0x552055;var _0x2e46dc=squel[_0x62bf('0x6e')]();_0x2e46dc['from'](_0xe5d024[_0x62bf('0x6f')]);for(var _0x2f3f81=0x0;_0x2f3f81<_0x1db842[_0x62bf('0x37')];_0x2f3f81+=0x1){_0x552055=_0x1db842[_0x2f3f81][_0x62bf('0x70')]?_0x2419df[_0x1db842[_0x2f3f81]['MetricId']]['metric']:_0x1db842[_0x2f3f81][_0x62bf('0x65')];_0x552055=_0x1db842[_0x2f3f81][_0x62bf('0x71')]?_[_0x62bf('0x72')](_0x4eee79[_0x1db842[_0x2f3f81][_0x62bf('0x71')]],'%s',_0x552055):_0x552055;_0x552055=_0x1db842[_0x2f3f81][_0x62bf('0x73')]?_[_0x62bf('0x72')](_0x351520[_0x1db842[_0x2f3f81]['format']],'%s',_0x552055):_0x552055;if(_0x1db842[_0x2f3f81][_0x62bf('0x74')]){_0x2e46dc[_0x62bf('0x64')](_0x552055);}_0x1db842[_0x2f3f81][_0x62bf('0x75')]&&_0x2e46dc['order'](_0x552055,_0x1db842[_0x2f3f81][_0x62bf('0x75')]===_0x62bf('0x76')?![]:!![]);_0x2e46dc['field'](_0x552055,_0x1db842[_0x2f3f81][_0x62bf('0x77')]||_0x552055);}if(_0xe5d024[_0x62bf('0x78')]){_0xe5d024[_0x62bf('0x78')]=JSON[_0x62bf('0x79')](_0xe5d024[_0x62bf('0x78')]);for(var _0x2f0c1b=0x0;_0x2f0c1b<_0xe5d024[_0x62bf('0x78')]['length'];_0x2f0c1b+=0x1){if(_0xe5d024[_0x62bf('0x78')][_0x2f0c1b][_0x62bf('0x2f')]&&_[_0x62bf('0x7a')](_0x57713a,_0xe5d024['joins'][_0x2f0c1b][_0x62bf('0x2f')])&&_0xe5d024[_0x62bf('0x78')][_0x2f0c1b]['parentKey']&&_0xe5d024[_0x62bf('0x78')][_0x2f0c1b][_0x62bf('0x7b')]&&_0xe5d024[_0x62bf('0x78')][_0x2f0c1b][_0x62bf('0x7c')]){_0x2e46dc[_0xe5d024[_0x62bf('0x78')][_0x2f0c1b][_0x62bf('0x2f')]](_0xe5d024['joins'][_0x2f0c1b]['foreignTable'],null,util['format'](_0x62bf('0x7d'),_0xe5d024[_0x62bf('0x6f')],_0xe5d024[_0x62bf('0x78')][_0x2f0c1b]['parentKey'],_0xe5d024['joins'][_0x2f0c1b][_0x62bf('0x7b')],_0xe5d024[_0x62bf('0x78')][_0x2f0c1b][_0x62bf('0x7c')]));}}}if(_0xe5d024[_0x62bf('0x7e')]){_0xe5d024[_0x62bf('0x7e')]=JSON[_0x62bf('0x79')](_0xe5d024['conditions']);_0x2e46dc[_0x62bf('0x3c')](_0xa07fbe(_0xe5d024[_0x62bf('0x7e')]['group']));}_0x105fa1=_0x2e46dc[_0x62bf('0x7f')]();_0x2e46dc[_0x62bf('0x1c')](_0x370eb2);_0x2e46dc[_0x62bf('0x1b')](0x0);logger['debug'](_0x62bf('0x80'),_0x2e46dc[_0x62bf('0x81')]());return dbH[_0x62bf('0x82')][_0x62bf('0x33')](_0x2e46dc[_0x62bf('0x81')](),{'type':dbH[_0x62bf('0x82')][_0x62bf('0x83')][_0x62bf('0x84')]});}})['then'](respondWithResult(_0x5ee23c,null))[_0x62bf('0x44')](handleError(_0x5ee23c,null));};function runReport(_0x195eb0,_0x23d927,_0x560fa5){var _0x505566=_0x23d927[_0x62bf('0x28')];var _0x47cd57=0xa;var _0x56c7e8=[_0x62bf('0x53'),_0x62bf('0x85'),_0x62bf('0x54'),_0x62bf('0x86')];var _0x5b21e2={'SUM':_0x62bf('0x55'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x62bf('0x57'),'MAX':_0x62bf('0x58'),'MIN':_0x62bf('0x59'),'AVG':_0x62bf('0x87'),'GROUP_CONCAT':_0x62bf('0x88'),'GROUP_CONCAT ASC':_0x62bf('0x89'),'GROUP_CONCAT DESC':_0x62bf('0x8a')};var _0x2765fa={'SEC_TO_TIME':_0x62bf('0x5a'),'DATE':'DATE(%s)','HOUR':_0x62bf('0x8b'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x62bf('0x5d')};var _0x5789e0=function(_0x580f17){return!_[_0x62bf('0x7a')]([_0x62bf('0x5e'),_0x62bf('0x5f'),_0x62bf('0x60'),_0x62bf('0x61')],_0x580f17);};var _0x45cad1=function(_0x38891c){if(!_0x38891c||!_0x38891c[_0x62bf('0x62')][_0x62bf('0x37')]){return'';}for(var _0x4842d5='(',_0x2cefb1=0x0;_0x2cefb1<_0x38891c[_0x62bf('0x62')][_0x62bf('0x37')];_0x2cefb1+=0x1){_0x2cefb1>0x0&&(_0x4842d5+='\x20'+_0x38891c[_0x62bf('0x63')]+'\x20');_0x4842d5+=_0x38891c['rules'][_0x2cefb1]['group']?_0x45cad1(_0x38891c[_0x62bf('0x62')][_0x2cefb1][_0x62bf('0x64')]):_0x38891c[_0x62bf('0x62')][_0x2cefb1][_0x62bf('0x65')]+'\x20'+_0x38891c[_0x62bf('0x62')][_0x2cefb1][_0x62bf('0x66')]+(_0x5789e0(_0x38891c['rules'][_0x2cefb1][_0x62bf('0x66')])?'\x20'+_0x38891c['rules'][_0x2cefb1][_0x62bf('0x67')]:'');}return _0x4842d5+')';};var _0x273ca0={'where':{'id':_0x195eb0['id']}},_0x27409f,_0xda2d93,_0x5daf75,_0x3e6397,_0x2f4c0b;_0x273ca0=_[_0x62bf('0x3f')]({},_0x273ca0,_0x560fa5);return db['AnalyticDefaultReport'][_0x62bf('0x48')](_0x273ca0)[_0x62bf('0x21')](function(_0x1aa0c5){if(_0x1aa0c5){_0x27409f=_0x1aa0c5;return _0x1aa0c5[_0x62bf('0x68')]();}return null;})[_0x62bf('0x21')](function(_0x4b45e5){if(_0x4b45e5){if(!_0x4b45e5[_0x62bf('0x37')]){throw new db['Sequelize'][(_0x62bf('0x69'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0xda2d93=_0x4b45e5;return db[_0x62bf('0x6b')][_0x62bf('0x6c')]({'raw':!![]});}return null;})['then'](function(_0xf43fa7){if(_0xf43fa7){_0x5daf75=_[_0x62bf('0x6d')](_0xf43fa7,'id');var _0x5b2845;var _0x2e8ca2=squel[_0x62bf('0x6e')]();_0x2e8ca2[_0x62bf('0x8c')](_0x27409f[_0x62bf('0x6f')]);for(var _0x413beb=0x0;_0x413beb<_0xda2d93['length'];_0x413beb+=0x1){_0x5b2845=_0xda2d93[_0x413beb][_0x62bf('0x70')]?_0x5daf75[_0xda2d93[_0x413beb][_0x62bf('0x70')]]['metric']:_0xda2d93[_0x413beb][_0x62bf('0x65')];_0x5b2845=_0xda2d93[_0x413beb][_0x62bf('0x71')]?_[_0x62bf('0x72')](_0x5b21e2[_0xda2d93[_0x413beb][_0x62bf('0x71')]],'%s',_0x5b2845):_0x5b2845;_0x5b2845=_0xda2d93[_0x413beb]['format']?_['replace'](_0x2765fa[_0xda2d93[_0x413beb][_0x62bf('0x73')]],'%s',_0x5b2845):_0x5b2845;if(_0xda2d93[_0x413beb]['groupBy']){_0x2e8ca2[_0x62bf('0x64')](_0x5b2845);}_0xda2d93[_0x413beb]['orderBy']&&_0x2e8ca2[_0x62bf('0x3a')](_0x5b2845,_0xda2d93[_0x413beb][_0x62bf('0x75')]==='DESC'?![]:!![]);_0x2e8ca2[_0x62bf('0x65')](_0x5b2845,_0xda2d93[_0x413beb][_0x62bf('0x77')]||_0x5b2845);}if(_0x27409f['joins']){_0x27409f[_0x62bf('0x78')]=JSON[_0x62bf('0x79')](_0x27409f[_0x62bf('0x78')]);for(var _0x44a009=0x0;_0x44a009<_0x27409f[_0x62bf('0x78')][_0x62bf('0x37')];_0x44a009+=0x1){if(_0x27409f[_0x62bf('0x78')][_0x44a009][_0x62bf('0x2f')]&&_['includes'](_0x56c7e8,_0x27409f[_0x62bf('0x78')][_0x44a009][_0x62bf('0x2f')])&&_0x27409f['joins'][_0x44a009]['parentKey']&&_0x27409f[_0x62bf('0x78')][_0x44a009][_0x62bf('0x7b')]&&_0x27409f['joins'][_0x44a009][_0x62bf('0x7c')]){_0x2e8ca2[_0x27409f['joins'][_0x44a009]['type']](_0x27409f[_0x62bf('0x78')][_0x44a009]['foreignTable'],null,util['format'](_0x62bf('0x7d'),_0x27409f[_0x62bf('0x6f')],_0x27409f[_0x62bf('0x78')][_0x44a009][_0x62bf('0x8d')],_0x27409f[_0x62bf('0x78')][_0x44a009][_0x62bf('0x7b')],_0x27409f['joins'][_0x44a009]['foreignKey']));}}}if(_0x27409f[_0x62bf('0x7e')]){_0x27409f[_0x62bf('0x7e')]=JSON['parse'](_0x27409f['conditions']);_0x2e8ca2[_0x62bf('0x3c')](_0x45cad1(_0x27409f[_0x62bf('0x7e')][_0x62bf('0x64')]));}_0x2f4c0b=_0x2e8ca2[_0x62bf('0x7f')]();_0x2e8ca2[_0x62bf('0x1c')](_0x47cd57);_0x2e8ca2[_0x62bf('0x1b')](0x0);return;}})['then'](function(){if(_0x23d927[_0x62bf('0x8e')]===_0x62bf('0x8f')){return null;}var _0x56d091=_[_0x62bf('0x3f')](_0x23d927,{'name':_0x23d927['fullPath']||_0x23d927['name']||_0x27409f[_0x62bf('0x28')],'basename':_0x505566,'savename':util[_0x62bf('0x73')](_0x62bf('0x90'),_0x23d927[_0x62bf('0x28')]||_0x27409f['name'],require(_0x62bf('0x91'))['generate'](0x4),_0x23d927[_0x62bf('0x8e')]||'csv'),'reportId':_0x27409f['id'],'reportType':'default'});return db[_0x62bf('0x92')][_0x62bf('0x49')](_0x56d091,{'raw':!![]});})[_0x62bf('0x21')](function(_0x511a42){if(_0x27409f[_0x62bf('0x6f')]===_0x62bf('0x93')){_0x2f4c0b[_0x62bf('0x3c')](_0x27409f[_0x62bf('0x6f')]+_0x62bf('0x94'),_0x23d927[_0x62bf('0x95')],_0x23d927[_0x62bf('0x96')]);}else{_0x2f4c0b['where'](_0x27409f[_0x62bf('0x6f')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x23d927[_0x62bf('0x95')],_0x23d927['endDate']);}if(_0x511a42){logger[_0x62bf('0x97')](_0x62bf('0x98'),_0x2f4c0b[_0x62bf('0x81')]());require(_0x62bf('0x99'))[_0x62bf('0x9a')](path[_0x62bf('0x53')](__dirname,_0x62bf('0x9b'),_0x511a42['output']),[_0x511a42['id'],_0x2f4c0b['toString'](),path[_0x62bf('0x53')](__dirname,_0x62bf('0x9c'),_0x511a42[_0x62bf('0x9d')]),_0x505566]);return _0x511a42;}else{var _0x670888=squel['select']();_0x670888[_0x62bf('0x8c')]('('+_0x2f4c0b[_0x62bf('0x81')]()+')',_0x62bf('0x9e'));_0x670888[_0x62bf('0x65')]('COUNT(*)','count');_0x2f4c0b[_0x62bf('0x1c')](_0x23d927[_0x62bf('0x1c')]||_0x47cd57);_0x2f4c0b[_0x62bf('0x1b')](_0x23d927['offset']||0x0);return dbH[_0x62bf('0x82')][_0x62bf('0x33')](_0x670888[_0x62bf('0x81')](),{'type':dbH[_0x62bf('0x82')][_0x62bf('0x83')][_0x62bf('0x84')]})[_0x62bf('0x21')](function(_0x1aee2e){if(!_0x1aee2e[_0x62bf('0x37')]){_0x3e6397=0x0;}else{_0x3e6397=_0x1aee2e[0x0][_0x62bf('0x1a')]||0x0;}return dbH[_0x62bf('0x82')][_0x62bf('0x33')](_0x2f4c0b['toString'](),{'type':dbH[_0x62bf('0x82')][_0x62bf('0x83')][_0x62bf('0x84')]});})[_0x62bf('0x21')](function(_0x1e9b94){return{'rows':_0x1e9b94||[],'count':_0x3e6397};});}});}exports[_0x62bf('0x9f')]=function(_0x241a12,_0x21b88d){return runReport(_0x241a12[_0x62bf('0x51')],_0x241a12[_0x62bf('0x33')],_0x241a12[_0x62bf('0x41')])[_0x62bf('0x21')](respondWithResult(_0x21b88d,null))[_0x62bf('0x44')](handleError(_0x21b88d,null));};exports[_0x62bf('0xa0')]=runReport;exports[_0x62bf('0x33')]=function(_0x4bd31a,_0x326ced){var _0x1d7de8=0xa;var _0x276063=[_0x62bf('0x53'),_0x62bf('0x85'),'right_join',_0x62bf('0x86')];var _0x2db324={'SUM':'SUM(%s)','COUNT':_0x62bf('0x56'),'COUNT DISTINCT':_0x62bf('0x57'),'MAX':_0x62bf('0x58'),'MIN':_0x62bf('0x59'),'AVG':_0x62bf('0x87'),'GROUP_CONCAT':_0x62bf('0x88'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x62bf('0x8a')};var _0x5e7ca7={'SEC_TO_TIME':_0x62bf('0x5a'),'DATE':'DATE(%s)','HOUR':'HOUR(%s)','ROUND':_0x62bf('0x5c'),'UNIX_TIMESTAMP':_0x62bf('0x5d')};var _0x2e78c4=function(_0x4604e9){return!_['includes'](['IS\x20NULL',_0x62bf('0x5f'),_0x62bf('0x60'),_0x62bf('0x61')],_0x4604e9);};var _0x4be261=function(_0x23cb37){if(!_0x23cb37||!_0x23cb37[_0x62bf('0x62')][_0x62bf('0x37')]){return'';}for(var _0x40fac4='(',_0x73f21b=0x0;_0x73f21b<_0x23cb37['rules'][_0x62bf('0x37')];_0x73f21b+=0x1){_0x73f21b>0x0&&(_0x40fac4+='\x20'+_0x23cb37[_0x62bf('0x63')]+'\x20');_0x40fac4+=_0x23cb37[_0x62bf('0x62')][_0x73f21b]['group']?_0x4be261(_0x23cb37[_0x62bf('0x62')][_0x73f21b][_0x62bf('0x64')]):_0x23cb37[_0x62bf('0x62')][_0x73f21b][_0x62bf('0x65')]+'\x20'+_0x23cb37['rules'][_0x73f21b][_0x62bf('0x66')]+(_0x2e78c4(_0x23cb37[_0x62bf('0x62')][_0x73f21b]['condition'])?'\x20'+_0x23cb37[_0x62bf('0x62')][_0x73f21b][_0x62bf('0x67')]:'');}return _0x40fac4+')';};var _0x140bbd={'where':{'id':_0x4bd31a[_0x62bf('0x51')]['id']}},_0x110a95,_0x1a86f9,_0x464aa8,_0xcbc30c,_0x2f5a32;_0x140bbd=_[_0x62bf('0x3f')]({},_0x140bbd,_0x4bd31a[_0x62bf('0x41')]);return db[_0x62bf('0x2c')]['find'](_0x140bbd)[_0x62bf('0x21')](function(_0x4eefb7){if(_0x4eefb7){_0x110a95=_0x4eefb7;return _0x4eefb7[_0x62bf('0x68')]();}return null;})[_0x62bf('0x21')](function(_0x101696){if(_0x101696){if(!_0x101696[_0x62bf('0x37')]){throw new db[(_0x62bf('0xa1'))][(_0x62bf('0x69'))](_0x62bf('0x6a'),0x193);}_0x1a86f9=_0x101696;return db[_0x62bf('0x6b')][_0x62bf('0x6c')]({'raw':!![]});}return null;})[_0x62bf('0x21')](function(_0xd31eb6){if(_0xd31eb6){_0x464aa8=_['keyBy'](_0xd31eb6,'id');var _0x33f147;var _0x5aea74=squel['select']();_0x5aea74[_0x62bf('0x8c')](_0x110a95[_0x62bf('0x6f')]);for(var _0x2aeb23=0x0;_0x2aeb23<_0x1a86f9[_0x62bf('0x37')];_0x2aeb23+=0x1){_0x33f147=_0x1a86f9[_0x2aeb23][_0x62bf('0x70')]?_0x464aa8[_0x1a86f9[_0x2aeb23][_0x62bf('0x70')]]['metric']:_0x1a86f9[_0x2aeb23][_0x62bf('0x65')];_0x33f147=_0x1a86f9[_0x2aeb23][_0x62bf('0x71')]?_['replace'](_0x2db324[_0x1a86f9[_0x2aeb23][_0x62bf('0x71')]],'%s',_0x33f147):_0x33f147;_0x33f147=_0x1a86f9[_0x2aeb23][_0x62bf('0x73')]?_[_0x62bf('0x72')](_0x5e7ca7[_0x1a86f9[_0x2aeb23][_0x62bf('0x73')]],'%s',_0x33f147):_0x33f147;if(_0x1a86f9[_0x2aeb23][_0x62bf('0x74')]){_0x5aea74[_0x62bf('0x64')](_0x33f147);}_0x1a86f9[_0x2aeb23][_0x62bf('0x75')]&&_0x5aea74[_0x62bf('0x3a')](_0x33f147,_0x1a86f9[_0x2aeb23]['orderBy']==='DESC'?![]:!![]);_0x5aea74[_0x62bf('0x65')](_0x33f147,_0x1a86f9[_0x2aeb23][_0x62bf('0x77')]||_0x33f147);}if(_0x110a95[_0x62bf('0x78')]){_0x110a95[_0x62bf('0x78')]=JSON[_0x62bf('0x79')](_0x110a95['joins']);for(var _0x2dbfe0=0x0;_0x2dbfe0<_0x110a95[_0x62bf('0x78')][_0x62bf('0x37')];_0x2dbfe0+=0x1){if(_0x110a95[_0x62bf('0x78')][_0x2dbfe0][_0x62bf('0x2f')]&&_[_0x62bf('0x7a')](_0x276063,_0x110a95['joins'][_0x2dbfe0][_0x62bf('0x2f')])&&_0x110a95['joins'][_0x2dbfe0][_0x62bf('0x8d')]&&_0x110a95['joins'][_0x2dbfe0]['foreignTable']&&_0x110a95[_0x62bf('0x78')][_0x2dbfe0][_0x62bf('0x7c')]){_0x5aea74[_0x110a95[_0x62bf('0x78')][_0x2dbfe0][_0x62bf('0x2f')]](_0x110a95[_0x62bf('0x78')][_0x2dbfe0][_0x62bf('0x7b')],null,util['format'](_0x62bf('0x7d'),_0x110a95[_0x62bf('0x6f')],_0x110a95[_0x62bf('0x78')][_0x2dbfe0]['parentKey'],_0x110a95[_0x62bf('0x78')][_0x2dbfe0][_0x62bf('0x7b')],_0x110a95[_0x62bf('0x78')][_0x2dbfe0]['foreignKey']));}}}if(_0x110a95[_0x62bf('0x7e')]){_0x110a95['conditions']=JSON[_0x62bf('0x79')](_0x110a95['conditions']);_0x5aea74[_0x62bf('0x3c')](_0x4be261(_0x110a95[_0x62bf('0x7e')][_0x62bf('0x64')]));}_0x2f5a32=_0x5aea74[_0x62bf('0x7f')]();_0x5aea74[_0x62bf('0x1c')](_0x1d7de8);_0x5aea74['offset'](0x0);logger[_0x62bf('0xa2')](_0x62bf('0x80'),_0x5aea74['toString']());return dbH['sequelize'][_0x62bf('0x33')](_0x5aea74[_0x62bf('0x81')](),{'type':dbH[_0x62bf('0x82')][_0x62bf('0x83')][_0x62bf('0x84')]});}})[_0x62bf('0x21')](function(){return{'sql':_0x2f5a32[_0x62bf('0x81')]()};})['then'](respondWithResult(_0x326ced,null))[_0x62bf('0x44')](handleError(_0x326ced,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