Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index fb82e78..80ec0d5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5cff=['fast-json-patch','request-promise','bluebird','mustache','path','ejs','lodash','squel','jsforce','desk.js','to-csv','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','dbH','status','end','count','offset','limit','set','Content-Range','json','apply','reject','save','update','then','get','DefaultReports','UserProfileResource','destroy','sendStatus','error','stack','name','send','map','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','type','VIRTUAL','filter','merge','options','includeAll','include','AnalyticDefaultReport','findAll','rows','catch','show','params','find','create','role','user','Reports','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','preview','join','left_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','rules','operator','group','field','condition','value','getFields','Sequelize','AnalyticMetric','keyBy','select','from','table','MetricId','function','replace','format','groupBy','DESC','alias','joins','parse','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','Limited\x20Query:','toString','sequelize','QueryTypes','cross_join','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','IS\x20NOT\x20EMPTY','Please\x20insert\x20at\x20least\x20one\x20field','metric','orderBy','order','clone','output','web','fullPath','%s-%s.%s','randomstring','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','startDate','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','SELECT','run','runReport','right_join','IS\x20EMPTY','debug','html-pdf','eml-format','rimraf','zip-dir'];(function(_0x501510,_0x61caa9){var _0x1e6ee5=function(_0x32845b){while(--_0x32845b){_0x501510['push'](_0x501510['shift']());}};_0x1e6ee5(++_0x61caa9);}(_0x5cff,0xa7));var _0xf5cf=function(_0x274160,_0x5622d9){_0x274160=_0x274160-0x0;var _0x349a83=_0x5cff[_0x274160];return _0x349a83;};'use strict';var pdf=require(_0xf5cf('0x0'));var emlformat=require(_0xf5cf('0x1'));var rimraf=require(_0xf5cf('0x2'));var zipdir=require(_0xf5cf('0x3'));var jsonpatch=require(_0xf5cf('0x4'));var rp=require(_0xf5cf('0x5'));var moment=require('moment');var BPromise=require(_0xf5cf('0x6'));var Mustache=require(_0xf5cf('0x7'));var util=require('util');var path=require(_0xf5cf('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xf5cf('0x9'));var fs=require('fs');var _=require(_0xf5cf('0xa'));var squel=require(_0xf5cf('0xb'));var crypto=require('crypto');var jsforce=require(_0xf5cf('0xc'));var deskjs=require(_0xf5cf('0xd'));var toCsv=require(_0xf5cf('0xe'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xf5cf('0xf'));var authService=require(_0xf5cf('0x10'));var qs=require(_0xf5cf('0x11'));var as=require(_0xf5cf('0x12'));var hardwareService=require(_0xf5cf('0x13'));var logger=require(_0xf5cf('0x14'))(_0xf5cf('0x15'));var utils=require('../../config/utils');var config=require(_0xf5cf('0x16'));var licenseUtil=require(_0xf5cf('0x17'));var db=require('../../mysqldb')['db'];var dbH=require(_0xf5cf('0x18'))[_0xf5cf('0x19')];function respondWithStatusCode(_0x16fe3e,_0xe54145){_0xe54145=_0xe54145||0xcc;return function(_0x21d1e0){if(_0x21d1e0){return _0x16fe3e['sendStatus'](_0xe54145);}return _0x16fe3e[_0xf5cf('0x1a')](_0xe54145)[_0xf5cf('0x1b')]();};}function respondWithResult(_0x2776c6,_0x1b3bc0){_0x1b3bc0=_0x1b3bc0||0xc8;return function(_0xb00f58){if(_0xb00f58){return _0x2776c6[_0xf5cf('0x1a')](_0x1b3bc0)['json'](_0xb00f58);}};}function respondWithFilteredResult(_0x326c97,_0x746d48){return function(_0x141149){if(_0x141149){var _0x43d90f=_0x141149[_0xf5cf('0x1c')],_0x5a5ac9=_0x746d48[_0xf5cf('0x1d')],_0x40d14c=_0x746d48[_0xf5cf('0x1d')]+_0x746d48[_0xf5cf('0x1e')],_0x1c9b14;if(_0x40d14c>=_0x43d90f){_0x40d14c=_0x43d90f;_0x1c9b14=0xc8;}else{_0x1c9b14=0xce;}_0x326c97[_0xf5cf('0x1a')](_0x1c9b14);return _0x326c97[_0xf5cf('0x1f')](_0xf5cf('0x20'),_0x5a5ac9+'-'+_0x40d14c+'/'+_0x43d90f)[_0xf5cf('0x21')](_0x141149);}return null;};}function patchUpdates(_0x417d1f){return function(_0x3ce3de){try{jsonpatch[_0xf5cf('0x22')](_0x3ce3de,_0x417d1f,!![]);}catch(_0x51648e){return BPromise[_0xf5cf('0x23')](_0x51648e);}return _0x3ce3de[_0xf5cf('0x24')]();};}function saveUpdates(_0xe65453,_0x38ad09){return function(_0x3b54bc){if(_0x3b54bc){return _0x3b54bc[_0xf5cf('0x25')](_0xe65453)[_0xf5cf('0x26')](function(_0x1d2ac0){return _0x1d2ac0;});}return null;};}function removeEntity(_0x358078,_0x4fb80f){return function(_0x1ab4e6){if(_0x1ab4e6){return _0x1ab4e6['destroy']()[_0xf5cf('0x26')](function(){var _0x3d0b97=_0x1ab4e6[_0xf5cf('0x27')]({'plain':!![]});var _0x320606=_0xf5cf('0x28');return db[_0xf5cf('0x29')][_0xf5cf('0x2a')]({'where':{'type':_0x320606,'resourceId':_0x3d0b97['id']}})['then'](function(){return _0x1ab4e6;});})[_0xf5cf('0x26')](function(){_0x358078[_0xf5cf('0x1a')](0xcc)[_0xf5cf('0x1b')]();});}};}function handleEntityNotFound(_0x28b8b6,_0x204383){return function(_0x3adac2){if(!_0x3adac2){_0x28b8b6[_0xf5cf('0x2b')](0x194);}return _0x3adac2;};}function handleError(_0x1e7e23,_0x5ae124){_0x5ae124=_0x5ae124||0x1f4;return function(_0x18d682){logger[_0xf5cf('0x2c')](_0x18d682[_0xf5cf('0x2d')]);if(_0x18d682[_0xf5cf('0x2e')]){delete _0x18d682[_0xf5cf('0x2e')];}_0x1e7e23[_0xf5cf('0x1a')](_0x5ae124)[_0xf5cf('0x2f')](_0x18d682);};}exports['index']=function(_0xf860ce,_0x237935){var _0x286691={},_0x27aaea={},_0x2218e8={'count':0x0,'rows':[]};var _0x43ba34=_[_0xf5cf('0x30')](db['AnalyticDefaultReport'][_0xf5cf('0x31')],function(_0x503d43){return{'name':_0x503d43[_0xf5cf('0x32')],'type':_0x503d43['type'][_0xf5cf('0x33')]};});_0x27aaea[_0xf5cf('0x34')]=_[_0xf5cf('0x30')](_0x43ba34,_0xf5cf('0x2e'));_0x27aaea[_0xf5cf('0x35')]=_[_0xf5cf('0x36')](_0xf860ce[_0xf5cf('0x35')]);_0x27aaea[_0xf5cf('0x37')]=_['intersection'](_0x27aaea[_0xf5cf('0x34')],_0x27aaea[_0xf5cf('0x35')]);_0x286691[_0xf5cf('0x38')]=_[_0xf5cf('0x39')](_0x27aaea[_0xf5cf('0x34')],qs[_0xf5cf('0x3a')](_0xf860ce[_0xf5cf('0x35')][_0xf5cf('0x3a')]));_0x286691[_0xf5cf('0x38')]=_0x286691[_0xf5cf('0x38')][_0xf5cf('0x3b')]?_0x286691['attributes']:_0x27aaea[_0xf5cf('0x34')];if(!_0xf860ce[_0xf5cf('0x35')][_0xf5cf('0x3c')](_0xf5cf('0x3d'))){_0x286691[_0xf5cf('0x1e')]=qs[_0xf5cf('0x1e')](_0xf860ce[_0xf5cf('0x35')][_0xf5cf('0x1e')]);_0x286691[_0xf5cf('0x1d')]=qs['offset'](_0xf860ce['query'][_0xf5cf('0x1d')]);}_0x286691['order']=qs['sort'](_0xf860ce[_0xf5cf('0x35')][_0xf5cf('0x3e')]);_0x286691[_0xf5cf('0x3f')]=qs[_0xf5cf('0x37')](_['pick'](_0xf860ce[_0xf5cf('0x35')],_0x27aaea[_0xf5cf('0x37')]),_0x43ba34);if(_0xf860ce[_0xf5cf('0x35')]['filter']){_0x286691['where']=_['merge'](_0x286691[_0xf5cf('0x3f')],{'$or':_[_0xf5cf('0x30')](_0x43ba34,function(_0x378ab1){if(_0x378ab1[_0xf5cf('0x40')]!==_0xf5cf('0x41')){var _0x2b833c={};_0x2b833c[_0x378ab1['name']]={'$like':'%'+_0xf860ce[_0xf5cf('0x35')][_0xf5cf('0x42')]+'%'};return _0x2b833c;}})});}_0x286691=_[_0xf5cf('0x43')]({},_0x286691,_0xf860ce[_0xf5cf('0x44')]);var _0x560cfb={'where':_0x286691[_0xf5cf('0x3f')]};return db['AnalyticDefaultReport'][_0xf5cf('0x1c')](_0x560cfb)[_0xf5cf('0x26')](function(_0x3725f3){_0x2218e8[_0xf5cf('0x1c')]=_0x3725f3;if(_0xf860ce[_0xf5cf('0x35')][_0xf5cf('0x45')]){_0x286691[_0xf5cf('0x46')]=[{'all':!![]}];}return db[_0xf5cf('0x47')][_0xf5cf('0x48')](_0x286691);})['then'](function(_0x3fe0ac){_0x2218e8[_0xf5cf('0x49')]=_0x3fe0ac;return _0x2218e8;})[_0xf5cf('0x26')](respondWithFilteredResult(_0x237935,_0x286691))[_0xf5cf('0x4a')](handleError(_0x237935,null));};exports[_0xf5cf('0x4b')]=function(_0x23af14,_0x28a997){var _0x54a6d6={'raw':!![],'where':{'id':_0x23af14[_0xf5cf('0x4c')]['id']}},_0x4a01c6={};_0x4a01c6[_0xf5cf('0x34')]=_[_0xf5cf('0x36')](db['AnalyticDefaultReport'][_0xf5cf('0x31')]);_0x4a01c6[_0xf5cf('0x35')]=_[_0xf5cf('0x36')](_0x23af14[_0xf5cf('0x35')]);_0x4a01c6[_0xf5cf('0x37')]=_['intersection'](_0x4a01c6[_0xf5cf('0x34')],_0x4a01c6[_0xf5cf('0x35')]);_0x54a6d6[_0xf5cf('0x38')]=_['intersection'](_0x4a01c6[_0xf5cf('0x34')],qs['fields'](_0x23af14['query'][_0xf5cf('0x3a')]));_0x54a6d6['attributes']=_0x54a6d6[_0xf5cf('0x38')][_0xf5cf('0x3b')]?_0x54a6d6[_0xf5cf('0x38')]:_0x4a01c6[_0xf5cf('0x34')];if(_0x23af14[_0xf5cf('0x35')]['includeAll']){_0x54a6d6[_0xf5cf('0x46')]=[{'all':!![]}];}_0x54a6d6=_[_0xf5cf('0x43')]({},_0x54a6d6,_0x23af14[_0xf5cf('0x44')]);return db[_0xf5cf('0x47')][_0xf5cf('0x4d')](_0x54a6d6)[_0xf5cf('0x26')](handleEntityNotFound(_0x28a997,null))[_0xf5cf('0x26')](respondWithResult(_0x28a997,null))['catch'](handleError(_0x28a997,null));};exports['create']=function(_0x25af72,_0x3f6fde){return db[_0xf5cf('0x47')][_0xf5cf('0x4e')](_0x25af72['body'],{})['then'](function(_0x440390){var _0x34400a=_0x25af72['user'][_0xf5cf('0x27')]({'plain':!![]});if(!_0x34400a)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x34400a[_0xf5cf('0x4f')]===_0xf5cf('0x50')){var _0x16119a=_0x440390[_0xf5cf('0x27')]({'plain':!![]});var _0xc43210=_0xf5cf('0x51');return db[_0xf5cf('0x52')]['find']({'where':{'name':_0xc43210,'userProfileId':_0x34400a[_0xf5cf('0x53')]},'raw':!![]})[_0xf5cf('0x26')](function(_0x3401b5){if(_0x3401b5&&_0x3401b5[_0xf5cf('0x54')]===0x0){return db[_0xf5cf('0x29')][_0xf5cf('0x4e')]({'name':_0x16119a[_0xf5cf('0x2e')],'resourceId':_0x16119a['id'],'type':'DefaultReports','sectionId':_0x3401b5['id']},{})[_0xf5cf('0x26')](function(){return _0x440390;});}else{return _0x440390;}})['catch'](function(_0x44eda3){logger[_0xf5cf('0x2c')](_0xf5cf('0x55'),_0x44eda3);throw _0x44eda3;});}return _0x440390;})[_0xf5cf('0x26')](respondWithResult(_0x3f6fde,0xc9))[_0xf5cf('0x4a')](handleError(_0x3f6fde,null));};exports['update']=function(_0x5d92c6,_0x3bf4fb){if(_0x5d92c6[_0xf5cf('0x56')]['id']){delete _0x5d92c6['body']['id'];}return db['AnalyticDefaultReport'][_0xf5cf('0x4d')]({'where':{'id':_0x5d92c6[_0xf5cf('0x4c')]['id']}})[_0xf5cf('0x26')](handleEntityNotFound(_0x3bf4fb,null))['then'](saveUpdates(_0x5d92c6[_0xf5cf('0x56')],null))[_0xf5cf('0x26')](respondWithResult(_0x3bf4fb,null))[_0xf5cf('0x4a')](handleError(_0x3bf4fb,null));};exports[_0xf5cf('0x2a')]=function(_0x74c89a,_0x1276e6){return db[_0xf5cf('0x47')][_0xf5cf('0x4d')]({'where':{'id':_0x74c89a[_0xf5cf('0x4c')]['id']}})[_0xf5cf('0x26')](handleEntityNotFound(_0x1276e6,null))[_0xf5cf('0x26')](removeEntity(_0x1276e6,null))['catch'](handleError(_0x1276e6,null));};exports[_0xf5cf('0x57')]=function(_0x4c52cb,_0x1a3a5d){var _0x5baf17=0xa;var _0x266ee0=[_0xf5cf('0x58'),_0xf5cf('0x59'),'right_join','cross_join'];var _0x3f67d2={'SUM':_0xf5cf('0x5a'),'COUNT':_0xf5cf('0x5b'),'COUNT DISTINCT':_0xf5cf('0x5c'),'MAX':_0xf5cf('0x5d'),'MIN':_0xf5cf('0x5e'),'AVG':_0xf5cf('0x5f'),'GROUP_CONCAT':_0xf5cf('0x60'),'GROUP_CONCAT ASC':_0xf5cf('0x61'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x478ede={'SEC_TO_TIME':_0xf5cf('0x62'),'DATE':_0xf5cf('0x63'),'HOUR':_0xf5cf('0x64'),'ROUND':_0xf5cf('0x65'),'UNIX_TIMESTAMP':_0xf5cf('0x66')};var _0x45a89e=function(_0x409aae){return!_[_0xf5cf('0x67')]([_0xf5cf('0x68'),_0xf5cf('0x69'),'IS\x20EMPTY','IS\x20NOT\x20EMPTY'],_0x409aae);};var _0x5047b8=function(_0x58a996){if(!_0x58a996||!_0x58a996[_0xf5cf('0x6a')][_0xf5cf('0x3b')]){return'';}for(var _0x48636b='(',_0x1e01cf=0x0;_0x1e01cf<_0x58a996[_0xf5cf('0x6a')]['length'];_0x1e01cf+=0x1){_0x1e01cf>0x0&&(_0x48636b+='\x20'+_0x58a996[_0xf5cf('0x6b')]+'\x20');_0x48636b+=_0x58a996[_0xf5cf('0x6a')][_0x1e01cf][_0xf5cf('0x6c')]?_0x5047b8(_0x58a996[_0xf5cf('0x6a')][_0x1e01cf][_0xf5cf('0x6c')]):_0x58a996['rules'][_0x1e01cf][_0xf5cf('0x6d')]+'\x20'+_0x58a996[_0xf5cf('0x6a')][_0x1e01cf][_0xf5cf('0x6e')]+(_0x45a89e(_0x58a996[_0xf5cf('0x6a')][_0x1e01cf][_0xf5cf('0x6e')])?'\x20'+_0x58a996['rules'][_0x1e01cf][_0xf5cf('0x6f')]:'');}return _0x48636b+')';};var _0x3c7ab1={'where':{'id':_0x4c52cb[_0xf5cf('0x4c')]['id']}},_0x2d3460,_0x163db3,_0x295201,_0x591c75,_0x369230;_0x3c7ab1=_[_0xf5cf('0x43')]({},_0x3c7ab1,_0x4c52cb[_0xf5cf('0x44')]);return db['AnalyticDefaultReport'][_0xf5cf('0x4d')](_0x3c7ab1)['then'](function(_0x2191af){if(_0x2191af){_0x2d3460=_0x2191af;return _0x2191af[_0xf5cf('0x70')]();}return null;})[_0xf5cf('0x26')](function(_0x51cff3){if(_0x51cff3){if(!_0x51cff3[_0xf5cf('0x3b')]){throw new db[(_0xf5cf('0x71'))]['ValidationErrorItem']('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x163db3=_0x51cff3;return db[_0xf5cf('0x72')][_0xf5cf('0x48')]({'raw':!![]});}return null;})[_0xf5cf('0x26')](function(_0x47f7b4){if(_0x47f7b4){_0x295201=_[_0xf5cf('0x73')](_0x47f7b4,'id');var _0x11ceb1;var _0x2eb943=squel[_0xf5cf('0x74')]();_0x2eb943[_0xf5cf('0x75')](_0x2d3460[_0xf5cf('0x76')]);for(var _0x44a7a3=0x0;_0x44a7a3<_0x163db3['length'];_0x44a7a3+=0x1){_0x11ceb1=_0x163db3[_0x44a7a3][_0xf5cf('0x77')]?_0x295201[_0x163db3[_0x44a7a3]['MetricId']]['metric']:_0x163db3[_0x44a7a3][_0xf5cf('0x6d')];_0x11ceb1=_0x163db3[_0x44a7a3][_0xf5cf('0x78')]?_[_0xf5cf('0x79')](_0x3f67d2[_0x163db3[_0x44a7a3][_0xf5cf('0x78')]],'%s',_0x11ceb1):_0x11ceb1;_0x11ceb1=_0x163db3[_0x44a7a3]['format']?_[_0xf5cf('0x79')](_0x478ede[_0x163db3[_0x44a7a3][_0xf5cf('0x7a')]],'%s',_0x11ceb1):_0x11ceb1;if(_0x163db3[_0x44a7a3][_0xf5cf('0x7b')]){_0x2eb943['group'](_0x11ceb1);}_0x163db3[_0x44a7a3]['orderBy']&&_0x2eb943['order'](_0x11ceb1,_0x163db3[_0x44a7a3]['orderBy']===_0xf5cf('0x7c')?![]:!![]);_0x2eb943[_0xf5cf('0x6d')](_0x11ceb1,_0x163db3[_0x44a7a3][_0xf5cf('0x7d')]||_0x11ceb1);}if(_0x2d3460[_0xf5cf('0x7e')]){_0x2d3460[_0xf5cf('0x7e')]=JSON[_0xf5cf('0x7f')](_0x2d3460[_0xf5cf('0x7e')]);for(var _0x1a43c2=0x0;_0x1a43c2<_0x2d3460['joins']['length'];_0x1a43c2+=0x1){if(_0x2d3460['joins'][_0x1a43c2][_0xf5cf('0x40')]&&_[_0xf5cf('0x67')](_0x266ee0,_0x2d3460[_0xf5cf('0x7e')][_0x1a43c2][_0xf5cf('0x40')])&&_0x2d3460[_0xf5cf('0x7e')][_0x1a43c2][_0xf5cf('0x80')]&&_0x2d3460[_0xf5cf('0x7e')][_0x1a43c2][_0xf5cf('0x81')]&&_0x2d3460[_0xf5cf('0x7e')][_0x1a43c2][_0xf5cf('0x82')]){_0x2eb943[_0x2d3460[_0xf5cf('0x7e')][_0x1a43c2][_0xf5cf('0x40')]](_0x2d3460['joins'][_0x1a43c2][_0xf5cf('0x81')],null,util[_0xf5cf('0x7a')](_0xf5cf('0x83'),_0x2d3460['table'],_0x2d3460[_0xf5cf('0x7e')][_0x1a43c2][_0xf5cf('0x80')],_0x2d3460[_0xf5cf('0x7e')][_0x1a43c2][_0xf5cf('0x81')],_0x2d3460[_0xf5cf('0x7e')][_0x1a43c2]['foreignKey']));}}}if(_0x2d3460[_0xf5cf('0x84')]){_0x2d3460[_0xf5cf('0x84')]=JSON[_0xf5cf('0x7f')](_0x2d3460[_0xf5cf('0x84')]);_0x2eb943[_0xf5cf('0x3f')](_0x5047b8(_0x2d3460[_0xf5cf('0x84')][_0xf5cf('0x6c')]));}_0x369230=_0x2eb943['clone']();_0x2eb943[_0xf5cf('0x1e')](_0x5baf17);_0x2eb943['offset'](0x0);logger['debug'](_0xf5cf('0x85'),_0x2eb943[_0xf5cf('0x86')]());return dbH[_0xf5cf('0x87')]['query'](_0x2eb943[_0xf5cf('0x86')](),{'type':dbH[_0xf5cf('0x87')][_0xf5cf('0x88')]['SELECT']});}})[_0xf5cf('0x26')](respondWithResult(_0x1a3a5d,null))[_0xf5cf('0x4a')](handleError(_0x1a3a5d,null));};function runReport(_0x5a6288,_0x2ca543,_0x31dbb1){var _0x2b9dfc=_0x2ca543[_0xf5cf('0x2e')];var _0x3d68e6=0xa;var _0x39dabd=['join',_0xf5cf('0x59'),'right_join',_0xf5cf('0x89')];var _0xee8be={'SUM':_0xf5cf('0x5a'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xf5cf('0x5c'),'MAX':_0xf5cf('0x5d'),'MIN':_0xf5cf('0x5e'),'AVG':_0xf5cf('0x5f'),'GROUP_CONCAT':_0xf5cf('0x60'),'GROUP_CONCAT ASC':_0xf5cf('0x61'),'GROUP_CONCAT DESC':_0xf5cf('0x8a')};var _0x4e38dc={'SEC_TO_TIME':_0xf5cf('0x62'),'DATE':_0xf5cf('0x63'),'HOUR':_0xf5cf('0x64'),'ROUND':_0xf5cf('0x65'),'UNIX_TIMESTAMP':_0xf5cf('0x66')};var _0xba8304=function(_0x172594){return!_[_0xf5cf('0x67')]([_0xf5cf('0x68'),_0xf5cf('0x69'),'IS\x20EMPTY',_0xf5cf('0x8b')],_0x172594);};var _0xcb8e60=function(_0x26737e){if(!_0x26737e||!_0x26737e['rules'][_0xf5cf('0x3b')]){return'';}for(var _0x1a584c='(',_0x4440fb=0x0;_0x4440fb<_0x26737e['rules']['length'];_0x4440fb+=0x1){_0x4440fb>0x0&&(_0x1a584c+='\x20'+_0x26737e['operator']+'\x20');_0x1a584c+=_0x26737e[_0xf5cf('0x6a')][_0x4440fb][_0xf5cf('0x6c')]?_0xcb8e60(_0x26737e[_0xf5cf('0x6a')][_0x4440fb][_0xf5cf('0x6c')]):_0x26737e[_0xf5cf('0x6a')][_0x4440fb]['field']+'\x20'+_0x26737e[_0xf5cf('0x6a')][_0x4440fb][_0xf5cf('0x6e')]+(_0xba8304(_0x26737e[_0xf5cf('0x6a')][_0x4440fb][_0xf5cf('0x6e')])?'\x20'+_0x26737e['rules'][_0x4440fb]['value']:'');}return _0x1a584c+')';};var _0x2152fb={'where':{'id':_0x5a6288['id']}},_0x29d739,_0x815caa,_0x2b47d2,_0xa6d93,_0x6a169;_0x2152fb=_[_0xf5cf('0x43')]({},_0x2152fb,_0x31dbb1);return db[_0xf5cf('0x47')][_0xf5cf('0x4d')](_0x2152fb)['then'](function(_0x4d0314){if(_0x4d0314){_0x29d739=_0x4d0314;return _0x4d0314[_0xf5cf('0x70')]();}return null;})['then'](function(_0x482c88){if(_0x482c88){if(!_0x482c88[_0xf5cf('0x3b')]){throw new db[(_0xf5cf('0x71'))]['ValidationErrorItem'](_0xf5cf('0x8c'),0x193);}_0x815caa=_0x482c88;return db[_0xf5cf('0x72')][_0xf5cf('0x48')]({'raw':!![]});}return null;})[_0xf5cf('0x26')](function(_0x244368){if(_0x244368){_0x2b47d2=_[_0xf5cf('0x73')](_0x244368,'id');var _0x531640;var _0x1d420=squel[_0xf5cf('0x74')]();_0x1d420['from'](_0x29d739[_0xf5cf('0x76')]);for(var _0x3bad43=0x0;_0x3bad43<_0x815caa[_0xf5cf('0x3b')];_0x3bad43+=0x1){_0x531640=_0x815caa[_0x3bad43][_0xf5cf('0x77')]?_0x2b47d2[_0x815caa[_0x3bad43][_0xf5cf('0x77')]][_0xf5cf('0x8d')]:_0x815caa[_0x3bad43]['field'];_0x531640=_0x815caa[_0x3bad43][_0xf5cf('0x78')]?_['replace'](_0xee8be[_0x815caa[_0x3bad43]['function']],'%s',_0x531640):_0x531640;_0x531640=_0x815caa[_0x3bad43][_0xf5cf('0x7a')]?_[_0xf5cf('0x79')](_0x4e38dc[_0x815caa[_0x3bad43][_0xf5cf('0x7a')]],'%s',_0x531640):_0x531640;if(_0x815caa[_0x3bad43]['groupBy']){_0x1d420[_0xf5cf('0x6c')](_0x531640);}_0x815caa[_0x3bad43][_0xf5cf('0x8e')]&&_0x1d420[_0xf5cf('0x8f')](_0x531640,_0x815caa[_0x3bad43][_0xf5cf('0x8e')]===_0xf5cf('0x7c')?![]:!![]);_0x1d420[_0xf5cf('0x6d')](_0x531640,_0x815caa[_0x3bad43][_0xf5cf('0x7d')]||_0x531640);}if(_0x29d739[_0xf5cf('0x7e')]){_0x29d739[_0xf5cf('0x7e')]=JSON[_0xf5cf('0x7f')](_0x29d739[_0xf5cf('0x7e')]);for(var _0x16765d=0x0;_0x16765d<_0x29d739[_0xf5cf('0x7e')][_0xf5cf('0x3b')];_0x16765d+=0x1){if(_0x29d739['joins'][_0x16765d][_0xf5cf('0x40')]&&_['includes'](_0x39dabd,_0x29d739[_0xf5cf('0x7e')][_0x16765d][_0xf5cf('0x40')])&&_0x29d739[_0xf5cf('0x7e')][_0x16765d]['parentKey']&&_0x29d739[_0xf5cf('0x7e')][_0x16765d][_0xf5cf('0x81')]&&_0x29d739[_0xf5cf('0x7e')][_0x16765d][_0xf5cf('0x82')]){_0x1d420[_0x29d739[_0xf5cf('0x7e')][_0x16765d]['type']](_0x29d739[_0xf5cf('0x7e')][_0x16765d][_0xf5cf('0x81')],null,util[_0xf5cf('0x7a')]('%s.%s\x20=\x20%s.%s',_0x29d739[_0xf5cf('0x76')],_0x29d739[_0xf5cf('0x7e')][_0x16765d][_0xf5cf('0x80')],_0x29d739[_0xf5cf('0x7e')][_0x16765d]['foreignTable'],_0x29d739[_0xf5cf('0x7e')][_0x16765d][_0xf5cf('0x82')]));}}}if(_0x29d739[_0xf5cf('0x84')]){_0x29d739[_0xf5cf('0x84')]=JSON[_0xf5cf('0x7f')](_0x29d739[_0xf5cf('0x84')]);_0x1d420[_0xf5cf('0x3f')](_0xcb8e60(_0x29d739['conditions'][_0xf5cf('0x6c')]));}_0x6a169=_0x1d420[_0xf5cf('0x90')]();_0x1d420[_0xf5cf('0x1e')](_0x3d68e6);_0x1d420['offset'](0x0);return;}})[_0xf5cf('0x26')](function(){if(_0x2ca543[_0xf5cf('0x91')]===_0xf5cf('0x92')){return null;}var _0xa07f7f=_[_0xf5cf('0x43')](_0x2ca543,{'name':_0x2ca543[_0xf5cf('0x93')]||_0x2ca543['name']||_0x29d739[_0xf5cf('0x2e')],'basename':_0x2b9dfc,'savename':util[_0xf5cf('0x7a')](_0xf5cf('0x94'),_0x2ca543[_0xf5cf('0x2e')]||_0x29d739[_0xf5cf('0x2e')],require(_0xf5cf('0x95'))['generate'](0x4),_0x2ca543[_0xf5cf('0x91')]||'csv'),'reportId':_0x29d739['id'],'reportType':_0xf5cf('0x96')});return db[_0xf5cf('0x97')][_0xf5cf('0x4e')](_0xa07f7f,{'raw':!![]});})[_0xf5cf('0x26')](function(_0x3c09c2){if(_0x29d739['table']===_0xf5cf('0x98')){_0x6a169[_0xf5cf('0x3f')](_0x29d739['table']+_0xf5cf('0x99'),_0x2ca543['startDate'],_0x2ca543[_0xf5cf('0x9a')]);}else{_0x6a169['where'](_0x29d739[_0xf5cf('0x76')]+_0xf5cf('0x9b'),_0x2ca543[_0xf5cf('0x9c')],_0x2ca543[_0xf5cf('0x9a')]);}if(_0x3c09c2){logger['info'](_0xf5cf('0x9d'),_0x6a169[_0xf5cf('0x86')]());require(_0xf5cf('0x9e'))[_0xf5cf('0x9f')](path[_0xf5cf('0x58')](__dirname,_0xf5cf('0xa0'),_0x3c09c2[_0xf5cf('0x91')]),[_0x3c09c2['id'],_0x6a169[_0xf5cf('0x86')](),path[_0xf5cf('0x58')](__dirname,_0xf5cf('0xa1'),_0x3c09c2[_0xf5cf('0xa2')]),_0x2b9dfc]);return _0x3c09c2;}else{var _0x53a6c3=squel[_0xf5cf('0x74')]();_0x53a6c3['from']('('+_0x6a169['toString']()+')',_0xf5cf('0xa3'));_0x53a6c3['field'](_0xf5cf('0xa4'),'count');_0x6a169[_0xf5cf('0x1e')](_0x2ca543['limit']||_0x3d68e6);_0x6a169[_0xf5cf('0x1d')](_0x2ca543['offset']||0x0);return dbH[_0xf5cf('0x87')]['query'](_0x53a6c3[_0xf5cf('0x86')](),{'type':dbH['sequelize'][_0xf5cf('0x88')][_0xf5cf('0xa5')]})[_0xf5cf('0x26')](function(_0x18d80a){if(!_0x18d80a[_0xf5cf('0x3b')]){_0xa6d93=0x0;}else{_0xa6d93=_0x18d80a[0x0][_0xf5cf('0x1c')]||0x0;}return dbH[_0xf5cf('0x87')][_0xf5cf('0x35')](_0x6a169[_0xf5cf('0x86')](),{'type':dbH[_0xf5cf('0x87')]['QueryTypes']['SELECT']});})[_0xf5cf('0x26')](function(_0x13ba42){return{'rows':_0x13ba42||[],'count':_0xa6d93};});}});}exports[_0xf5cf('0xa6')]=function(_0x179b9f,_0x7d7c7f){return runReport(_0x179b9f[_0xf5cf('0x4c')],_0x179b9f[_0xf5cf('0x35')],_0x179b9f[_0xf5cf('0x44')])['then'](respondWithResult(_0x7d7c7f,null))[_0xf5cf('0x4a')](handleError(_0x7d7c7f,null));};exports[_0xf5cf('0xa7')]=runReport;exports['query']=function(_0x45426a,_0x2d01ff){var _0x34d63b=0xa;var _0x5e0920=[_0xf5cf('0x58'),'left_join',_0xf5cf('0xa8'),_0xf5cf('0x89')];var _0x3ecad1={'SUM':_0xf5cf('0x5a'),'COUNT':_0xf5cf('0x5b'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xf5cf('0x5d'),'MIN':_0xf5cf('0x5e'),'AVG':_0xf5cf('0x5f'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xf5cf('0x61'),'GROUP_CONCAT DESC':_0xf5cf('0x8a')};var _0x83655c={'SEC_TO_TIME':_0xf5cf('0x62'),'DATE':'DATE(%s)','HOUR':_0xf5cf('0x64'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xf5cf('0x66')};var _0x1bd172=function(_0xde13fe){return!_['includes'](['IS\x20NULL','IS\x20NOT\x20NULL',_0xf5cf('0xa9'),_0xf5cf('0x8b')],_0xde13fe);};var _0x3b93c=function(_0x19edef){if(!_0x19edef||!_0x19edef[_0xf5cf('0x6a')][_0xf5cf('0x3b')]){return'';}for(var _0xe5f875='(',_0x33c973=0x0;_0x33c973<_0x19edef['rules'][_0xf5cf('0x3b')];_0x33c973+=0x1){_0x33c973>0x0&&(_0xe5f875+='\x20'+_0x19edef[_0xf5cf('0x6b')]+'\x20');_0xe5f875+=_0x19edef[_0xf5cf('0x6a')][_0x33c973][_0xf5cf('0x6c')]?_0x3b93c(_0x19edef[_0xf5cf('0x6a')][_0x33c973]['group']):_0x19edef['rules'][_0x33c973]['field']+'\x20'+_0x19edef['rules'][_0x33c973][_0xf5cf('0x6e')]+(_0x1bd172(_0x19edef['rules'][_0x33c973][_0xf5cf('0x6e')])?'\x20'+_0x19edef[_0xf5cf('0x6a')][_0x33c973][_0xf5cf('0x6f')]:'');}return _0xe5f875+')';};var _0x35caf6={'where':{'id':_0x45426a['params']['id']}},_0x57341d,_0x147591,_0x2e0129,_0x145730,_0xf6c3ff;_0x35caf6=_[_0xf5cf('0x43')]({},_0x35caf6,_0x45426a[_0xf5cf('0x44')]);return db[_0xf5cf('0x47')][_0xf5cf('0x4d')](_0x35caf6)['then'](function(_0x33e41c){if(_0x33e41c){_0x57341d=_0x33e41c;return _0x33e41c[_0xf5cf('0x70')]();}return null;})[_0xf5cf('0x26')](function(_0x292948){if(_0x292948){if(!_0x292948[_0xf5cf('0x3b')]){throw new db[(_0xf5cf('0x71'))]['ValidationErrorItem'](_0xf5cf('0x8c'),0x193);}_0x147591=_0x292948;return db['AnalyticMetric'][_0xf5cf('0x48')]({'raw':!![]});}return null;})['then'](function(_0x58d08e){if(_0x58d08e){_0x2e0129=_[_0xf5cf('0x73')](_0x58d08e,'id');var _0x4b83ce;var _0x4a8ab1=squel[_0xf5cf('0x74')]();_0x4a8ab1[_0xf5cf('0x75')](_0x57341d['table']);for(var _0x118dc0=0x0;_0x118dc0<_0x147591[_0xf5cf('0x3b')];_0x118dc0+=0x1){_0x4b83ce=_0x147591[_0x118dc0][_0xf5cf('0x77')]?_0x2e0129[_0x147591[_0x118dc0][_0xf5cf('0x77')]][_0xf5cf('0x8d')]:_0x147591[_0x118dc0][_0xf5cf('0x6d')];_0x4b83ce=_0x147591[_0x118dc0]['function']?_[_0xf5cf('0x79')](_0x3ecad1[_0x147591[_0x118dc0][_0xf5cf('0x78')]],'%s',_0x4b83ce):_0x4b83ce;_0x4b83ce=_0x147591[_0x118dc0][_0xf5cf('0x7a')]?_['replace'](_0x83655c[_0x147591[_0x118dc0][_0xf5cf('0x7a')]],'%s',_0x4b83ce):_0x4b83ce;if(_0x147591[_0x118dc0][_0xf5cf('0x7b')]){_0x4a8ab1[_0xf5cf('0x6c')](_0x4b83ce);}_0x147591[_0x118dc0][_0xf5cf('0x8e')]&&_0x4a8ab1[_0xf5cf('0x8f')](_0x4b83ce,_0x147591[_0x118dc0]['orderBy']===_0xf5cf('0x7c')?![]:!![]);_0x4a8ab1[_0xf5cf('0x6d')](_0x4b83ce,_0x147591[_0x118dc0][_0xf5cf('0x7d')]||_0x4b83ce);}if(_0x57341d[_0xf5cf('0x7e')]){_0x57341d[_0xf5cf('0x7e')]=JSON[_0xf5cf('0x7f')](_0x57341d[_0xf5cf('0x7e')]);for(var _0x4bbb7e=0x0;_0x4bbb7e<_0x57341d['joins'][_0xf5cf('0x3b')];_0x4bbb7e+=0x1){if(_0x57341d[_0xf5cf('0x7e')][_0x4bbb7e]['type']&&_['includes'](_0x5e0920,_0x57341d['joins'][_0x4bbb7e][_0xf5cf('0x40')])&&_0x57341d[_0xf5cf('0x7e')][_0x4bbb7e][_0xf5cf('0x80')]&&_0x57341d[_0xf5cf('0x7e')][_0x4bbb7e][_0xf5cf('0x81')]&&_0x57341d['joins'][_0x4bbb7e]['foreignKey']){_0x4a8ab1[_0x57341d[_0xf5cf('0x7e')][_0x4bbb7e]['type']](_0x57341d[_0xf5cf('0x7e')][_0x4bbb7e][_0xf5cf('0x81')],null,util['format'](_0xf5cf('0x83'),_0x57341d[_0xf5cf('0x76')],_0x57341d[_0xf5cf('0x7e')][_0x4bbb7e][_0xf5cf('0x80')],_0x57341d[_0xf5cf('0x7e')][_0x4bbb7e][_0xf5cf('0x81')],_0x57341d[_0xf5cf('0x7e')][_0x4bbb7e][_0xf5cf('0x82')]));}}}if(_0x57341d[_0xf5cf('0x84')]){_0x57341d['conditions']=JSON[_0xf5cf('0x7f')](_0x57341d[_0xf5cf('0x84')]);_0x4a8ab1['where'](_0x3b93c(_0x57341d[_0xf5cf('0x84')]['group']));}_0xf6c3ff=_0x4a8ab1[_0xf5cf('0x90')]();_0x4a8ab1[_0xf5cf('0x1e')](_0x34d63b);_0x4a8ab1[_0xf5cf('0x1d')](0x0);logger[_0xf5cf('0xaa')](_0xf5cf('0x85'),_0x4a8ab1[_0xf5cf('0x86')]());return dbH[_0xf5cf('0x87')][_0xf5cf('0x35')](_0x4a8ab1[_0xf5cf('0x86')](),{'type':dbH[_0xf5cf('0x87')][_0xf5cf('0x88')][_0xf5cf('0xa5')]});}})[_0xf5cf('0x26')](function(){return{'sql':_0xf6c3ff[_0xf5cf('0x86')]()};})[_0xf5cf('0x26')](respondWithResult(_0x2d01ff,null))['catch'](handleError(_0x2d01ff,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