Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index fb82e78..57074ee 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 _0x46ed=['SEC_TO_TIME(%s)','value','AnalyticMetric','select','DESC','output','fullPath','%s-%s.%s','randomstring','csv','default','AnalyticExtractedReport','cdr','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','info','Run\x20Query:','child_process','../../files/reports','savename','countTable','COUNT(*)','sequelize','runReport','left_join','COUNT(%s)','MIN(%s)','AVG(%s)','Limited\x20Query:','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','get','DefaultReports','UserProfileResource','destroy','sendStatus','error','stack','name','send','index','map','AnalyticDefaultReport','rawAttributes','fieldName','type','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','merge','options','includeAll','include','findAll','catch','params','find','create','body','user','Reports','UserProfileSection','userProfileId','autoAssociation','preview','join','right_join','cross_join','SUM(%s)','COUNT(DISTINCT\x20%s)','MAX(%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)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','keyBy','from','table','MetricId','metric','function','replace','format','groupBy','orderBy','order','alias','joins','parentKey','foreignKey','foreignTable','%s.%s\x20=\x20%s.%s','conditions','parse','clone','toString','QueryTypes','SELECT'];(function(_0x38f530,_0xce8ca4){var _0x569092=function(_0x57fbce){while(--_0x57fbce){_0x38f530['push'](_0x38f530['shift']());}};_0x569092(++_0xce8ca4);}(_0x46ed,0x168));var _0xd46e=function(_0x178e48,_0x3c9509){_0x178e48=_0x178e48-0x0;var _0x440d7e=_0x46ed[_0x178e48];return _0x440d7e;};'use strict';var emlformat=require(_0xd46e('0x0'));var rimraf=require(_0xd46e('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd46e('0x2'));var rp=require(_0xd46e('0x3'));var moment=require(_0xd46e('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xd46e('0x5'));var util=require(_0xd46e('0x6'));var path=require('path');var sox=require(_0xd46e('0x7'));var csv=require(_0xd46e('0x8'));var ejs=require(_0xd46e('0x9'));var fs=require('fs');var fs_extra=require(_0xd46e('0xa'));var _=require(_0xd46e('0xb'));var squel=require(_0xd46e('0xc'));var crypto=require(_0xd46e('0xd'));var jsforce=require(_0xd46e('0xe'));var deskjs=require(_0xd46e('0xf'));var toCsv=require(_0xd46e('0x8'));var querystring=require(_0xd46e('0x10'));var Papa=require('papaparse');var Redis=require(_0xd46e('0x11'));var authService=require(_0xd46e('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xd46e('0x13'));var hardwareService=require(_0xd46e('0x14'));var logger=require(_0xd46e('0x15'))(_0xd46e('0x16'));var utils=require(_0xd46e('0x17'));var config=require(_0xd46e('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xd46e('0x19'))['db'];var dbH=require('../../mysqldb')['dbH'];function respondWithStatusCode(_0xf3048c,_0x27dbfb){_0x27dbfb=_0x27dbfb||0xcc;return function(_0x53b309){if(_0x53b309){return _0xf3048c['sendStatus'](_0x27dbfb);}return _0xf3048c[_0xd46e('0x1a')](_0x27dbfb)[_0xd46e('0x1b')]();};}function respondWithResult(_0x1e9aae,_0x3fdf88){_0x3fdf88=_0x3fdf88||0xc8;return function(_0x50c7c3){if(_0x50c7c3){return _0x1e9aae[_0xd46e('0x1a')](_0x3fdf88)[_0xd46e('0x1c')](_0x50c7c3);}};}function respondWithFilteredResult(_0x417402,_0x3d72ce){return function(_0x36a317){if(_0x36a317){var _0x47fa8f=typeof _0x3d72ce[_0xd46e('0x1d')]===_0xd46e('0x1e')&&typeof _0x3d72ce[_0xd46e('0x1f')]==='undefined';var _0x5ddd04=_0x36a317[_0xd46e('0x20')];var _0x1bd574=_0x47fa8f?0x0:_0x3d72ce['offset'];var _0x4fd1f2=_0x47fa8f?_0x36a317[_0xd46e('0x20')]:_0x3d72ce[_0xd46e('0x1d')]+_0x3d72ce[_0xd46e('0x1f')];var _0x2273c5;if(_0x4fd1f2>=_0x5ddd04){_0x4fd1f2=_0x5ddd04;_0x2273c5=0xc8;}else{_0x2273c5=0xce;}_0x417402[_0xd46e('0x1a')](_0x2273c5);return _0x417402[_0xd46e('0x21')](_0xd46e('0x22'),_0x1bd574+'-'+_0x4fd1f2+'/'+_0x5ddd04)[_0xd46e('0x1c')](_0x36a317);}return null;};}function patchUpdates(_0xb4940){return function(_0x3c7e91){try{jsonpatch[_0xd46e('0x23')](_0x3c7e91,_0xb4940,!![]);}catch(_0x5ba94d){return BPromise[_0xd46e('0x24')](_0x5ba94d);}return _0x3c7e91[_0xd46e('0x25')]();};}function saveUpdates(_0x79aa51,_0x45ce0b){return function(_0x128246){if(_0x128246){return _0x128246[_0xd46e('0x26')](_0x79aa51)[_0xd46e('0x27')](function(_0x8a1be){return _0x8a1be;});}return null;};}function removeEntity(_0x62dea5,_0x4cf899){return function(_0x314570){if(_0x314570){return _0x314570['destroy']()['then'](function(){var _0x371054=_0x314570[_0xd46e('0x28')]({'plain':!![]});var _0x21135f=_0xd46e('0x29');return db[_0xd46e('0x2a')][_0xd46e('0x2b')]({'where':{'type':_0x21135f,'resourceId':_0x371054['id']}})[_0xd46e('0x27')](function(){return _0x314570;});})['then'](function(){_0x62dea5[_0xd46e('0x1a')](0xcc)[_0xd46e('0x1b')]();});}};}function handleEntityNotFound(_0xddbce9,_0x17db79){return function(_0x96f15c){if(!_0x96f15c){_0xddbce9[_0xd46e('0x2c')](0x194);}return _0x96f15c;};}function handleError(_0x58aeef,_0x465d54){_0x465d54=_0x465d54||0x1f4;return function(_0x3a1ced){logger[_0xd46e('0x2d')](_0x3a1ced[_0xd46e('0x2e')]);if(_0x3a1ced[_0xd46e('0x2f')]){delete _0x3a1ced[_0xd46e('0x2f')];}_0x58aeef[_0xd46e('0x1a')](_0x465d54)[_0xd46e('0x30')](_0x3a1ced);};}exports[_0xd46e('0x31')]=function(_0x45ea47,_0x2ff785){var _0x504324={},_0x2f4a1b={},_0x5ed8dc={'count':0x0,'rows':[]};var _0x1248ce=_[_0xd46e('0x32')](db[_0xd46e('0x33')][_0xd46e('0x34')],function(_0x5ef248){return{'name':_0x5ef248[_0xd46e('0x35')],'type':_0x5ef248[_0xd46e('0x36')]['key']};});_0x2f4a1b[_0xd46e('0x37')]=_[_0xd46e('0x32')](_0x1248ce,'name');_0x2f4a1b[_0xd46e('0x38')]=_[_0xd46e('0x39')](_0x45ea47[_0xd46e('0x38')]);_0x2f4a1b['filters']=_['intersection'](_0x2f4a1b[_0xd46e('0x37')],_0x2f4a1b[_0xd46e('0x38')]);_0x504324[_0xd46e('0x3a')]=_[_0xd46e('0x3b')](_0x2f4a1b[_0xd46e('0x37')],qs[_0xd46e('0x3c')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x3c')]));_0x504324['attributes']=_0x504324[_0xd46e('0x3a')][_0xd46e('0x3d')]?_0x504324[_0xd46e('0x3a')]:_0x2f4a1b[_0xd46e('0x37')];if(!_0x45ea47[_0xd46e('0x38')][_0xd46e('0x3e')](_0xd46e('0x3f'))){_0x504324['limit']=qs[_0xd46e('0x1f')](_0x45ea47[_0xd46e('0x38')]['limit']);_0x504324[_0xd46e('0x1d')]=qs[_0xd46e('0x1d')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x1d')]);}_0x504324['order']=qs[_0xd46e('0x40')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x40')]);_0x504324[_0xd46e('0x41')]=qs[_0xd46e('0x42')](_[_0xd46e('0x43')](_0x45ea47[_0xd46e('0x38')],_0x2f4a1b[_0xd46e('0x42')]),_0x1248ce);if(_0x45ea47['query'][_0xd46e('0x44')]){_0x504324[_0xd46e('0x41')]=_[_0xd46e('0x45')](_0x504324[_0xd46e('0x41')],{'$or':_[_0xd46e('0x32')](_0x1248ce,function(_0x56f99c){if(_0x56f99c[_0xd46e('0x36')]!=='VIRTUAL'){var _0x55230d={};_0x55230d[_0x56f99c['name']]={'$like':'%'+_0x45ea47['query'][_0xd46e('0x44')]+'%'};return _0x55230d;}})});}_0x504324=_['merge']({},_0x504324,_0x45ea47[_0xd46e('0x46')]);var _0x40720e={'where':_0x504324['where']};return db[_0xd46e('0x33')][_0xd46e('0x20')](_0x40720e)[_0xd46e('0x27')](function(_0x31ba12){_0x5ed8dc[_0xd46e('0x20')]=_0x31ba12;if(_0x45ea47[_0xd46e('0x38')][_0xd46e('0x47')]){_0x504324[_0xd46e('0x48')]=[{'all':!![]}];}return db[_0xd46e('0x33')][_0xd46e('0x49')](_0x504324);})[_0xd46e('0x27')](function(_0x5ea048){_0x5ed8dc['rows']=_0x5ea048;return _0x5ed8dc;})['then'](respondWithFilteredResult(_0x2ff785,_0x504324))[_0xd46e('0x4a')](handleError(_0x2ff785,null));};exports['show']=function(_0x168d35,_0x272f5f){var _0x3fdf67={'raw':!![],'where':{'id':_0x168d35[_0xd46e('0x4b')]['id']}},_0x416505={};_0x416505[_0xd46e('0x37')]=_[_0xd46e('0x39')](db[_0xd46e('0x33')]['rawAttributes']);_0x416505[_0xd46e('0x38')]=_['keys'](_0x168d35[_0xd46e('0x38')]);_0x416505[_0xd46e('0x42')]=_[_0xd46e('0x3b')](_0x416505[_0xd46e('0x37')],_0x416505[_0xd46e('0x38')]);_0x3fdf67['attributes']=_[_0xd46e('0x3b')](_0x416505[_0xd46e('0x37')],qs[_0xd46e('0x3c')](_0x168d35[_0xd46e('0x38')][_0xd46e('0x3c')]));_0x3fdf67['attributes']=_0x3fdf67[_0xd46e('0x3a')][_0xd46e('0x3d')]?_0x3fdf67[_0xd46e('0x3a')]:_0x416505[_0xd46e('0x37')];if(_0x168d35[_0xd46e('0x38')]['includeAll']){_0x3fdf67[_0xd46e('0x48')]=[{'all':!![]}];}_0x3fdf67=_[_0xd46e('0x45')]({},_0x3fdf67,_0x168d35[_0xd46e('0x46')]);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0x3fdf67)[_0xd46e('0x27')](handleEntityNotFound(_0x272f5f,null))[_0xd46e('0x27')](respondWithResult(_0x272f5f,null))[_0xd46e('0x4a')](handleError(_0x272f5f,null));};exports['create']=function(_0xf9dab,_0x71a8dc){return db[_0xd46e('0x33')][_0xd46e('0x4d')](_0xf9dab[_0xd46e('0x4e')],{})['then'](function(_0x4ae314){var _0x3a94cf=_0xf9dab[_0xd46e('0x4f')][_0xd46e('0x28')]({'plain':!![]});if(!_0x3a94cf)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3a94cf['role']===_0xd46e('0x4f')){var _0x9d8638=_0x4ae314['get']({'plain':!![]});var _0x2eee92=_0xd46e('0x50');return db[_0xd46e('0x51')][_0xd46e('0x4c')]({'where':{'name':_0x2eee92,'userProfileId':_0x3a94cf[_0xd46e('0x52')]},'raw':!![]})[_0xd46e('0x27')](function(_0x80ed51){if(_0x80ed51&&_0x80ed51[_0xd46e('0x53')]===0x0){return db['UserProfileResource'][_0xd46e('0x4d')]({'name':_0x9d8638[_0xd46e('0x2f')],'resourceId':_0x9d8638['id'],'type':_0xd46e('0x29'),'sectionId':_0x80ed51['id']},{})[_0xd46e('0x27')](function(){return _0x4ae314;});}else{return _0x4ae314;}})['catch'](function(_0x56dd9a){logger[_0xd46e('0x2d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x56dd9a);throw _0x56dd9a;});}return _0x4ae314;})[_0xd46e('0x27')](respondWithResult(_0x71a8dc,0xc9))[_0xd46e('0x4a')](handleError(_0x71a8dc,null));};exports[_0xd46e('0x26')]=function(_0x31f7eb,_0x5a7870){if(_0x31f7eb[_0xd46e('0x4e')]['id']){delete _0x31f7eb['body']['id'];}return db[_0xd46e('0x33')][_0xd46e('0x4c')]({'where':{'id':_0x31f7eb[_0xd46e('0x4b')]['id']}})['then'](handleEntityNotFound(_0x5a7870,null))[_0xd46e('0x27')](saveUpdates(_0x31f7eb[_0xd46e('0x4e')],null))[_0xd46e('0x27')](respondWithResult(_0x5a7870,null))[_0xd46e('0x4a')](handleError(_0x5a7870,null));};exports[_0xd46e('0x2b')]=function(_0x2cc676,_0x2760ef){return db[_0xd46e('0x33')][_0xd46e('0x4c')]({'where':{'id':_0x2cc676[_0xd46e('0x4b')]['id']}})[_0xd46e('0x27')](handleEntityNotFound(_0x2760ef,null))[_0xd46e('0x27')](removeEntity(_0x2760ef,null))[_0xd46e('0x4a')](handleError(_0x2760ef,null));};exports[_0xd46e('0x54')]=function(_0x47a86c,_0x3ec709){var _0x37a22f=0xa;var _0xe0cd61=[_0xd46e('0x55'),'left_join',_0xd46e('0x56'),_0xd46e('0x57')];var _0xaf9641={'SUM':_0xd46e('0x58'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':_0xd46e('0x5c'),'GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x481dce={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':_0xd46e('0x61')};var _0x2dacb4=function(_0x2f9fcb){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),_0xd46e('0x64'),_0xd46e('0x65'),_0xd46e('0x66')],_0x2f9fcb);};var _0x1aaa99=function(_0x272514){if(!_0x272514||!_0x272514[_0xd46e('0x67')][_0xd46e('0x3d')]){return'';}for(var _0x476f09='(',_0x5067b7=0x0;_0x5067b7<_0x272514[_0xd46e('0x67')][_0xd46e('0x3d')];_0x5067b7+=0x1){_0x5067b7>0x0&&(_0x476f09+='\x20'+_0x272514[_0xd46e('0x68')]+'\x20');_0x476f09+=_0x272514['rules'][_0x5067b7][_0xd46e('0x69')]?_0x1aaa99(_0x272514[_0xd46e('0x67')][_0x5067b7]['group']):_0x272514[_0xd46e('0x67')][_0x5067b7][_0xd46e('0x6a')]+'\x20'+_0x272514[_0xd46e('0x67')][_0x5067b7]['condition']+(_0x2dacb4(_0x272514[_0xd46e('0x67')][_0x5067b7][_0xd46e('0x6b')])?'\x20'+_0x272514[_0xd46e('0x67')][_0x5067b7]['value']:'');}return _0x476f09+')';};var _0xe5f8cd={'where':{'id':_0x47a86c[_0xd46e('0x4b')]['id']}},_0x516e7d,_0x32eed0,_0x148187,_0x35db1b,_0x4f3ba0;_0xe5f8cd=_[_0xd46e('0x45')]({},_0xe5f8cd,_0x47a86c[_0xd46e('0x46')]);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0xe5f8cd)[_0xd46e('0x27')](function(_0x16f906){if(_0x16f906){_0x516e7d=_0x16f906;return _0x16f906[_0xd46e('0x6c')]();}return null;})[_0xd46e('0x27')](function(_0x3e55a3){if(_0x3e55a3){if(!_0x3e55a3[_0xd46e('0x3d')]){throw new db[(_0xd46e('0x6d'))][(_0xd46e('0x6e'))](_0xd46e('0x6f'),0x193);}_0x32eed0=_0x3e55a3;return db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0xd46e('0x27')](function(_0x3e0ed5){if(_0x3e0ed5){_0x148187=_[_0xd46e('0x70')](_0x3e0ed5,'id');var _0x2fff69;var _0x249938=squel['select']();_0x249938[_0xd46e('0x71')](_0x516e7d[_0xd46e('0x72')]);for(var _0xfb4073=0x0;_0xfb4073<_0x32eed0[_0xd46e('0x3d')];_0xfb4073+=0x1){_0x2fff69=_0x32eed0[_0xfb4073]['MetricId']?_0x148187[_0x32eed0[_0xfb4073][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x32eed0[_0xfb4073]['field'];_0x2fff69=_0x32eed0[_0xfb4073][_0xd46e('0x75')]?_[_0xd46e('0x76')](_0xaf9641[_0x32eed0[_0xfb4073]['function']],'%s',_0x2fff69):_0x2fff69;_0x2fff69=_0x32eed0[_0xfb4073][_0xd46e('0x77')]?_[_0xd46e('0x76')](_0x481dce[_0x32eed0[_0xfb4073]['format']],'%s',_0x2fff69):_0x2fff69;if(_0x32eed0[_0xfb4073][_0xd46e('0x78')]){_0x249938['group'](_0x2fff69);}_0x32eed0[_0xfb4073][_0xd46e('0x79')]&&_0x249938[_0xd46e('0x7a')](_0x2fff69,_0x32eed0[_0xfb4073]['orderBy']==='DESC'?![]:!![]);_0x249938[_0xd46e('0x6a')](_0x2fff69,_0x32eed0[_0xfb4073][_0xd46e('0x7b')]||_0x2fff69);}if(_0x516e7d[_0xd46e('0x7c')]){_0x516e7d[_0xd46e('0x7c')]=JSON['parse'](_0x516e7d[_0xd46e('0x7c')]);for(var _0x372509=0x0;_0x372509<_0x516e7d['joins'][_0xd46e('0x3d')];_0x372509+=0x1){if(_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0xe0cd61,_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x36')])&&_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7d')]&&_0x516e7d[_0xd46e('0x7c')][_0x372509]['foreignTable']&&_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7e')]){_0x249938[_0x516e7d['joins'][_0x372509][_0xd46e('0x36')]](_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7f')],null,util[_0xd46e('0x77')](_0xd46e('0x80'),_0x516e7d[_0xd46e('0x72')],_0x516e7d['joins'][_0x372509]['parentKey'],_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7f')],_0x516e7d['joins'][_0x372509]['foreignKey']));}}}if(_0x516e7d['conditions']){_0x516e7d[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0x516e7d[_0xd46e('0x81')]);_0x249938['where'](_0x1aaa99(_0x516e7d[_0xd46e('0x81')][_0xd46e('0x69')]));}_0x4f3ba0=_0x249938[_0xd46e('0x83')]();_0x249938['limit'](_0x37a22f);_0x249938['offset'](0x0);logger['debug']('Limited\x20Query:',_0x249938[_0xd46e('0x84')]());return dbH['sequelize'][_0xd46e('0x38')](_0x249938['toString'](),{'type':dbH['sequelize'][_0xd46e('0x85')][_0xd46e('0x86')]});}})[_0xd46e('0x27')](respondWithResult(_0x3ec709,null))[_0xd46e('0x4a')](handleError(_0x3ec709,null));};function runReport(_0xf16d87,_0x99872a,_0x57a7cc){var _0x586024=_0x99872a[_0xd46e('0x2f')];var _0x383919=0xa;var _0x114f2c=[_0xd46e('0x55'),'left_join',_0xd46e('0x56'),_0xd46e('0x57')];var _0x4ca21f={'SUM':_0xd46e('0x58'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':_0xd46e('0x5c'),'GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x5ef4cc={'SEC_TO_TIME':_0xd46e('0x87'),'DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':_0xd46e('0x61')};var _0x88460a=function(_0x3a3744){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),_0xd46e('0x64'),_0xd46e('0x65'),_0xd46e('0x66')],_0x3a3744);};var _0x3c476d=function(_0x1b2a6d){if(!_0x1b2a6d||!_0x1b2a6d[_0xd46e('0x67')][_0xd46e('0x3d')]){return'';}for(var _0x441f73='(',_0x1d2738=0x0;_0x1d2738<_0x1b2a6d['rules'][_0xd46e('0x3d')];_0x1d2738+=0x1){_0x1d2738>0x0&&(_0x441f73+='\x20'+_0x1b2a6d['operator']+'\x20');_0x441f73+=_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x69')]?_0x3c476d(_0x1b2a6d['rules'][_0x1d2738][_0xd46e('0x69')]):_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6a')]+'\x20'+_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6b')]+(_0x88460a(_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6b')])?'\x20'+_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x88')]:'');}return _0x441f73+')';};var _0x3fa34d={'where':{'id':_0xf16d87['id']}},_0xc098c9,_0x5f5ba7,_0x493df5,_0x18e140,_0x459a0c;_0x3fa34d=_[_0xd46e('0x45')]({},_0x3fa34d,_0x57a7cc);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0x3fa34d)[_0xd46e('0x27')](function(_0x5b554e){if(_0x5b554e){_0xc098c9=_0x5b554e;return _0x5b554e[_0xd46e('0x6c')]();}return null;})[_0xd46e('0x27')](function(_0xa254f5){if(_0xa254f5){if(!_0xa254f5[_0xd46e('0x3d')]){throw new db[(_0xd46e('0x6d'))][(_0xd46e('0x6e'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x5f5ba7=_0xa254f5;return db[_0xd46e('0x89')][_0xd46e('0x49')]({'raw':!![]});}return null;})['then'](function(_0x3c8d68){if(_0x3c8d68){_0x493df5=_[_0xd46e('0x70')](_0x3c8d68,'id');var _0x9e222d;var _0x3da17e=squel[_0xd46e('0x8a')]();_0x3da17e[_0xd46e('0x71')](_0xc098c9[_0xd46e('0x72')]);for(var _0x282f71=0x0;_0x282f71<_0x5f5ba7[_0xd46e('0x3d')];_0x282f71+=0x1){_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x73')]?_0x493df5[_0x5f5ba7[_0x282f71][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x5f5ba7[_0x282f71][_0xd46e('0x6a')];_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x75')]?_['replace'](_0x4ca21f[_0x5f5ba7[_0x282f71]['function']],'%s',_0x9e222d):_0x9e222d;_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x77')]?_[_0xd46e('0x76')](_0x5ef4cc[_0x5f5ba7[_0x282f71][_0xd46e('0x77')]],'%s',_0x9e222d):_0x9e222d;if(_0x5f5ba7[_0x282f71][_0xd46e('0x78')]){_0x3da17e[_0xd46e('0x69')](_0x9e222d);}_0x5f5ba7[_0x282f71][_0xd46e('0x79')]&&_0x3da17e['order'](_0x9e222d,_0x5f5ba7[_0x282f71][_0xd46e('0x79')]===_0xd46e('0x8b')?![]:!![]);_0x3da17e[_0xd46e('0x6a')](_0x9e222d,_0x5f5ba7[_0x282f71][_0xd46e('0x7b')]||_0x9e222d);}if(_0xc098c9['joins']){_0xc098c9[_0xd46e('0x7c')]=JSON[_0xd46e('0x82')](_0xc098c9['joins']);for(var _0xdf967c=0x0;_0xdf967c<_0xc098c9['joins']['length'];_0xdf967c+=0x1){if(_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0x114f2c,_0xc098c9[_0xd46e('0x7c')][_0xdf967c]['type'])&&_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7d')]&&_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7f')]&&_0xc098c9['joins'][_0xdf967c]['foreignKey']){_0x3da17e[_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x36')]](_0xc098c9['joins'][_0xdf967c]['foreignTable'],null,util[_0xd46e('0x77')](_0xd46e('0x80'),_0xc098c9[_0xd46e('0x72')],_0xc098c9[_0xd46e('0x7c')][_0xdf967c]['parentKey'],_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x7f')],_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7e')]));}}}if(_0xc098c9[_0xd46e('0x81')]){_0xc098c9[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0xc098c9[_0xd46e('0x81')]);_0x3da17e[_0xd46e('0x41')](_0x3c476d(_0xc098c9['conditions'][_0xd46e('0x69')]));}_0x459a0c=_0x3da17e[_0xd46e('0x83')]();_0x3da17e['limit'](_0x383919);_0x3da17e['offset'](0x0);return;}})[_0xd46e('0x27')](function(){if(_0x99872a[_0xd46e('0x8c')]==='web'){return null;}var _0x5e637d=_[_0xd46e('0x45')](_0x99872a,{'name':_0x99872a[_0xd46e('0x8d')]||_0x99872a['name']||_0xc098c9[_0xd46e('0x2f')],'basename':_0x586024,'savename':util[_0xd46e('0x77')](_0xd46e('0x8e'),_0x99872a[_0xd46e('0x2f')]||_0xc098c9[_0xd46e('0x2f')],require(_0xd46e('0x8f'))['generate'](0x4),_0x99872a[_0xd46e('0x8c')]||_0xd46e('0x90')),'reportId':_0xc098c9['id'],'reportType':_0xd46e('0x91')});return db[_0xd46e('0x92')][_0xd46e('0x4d')](_0x5e637d,{'raw':!![]});})[_0xd46e('0x27')](function(_0x3311a6){if(_0xc098c9[_0xd46e('0x72')]===_0xd46e('0x93')){_0x459a0c[_0xd46e('0x41')](_0xc098c9[_0xd46e('0x72')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x99872a[_0xd46e('0x94')],_0x99872a['endDate']);}else{_0x459a0c['where'](_0xc098c9[_0xd46e('0x72')]+_0xd46e('0x95'),_0x99872a[_0xd46e('0x94')],_0x99872a[_0xd46e('0x96')]);}if(_0x3311a6){logger[_0xd46e('0x97')](_0xd46e('0x98'),_0x459a0c[_0xd46e('0x84')]());require(_0xd46e('0x99'))['fork'](path[_0xd46e('0x55')](__dirname,'../../components/export/',_0x3311a6[_0xd46e('0x8c')]),[_0x3311a6['id'],_0x459a0c[_0xd46e('0x84')](),path[_0xd46e('0x55')](__dirname,_0xd46e('0x9a'),_0x3311a6[_0xd46e('0x9b')]),_0x586024]);return _0x3311a6;}else{var _0x399918=squel[_0xd46e('0x8a')]();_0x399918[_0xd46e('0x71')]('('+_0x459a0c['toString']()+')',_0xd46e('0x9c'));_0x399918[_0xd46e('0x6a')](_0xd46e('0x9d'),'count');_0x459a0c[_0xd46e('0x1f')](_0x99872a[_0xd46e('0x1f')]||_0x383919);_0x459a0c[_0xd46e('0x1d')](_0x99872a['offset']||0x0);return dbH[_0xd46e('0x9e')][_0xd46e('0x38')](_0x399918[_0xd46e('0x84')](),{'type':dbH[_0xd46e('0x9e')][_0xd46e('0x85')][_0xd46e('0x86')]})['then'](function(_0x4967ff){if(!_0x4967ff[_0xd46e('0x3d')]){_0x18e140=0x0;}else{_0x18e140=_0x4967ff[0x0][_0xd46e('0x20')]||0x0;}return dbH['sequelize'][_0xd46e('0x38')](_0x459a0c[_0xd46e('0x84')](),{'type':dbH[_0xd46e('0x9e')][_0xd46e('0x85')][_0xd46e('0x86')]});})[_0xd46e('0x27')](function(_0x4bb76b){return{'rows':_0x4bb76b||[],'count':_0x18e140};});}});}exports['run']=function(_0x204a9f,_0x52ca5a){return runReport(_0x204a9f[_0xd46e('0x4b')],_0x204a9f[_0xd46e('0x38')],_0x204a9f['options'])[_0xd46e('0x27')](respondWithResult(_0x52ca5a,null))[_0xd46e('0x4a')](handleError(_0x52ca5a,null));};exports[_0xd46e('0x9f')]=runReport;exports[_0xd46e('0x38')]=function(_0x786ae,_0x537c73){var _0x1610bd=0xa;var _0x20cc4c=[_0xd46e('0x55'),_0xd46e('0xa0'),_0xd46e('0x56'),_0xd46e('0x57')];var _0x368742={'SUM':_0xd46e('0x58'),'COUNT':_0xd46e('0xa1'),'COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':_0xd46e('0xa2'),'AVG':_0xd46e('0xa3'),'GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x285cf8={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0xc87da2=function(_0x195f02){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),'IS\x20NOT\x20NULL',_0xd46e('0x65'),_0xd46e('0x66')],_0x195f02);};var _0x44322f=function(_0x49959f){if(!_0x49959f||!_0x49959f['rules'][_0xd46e('0x3d')]){return'';}for(var _0x2094e5='(',_0x85aac1=0x0;_0x85aac1<_0x49959f[_0xd46e('0x67')][_0xd46e('0x3d')];_0x85aac1+=0x1){_0x85aac1>0x0&&(_0x2094e5+='\x20'+_0x49959f[_0xd46e('0x68')]+'\x20');_0x2094e5+=_0x49959f['rules'][_0x85aac1][_0xd46e('0x69')]?_0x44322f(_0x49959f['rules'][_0x85aac1][_0xd46e('0x69')]):_0x49959f['rules'][_0x85aac1][_0xd46e('0x6a')]+'\x20'+_0x49959f['rules'][_0x85aac1]['condition']+(_0xc87da2(_0x49959f[_0xd46e('0x67')][_0x85aac1][_0xd46e('0x6b')])?'\x20'+_0x49959f[_0xd46e('0x67')][_0x85aac1][_0xd46e('0x88')]:'');}return _0x2094e5+')';};var _0x101a29={'where':{'id':_0x786ae[_0xd46e('0x4b')]['id']}},_0x3a44da,_0x417068,_0x52e73e,_0x206077,_0xe729b6;_0x101a29=_[_0xd46e('0x45')]({},_0x101a29,_0x786ae[_0xd46e('0x46')]);return db['AnalyticDefaultReport'][_0xd46e('0x4c')](_0x101a29)[_0xd46e('0x27')](function(_0x1d08bb){if(_0x1d08bb){_0x3a44da=_0x1d08bb;return _0x1d08bb['getFields']();}return null;})[_0xd46e('0x27')](function(_0x8c6ed1){if(_0x8c6ed1){if(!_0x8c6ed1['length']){throw new db['Sequelize']['ValidationErrorItem'](_0xd46e('0x6f'),0x193);}_0x417068=_0x8c6ed1;return db[_0xd46e('0x89')]['findAll']({'raw':!![]});}return null;})[_0xd46e('0x27')](function(_0x3a13f8){if(_0x3a13f8){_0x52e73e=_['keyBy'](_0x3a13f8,'id');var _0x5a8661;var _0x157fb0=squel[_0xd46e('0x8a')]();_0x157fb0[_0xd46e('0x71')](_0x3a44da[_0xd46e('0x72')]);for(var _0x50750f=0x0;_0x50750f<_0x417068['length'];_0x50750f+=0x1){_0x5a8661=_0x417068[_0x50750f][_0xd46e('0x73')]?_0x52e73e[_0x417068[_0x50750f][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x417068[_0x50750f][_0xd46e('0x6a')];_0x5a8661=_0x417068[_0x50750f][_0xd46e('0x75')]?_[_0xd46e('0x76')](_0x368742[_0x417068[_0x50750f][_0xd46e('0x75')]],'%s',_0x5a8661):_0x5a8661;_0x5a8661=_0x417068[_0x50750f]['format']?_[_0xd46e('0x76')](_0x285cf8[_0x417068[_0x50750f][_0xd46e('0x77')]],'%s',_0x5a8661):_0x5a8661;if(_0x417068[_0x50750f]['groupBy']){_0x157fb0[_0xd46e('0x69')](_0x5a8661);}_0x417068[_0x50750f][_0xd46e('0x79')]&&_0x157fb0[_0xd46e('0x7a')](_0x5a8661,_0x417068[_0x50750f][_0xd46e('0x79')]===_0xd46e('0x8b')?![]:!![]);_0x157fb0[_0xd46e('0x6a')](_0x5a8661,_0x417068[_0x50750f][_0xd46e('0x7b')]||_0x5a8661);}if(_0x3a44da[_0xd46e('0x7c')]){_0x3a44da['joins']=JSON[_0xd46e('0x82')](_0x3a44da[_0xd46e('0x7c')]);for(var _0x3c819b=0x0;_0x3c819b<_0x3a44da[_0xd46e('0x7c')][_0xd46e('0x3d')];_0x3c819b+=0x1){if(_0x3a44da['joins'][_0x3c819b][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0x20cc4c,_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x36')])&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7d')]&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')]&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b]['foreignKey']){_0x157fb0[_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x36')]](_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')],null,util['format']('%s.%s\x20=\x20%s.%s',_0x3a44da[_0xd46e('0x72')],_0x3a44da['joins'][_0x3c819b][_0xd46e('0x7d')],_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')],_0x3a44da[_0xd46e('0x7c')][_0x3c819b]['foreignKey']));}}}if(_0x3a44da[_0xd46e('0x81')]){_0x3a44da[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0x3a44da[_0xd46e('0x81')]);_0x157fb0[_0xd46e('0x41')](_0x44322f(_0x3a44da[_0xd46e('0x81')][_0xd46e('0x69')]));}_0xe729b6=_0x157fb0[_0xd46e('0x83')]();_0x157fb0[_0xd46e('0x1f')](_0x1610bd);_0x157fb0['offset'](0x0);logger['debug'](_0xd46e('0xa4'),_0x157fb0['toString']());return dbH[_0xd46e('0x9e')][_0xd46e('0x38')](_0x157fb0[_0xd46e('0x84')](),{'type':dbH['sequelize'][_0xd46e('0x85')][_0xd46e('0x86')]});}})[_0xd46e('0x27')](function(){return{'sql':_0xe729b6['toString']()};})['then'](respondWithResult(_0x537c73,null))[_0xd46e('0x4a')](handleError(_0x537c73,null));};
\ No newline at end of file