Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 312d70f..29aefdd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbc48=['key','model','keys','query','filters','intersection','fields','attributes','nolimit','sort','pick','filter','where','merge','options','includeAll','findAll','rows','catch','show','params','rawAttributes','include','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','UserProfileSection','autoAssociation','DefaultReports','join','right_join','SUM(%s)','COUNT(%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','IS\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','length','operator','group','field','condition','value','getFields','Sequelize','Please\x20insert\x20at\x20least\x20one\x20field','select','from','table','MetricId','function','replace','format','groupBy','alias','joins','includes','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','parentKey','conditions','parse','Limited\x20Query:','toString','sequelize','QueryTypes','GROUP_CONCAT(%s)','ValidationErrorItem','AnalyticMetric','keyBy','metric','orderBy','order','DESC','clone','output','web','fullPath','generate','csv','default','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','child_process','fork','../../components/export/','savename','countTable','COUNT(*)','SELECT','run','left_join','COUNT(DISTINCT\x20%s)','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','lodash','jsforce','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','end','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','AnalyticDefaultReport','type'];(function(_0x5b42a3,_0x5b98b5){var _0x1ccb19=function(_0x127155){while(--_0x127155){_0x5b42a3['push'](_0x5b42a3['shift']());}};_0x1ccb19(++_0x5b98b5);}(_0xbc48,0x111));var _0x8bc4=function(_0x2ac24f,_0x5a1436){_0x2ac24f=_0x2ac24f-0x0;var _0x3dcb45=_0xbc48[_0x2ac24f];return _0x3dcb45;};'use strict';var emlformat=require(_0x8bc4('0x0'));var rimraf=require(_0x8bc4('0x1'));var zipdir=require(_0x8bc4('0x2'));var jsonpatch=require(_0x8bc4('0x3'));var rp=require('request-promise');var moment=require(_0x8bc4('0x4'));var BPromise=require(_0x8bc4('0x5'));var Mustache=require(_0x8bc4('0x6'));var util=require(_0x8bc4('0x7'));var path=require('path');var sox=require(_0x8bc4('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x8bc4('0x9'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x8bc4('0xa'));var deskjs=require('desk.js');var toCsv=require(_0x8bc4('0xb'));var querystring=require(_0x8bc4('0xc'));var Papa=require(_0x8bc4('0xd'));var Redis=require(_0x8bc4('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x8bc4('0xf'));var as=require(_0x8bc4('0x10'));var hardwareService=require(_0x8bc4('0x11'));var logger=require(_0x8bc4('0x12'))(_0x8bc4('0x13'));var utils=require(_0x8bc4('0x14'));var config=require(_0x8bc4('0x15'));var licenseUtil=require(_0x8bc4('0x16'));var db=require(_0x8bc4('0x17'))['db'];var dbH=require(_0x8bc4('0x17'))[_0x8bc4('0x18')];function respondWithStatusCode(_0x1ec0e2,_0x80c304){_0x80c304=_0x80c304||0xcc;return function(_0x452a05){if(_0x452a05){return _0x1ec0e2[_0x8bc4('0x19')](_0x80c304);}return _0x1ec0e2['status'](_0x80c304)[_0x8bc4('0x1a')]();};}function respondWithResult(_0x198f18,_0x1bffd0){_0x1bffd0=_0x1bffd0||0xc8;return function(_0xca2e4b){if(_0xca2e4b){return _0x198f18[_0x8bc4('0x1b')](_0x1bffd0)[_0x8bc4('0x1c')](_0xca2e4b);}};}function respondWithFilteredResult(_0x5cd8f7,_0x4d2530){return function(_0x50e59b){if(_0x50e59b){var _0x36714f=typeof _0x4d2530['offset']===_0x8bc4('0x1d')&&typeof _0x4d2530[_0x8bc4('0x1e')]===_0x8bc4('0x1d');var _0x5982e6=_0x50e59b[_0x8bc4('0x1f')];var _0x968929=_0x36714f?0x0:_0x4d2530['offset'];var _0x1c8d5b=_0x36714f?_0x50e59b['count']:_0x4d2530[_0x8bc4('0x20')]+_0x4d2530['limit'];var _0x5c3835;if(_0x1c8d5b>=_0x5982e6){_0x1c8d5b=_0x5982e6;_0x5c3835=0xc8;}else{_0x5c3835=0xce;}_0x5cd8f7[_0x8bc4('0x1b')](_0x5c3835);return _0x5cd8f7[_0x8bc4('0x21')](_0x8bc4('0x22'),_0x968929+'-'+_0x1c8d5b+'/'+_0x5982e6)[_0x8bc4('0x1c')](_0x50e59b);}return null;};}function patchUpdates(_0x1af8da){return function(_0xf0a578){try{jsonpatch[_0x8bc4('0x23')](_0xf0a578,_0x1af8da,!![]);}catch(_0x37eaac){return BPromise[_0x8bc4('0x24')](_0x37eaac);}return _0xf0a578[_0x8bc4('0x25')]();};}function saveUpdates(_0x148fda,_0x4fd827){return function(_0x2a68c9){if(_0x2a68c9){return _0x2a68c9[_0x8bc4('0x26')](_0x148fda)[_0x8bc4('0x27')](function(_0x546d83){return _0x546d83;});}return null;};}function removeEntity(_0x327e90,_0x247eb8){return function(_0x53aa1b){if(_0x53aa1b){return _0x53aa1b[_0x8bc4('0x28')]()[_0x8bc4('0x27')](function(){var _0x45118c=_0x53aa1b['get']({'plain':!![]});var _0x324e59='DefaultReports';return db['UserProfileResource'][_0x8bc4('0x28')]({'where':{'type':_0x324e59,'resourceId':_0x45118c['id']}})[_0x8bc4('0x27')](function(){return _0x53aa1b;});})[_0x8bc4('0x27')](function(){_0x327e90[_0x8bc4('0x1b')](0xcc)[_0x8bc4('0x1a')]();});}};}function handleEntityNotFound(_0x14c7ec,_0x26133e){return function(_0x30f783){if(!_0x30f783){_0x14c7ec['sendStatus'](0x194);}return _0x30f783;};}function handleError(_0x56f462,_0x2f9cf4){_0x2f9cf4=_0x2f9cf4||0x1f4;return function(_0x39f657){logger[_0x8bc4('0x29')](_0x39f657[_0x8bc4('0x2a')]);if(_0x39f657[_0x8bc4('0x2b')]){delete _0x39f657[_0x8bc4('0x2b')];}_0x56f462['status'](_0x2f9cf4)[_0x8bc4('0x2c')](_0x39f657);};}exports[_0x8bc4('0x2d')]=function(_0xb006b8,_0x26452e){var _0x5b1504={},_0xfc99d8={},_0x1a0947={'count':0x0,'rows':[]};var _0x18de85=_[_0x8bc4('0x2e')](db[_0x8bc4('0x2f')]['rawAttributes'],function(_0x23368a){return{'name':_0x23368a['fieldName'],'type':_0x23368a[_0x8bc4('0x30')][_0x8bc4('0x31')]};});_0xfc99d8[_0x8bc4('0x32')]=_[_0x8bc4('0x2e')](_0x18de85,'name');_0xfc99d8['query']=_[_0x8bc4('0x33')](_0xb006b8[_0x8bc4('0x34')]);_0xfc99d8[_0x8bc4('0x35')]=_[_0x8bc4('0x36')](_0xfc99d8['model'],_0xfc99d8['query']);_0x5b1504['attributes']=_[_0x8bc4('0x36')](_0xfc99d8[_0x8bc4('0x32')],qs[_0x8bc4('0x37')](_0xb006b8['query']['fields']));_0x5b1504['attributes']=_0x5b1504['attributes']['length']?_0x5b1504[_0x8bc4('0x38')]:_0xfc99d8[_0x8bc4('0x32')];if(!_0xb006b8[_0x8bc4('0x34')]['hasOwnProperty'](_0x8bc4('0x39'))){_0x5b1504[_0x8bc4('0x1e')]=qs[_0x8bc4('0x1e')](_0xb006b8['query'][_0x8bc4('0x1e')]);_0x5b1504[_0x8bc4('0x20')]=qs[_0x8bc4('0x20')](_0xb006b8[_0x8bc4('0x34')][_0x8bc4('0x20')]);}_0x5b1504['order']=qs[_0x8bc4('0x3a')](_0xb006b8[_0x8bc4('0x34')][_0x8bc4('0x3a')]);_0x5b1504['where']=qs[_0x8bc4('0x35')](_[_0x8bc4('0x3b')](_0xb006b8[_0x8bc4('0x34')],_0xfc99d8[_0x8bc4('0x35')]),_0x18de85);if(_0xb006b8[_0x8bc4('0x34')][_0x8bc4('0x3c')]){_0x5b1504[_0x8bc4('0x3d')]=_[_0x8bc4('0x3e')](_0x5b1504[_0x8bc4('0x3d')],{'$or':_[_0x8bc4('0x2e')](_0x18de85,function(_0x20466d){if(_0x20466d['type']!=='VIRTUAL'){var _0x405142={};_0x405142[_0x20466d[_0x8bc4('0x2b')]]={'$like':'%'+_0xb006b8['query'][_0x8bc4('0x3c')]+'%'};return _0x405142;}})});}_0x5b1504=_[_0x8bc4('0x3e')]({},_0x5b1504,_0xb006b8[_0x8bc4('0x3f')]);var _0x563d01={'where':_0x5b1504['where']};return db[_0x8bc4('0x2f')][_0x8bc4('0x1f')](_0x563d01)[_0x8bc4('0x27')](function(_0x46dc4d){_0x1a0947[_0x8bc4('0x1f')]=_0x46dc4d;if(_0xb006b8[_0x8bc4('0x34')][_0x8bc4('0x40')]){_0x5b1504['include']=[{'all':!![]}];}return db['AnalyticDefaultReport'][_0x8bc4('0x41')](_0x5b1504);})['then'](function(_0x5eb5e0){_0x1a0947[_0x8bc4('0x42')]=_0x5eb5e0;return _0x1a0947;})[_0x8bc4('0x27')](respondWithFilteredResult(_0x26452e,_0x5b1504))[_0x8bc4('0x43')](handleError(_0x26452e,null));};exports[_0x8bc4('0x44')]=function(_0x43804,_0x376710){var _0x5d6ddc={'raw':!![],'where':{'id':_0x43804[_0x8bc4('0x45')]['id']}},_0xa656f9={};_0xa656f9['model']=_[_0x8bc4('0x33')](db['AnalyticDefaultReport'][_0x8bc4('0x46')]);_0xa656f9['query']=_[_0x8bc4('0x33')](_0x43804[_0x8bc4('0x34')]);_0xa656f9[_0x8bc4('0x35')]=_['intersection'](_0xa656f9[_0x8bc4('0x32')],_0xa656f9[_0x8bc4('0x34')]);_0x5d6ddc[_0x8bc4('0x38')]=_[_0x8bc4('0x36')](_0xa656f9['model'],qs['fields'](_0x43804[_0x8bc4('0x34')][_0x8bc4('0x37')]));_0x5d6ddc[_0x8bc4('0x38')]=_0x5d6ddc['attributes']['length']?_0x5d6ddc[_0x8bc4('0x38')]:_0xa656f9['model'];if(_0x43804[_0x8bc4('0x34')][_0x8bc4('0x40')]){_0x5d6ddc[_0x8bc4('0x47')]=[{'all':!![]}];}_0x5d6ddc=_[_0x8bc4('0x3e')]({},_0x5d6ddc,_0x43804[_0x8bc4('0x3f')]);return db[_0x8bc4('0x2f')][_0x8bc4('0x48')](_0x5d6ddc)[_0x8bc4('0x27')](handleEntityNotFound(_0x376710,null))[_0x8bc4('0x27')](respondWithResult(_0x376710,null))[_0x8bc4('0x43')](handleError(_0x376710,null));};exports[_0x8bc4('0x49')]=function(_0x3386a1,_0x7007f4){return db[_0x8bc4('0x2f')][_0x8bc4('0x49')](_0x3386a1[_0x8bc4('0x4a')],{})['then'](function(_0x1b89c3){var _0x1ec8bb=_0x3386a1[_0x8bc4('0x4b')][_0x8bc4('0x4c')]({'plain':!![]});if(!_0x1ec8bb)throw new Error(_0x8bc4('0x4d'));if(_0x1ec8bb[_0x8bc4('0x4e')]===_0x8bc4('0x4b')){var _0x277c39=_0x1b89c3['get']({'plain':!![]});var _0x425315=_0x8bc4('0x4f');return db[_0x8bc4('0x50')][_0x8bc4('0x48')]({'where':{'name':_0x425315,'userProfileId':_0x1ec8bb['userProfileId']},'raw':!![]})[_0x8bc4('0x27')](function(_0x47d108){if(_0x47d108&&_0x47d108[_0x8bc4('0x51')]===0x0){return db['UserProfileResource'][_0x8bc4('0x49')]({'name':_0x277c39[_0x8bc4('0x2b')],'resourceId':_0x277c39['id'],'type':_0x8bc4('0x52'),'sectionId':_0x47d108['id']},{})['then'](function(){return _0x1b89c3;});}else{return _0x1b89c3;}})[_0x8bc4('0x43')](function(_0x2f6160){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2f6160);throw _0x2f6160;});}return _0x1b89c3;})[_0x8bc4('0x27')](respondWithResult(_0x7007f4,0xc9))['catch'](handleError(_0x7007f4,null));};exports[_0x8bc4('0x26')]=function(_0xc4f351,_0x78a7f){if(_0xc4f351['body']['id']){delete _0xc4f351[_0x8bc4('0x4a')]['id'];}return db['AnalyticDefaultReport'][_0x8bc4('0x48')]({'where':{'id':_0xc4f351[_0x8bc4('0x45')]['id']}})[_0x8bc4('0x27')](handleEntityNotFound(_0x78a7f,null))['then'](saveUpdates(_0xc4f351[_0x8bc4('0x4a')],null))[_0x8bc4('0x27')](respondWithResult(_0x78a7f,null))['catch'](handleError(_0x78a7f,null));};exports[_0x8bc4('0x28')]=function(_0x5808a9,_0x4612b5){return db[_0x8bc4('0x2f')][_0x8bc4('0x48')]({'where':{'id':_0x5808a9[_0x8bc4('0x45')]['id']}})[_0x8bc4('0x27')](handleEntityNotFound(_0x4612b5,null))['then'](removeEntity(_0x4612b5,null))[_0x8bc4('0x43')](handleError(_0x4612b5,null));};exports['preview']=function(_0x241579,_0x5bf54e){var _0x54aeea=0xa;var _0x5e05f0=[_0x8bc4('0x53'),'left_join',_0x8bc4('0x54'),'cross_join'];var _0x579c0e={'SUM':_0x8bc4('0x55'),'COUNT':_0x8bc4('0x56'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x8bc4('0x57'),'MIN':_0x8bc4('0x58'),'AVG':_0x8bc4('0x59'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0x8bc4('0x5a'),'GROUP_CONCAT DESC':_0x8bc4('0x5b')};var _0x2c6396={'SEC_TO_TIME':_0x8bc4('0x5c'),'DATE':_0x8bc4('0x5d'),'HOUR':_0x8bc4('0x5e'),'ROUND':_0x8bc4('0x5f'),'UNIX_TIMESTAMP':_0x8bc4('0x60')};var _0xc224b=function(_0x35a8cb){return!_['includes']([_0x8bc4('0x61'),'IS\x20NOT\x20NULL',_0x8bc4('0x62'),_0x8bc4('0x63')],_0x35a8cb);};var _0x287e05=function(_0x1076ff){if(!_0x1076ff||!_0x1076ff[_0x8bc4('0x64')]['length']){return'';}for(var _0x527df1='(',_0x2aa807=0x0;_0x2aa807<_0x1076ff['rules'][_0x8bc4('0x65')];_0x2aa807+=0x1){_0x2aa807>0x0&&(_0x527df1+='\x20'+_0x1076ff[_0x8bc4('0x66')]+'\x20');_0x527df1+=_0x1076ff[_0x8bc4('0x64')][_0x2aa807]['group']?_0x287e05(_0x1076ff[_0x8bc4('0x64')][_0x2aa807][_0x8bc4('0x67')]):_0x1076ff[_0x8bc4('0x64')][_0x2aa807][_0x8bc4('0x68')]+'\x20'+_0x1076ff['rules'][_0x2aa807][_0x8bc4('0x69')]+(_0xc224b(_0x1076ff[_0x8bc4('0x64')][_0x2aa807]['condition'])?'\x20'+_0x1076ff['rules'][_0x2aa807][_0x8bc4('0x6a')]:'');}return _0x527df1+')';};var _0x3d7962={'where':{'id':_0x241579[_0x8bc4('0x45')]['id']}},_0x8f7887,_0x4a425f,_0xa7a7e0,_0x51b583,_0x4c0d0a;_0x3d7962=_[_0x8bc4('0x3e')]({},_0x3d7962,_0x241579[_0x8bc4('0x3f')]);return db[_0x8bc4('0x2f')]['find'](_0x3d7962)[_0x8bc4('0x27')](function(_0x4fec47){if(_0x4fec47){_0x8f7887=_0x4fec47;return _0x4fec47[_0x8bc4('0x6b')]();}return null;})[_0x8bc4('0x27')](function(_0x36e75b){if(_0x36e75b){if(!_0x36e75b[_0x8bc4('0x65')]){throw new db[(_0x8bc4('0x6c'))]['ValidationErrorItem'](_0x8bc4('0x6d'),0x193);}_0x4a425f=_0x36e75b;return db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0x8bc4('0x27')](function(_0x582eb9){if(_0x582eb9){_0xa7a7e0=_['keyBy'](_0x582eb9,'id');var _0x3654a7;var _0xfe2a76=squel[_0x8bc4('0x6e')]();_0xfe2a76[_0x8bc4('0x6f')](_0x8f7887[_0x8bc4('0x70')]);for(var _0x3dc90d=0x0;_0x3dc90d<_0x4a425f[_0x8bc4('0x65')];_0x3dc90d+=0x1){_0x3654a7=_0x4a425f[_0x3dc90d][_0x8bc4('0x71')]?_0xa7a7e0[_0x4a425f[_0x3dc90d][_0x8bc4('0x71')]]['metric']:_0x4a425f[_0x3dc90d][_0x8bc4('0x68')];_0x3654a7=_0x4a425f[_0x3dc90d][_0x8bc4('0x72')]?_[_0x8bc4('0x73')](_0x579c0e[_0x4a425f[_0x3dc90d][_0x8bc4('0x72')]],'%s',_0x3654a7):_0x3654a7;_0x3654a7=_0x4a425f[_0x3dc90d][_0x8bc4('0x74')]?_[_0x8bc4('0x73')](_0x2c6396[_0x4a425f[_0x3dc90d]['format']],'%s',_0x3654a7):_0x3654a7;if(_0x4a425f[_0x3dc90d][_0x8bc4('0x75')]){_0xfe2a76[_0x8bc4('0x67')](_0x3654a7);}_0x4a425f[_0x3dc90d]['orderBy']&&_0xfe2a76['order'](_0x3654a7,_0x4a425f[_0x3dc90d]['orderBy']==='DESC'?![]:!![]);_0xfe2a76[_0x8bc4('0x68')](_0x3654a7,_0x4a425f[_0x3dc90d][_0x8bc4('0x76')]||_0x3654a7);}if(_0x8f7887[_0x8bc4('0x77')]){_0x8f7887['joins']=JSON['parse'](_0x8f7887[_0x8bc4('0x77')]);for(var _0x188a60=0x0;_0x188a60<_0x8f7887[_0x8bc4('0x77')][_0x8bc4('0x65')];_0x188a60+=0x1){if(_0x8f7887[_0x8bc4('0x77')][_0x188a60][_0x8bc4('0x30')]&&_[_0x8bc4('0x78')](_0x5e05f0,_0x8f7887[_0x8bc4('0x77')][_0x188a60][_0x8bc4('0x30')])&&_0x8f7887[_0x8bc4('0x77')][_0x188a60]['parentKey']&&_0x8f7887[_0x8bc4('0x77')][_0x188a60][_0x8bc4('0x79')]&&_0x8f7887[_0x8bc4('0x77')][_0x188a60][_0x8bc4('0x7a')]){_0xfe2a76[_0x8f7887['joins'][_0x188a60]['type']](_0x8f7887[_0x8bc4('0x77')][_0x188a60][_0x8bc4('0x79')],null,util[_0x8bc4('0x74')](_0x8bc4('0x7b'),_0x8f7887[_0x8bc4('0x70')],_0x8f7887[_0x8bc4('0x77')][_0x188a60][_0x8bc4('0x7c')],_0x8f7887[_0x8bc4('0x77')][_0x188a60][_0x8bc4('0x79')],_0x8f7887['joins'][_0x188a60][_0x8bc4('0x7a')]));}}}if(_0x8f7887[_0x8bc4('0x7d')]){_0x8f7887[_0x8bc4('0x7d')]=JSON[_0x8bc4('0x7e')](_0x8f7887['conditions']);_0xfe2a76[_0x8bc4('0x3d')](_0x287e05(_0x8f7887[_0x8bc4('0x7d')][_0x8bc4('0x67')]));}_0x4c0d0a=_0xfe2a76['clone']();_0xfe2a76[_0x8bc4('0x1e')](_0x54aeea);_0xfe2a76[_0x8bc4('0x20')](0x0);logger['debug'](_0x8bc4('0x7f'),_0xfe2a76[_0x8bc4('0x80')]());return dbH[_0x8bc4('0x81')][_0x8bc4('0x34')](_0xfe2a76[_0x8bc4('0x80')](),{'type':dbH[_0x8bc4('0x81')][_0x8bc4('0x82')]['SELECT']});}})[_0x8bc4('0x27')](respondWithResult(_0x5bf54e,null))['catch'](handleError(_0x5bf54e,null));};function runReport(_0x39cbdf,_0x174394,_0xf84f90){var _0x2264cd=_0x174394[_0x8bc4('0x2b')];var _0x53a01c=0xa;var _0x282db2=[_0x8bc4('0x53'),'left_join','right_join','cross_join'];var _0x1dd5d1={'SUM':_0x8bc4('0x55'),'COUNT':'COUNT(%s)','COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x8bc4('0x57'),'MIN':'MIN(%s)','AVG':_0x8bc4('0x59'),'GROUP_CONCAT':_0x8bc4('0x83'),'GROUP_CONCAT ASC':_0x8bc4('0x5a'),'GROUP_CONCAT DESC':_0x8bc4('0x5b')};var _0x32858e={'SEC_TO_TIME':_0x8bc4('0x5c'),'DATE':_0x8bc4('0x5d'),'HOUR':_0x8bc4('0x5e'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x2ad2fa=function(_0x2f8d9b){return!_[_0x8bc4('0x78')]([_0x8bc4('0x61'),'IS\x20NOT\x20NULL',_0x8bc4('0x62'),_0x8bc4('0x63')],_0x2f8d9b);};var _0x482fa5=function(_0x2f72b2){if(!_0x2f72b2||!_0x2f72b2['rules']['length']){return'';}for(var _0x313df9='(',_0x3b20a4=0x0;_0x3b20a4<_0x2f72b2[_0x8bc4('0x64')]['length'];_0x3b20a4+=0x1){_0x3b20a4>0x0&&(_0x313df9+='\x20'+_0x2f72b2[_0x8bc4('0x66')]+'\x20');_0x313df9+=_0x2f72b2['rules'][_0x3b20a4][_0x8bc4('0x67')]?_0x482fa5(_0x2f72b2['rules'][_0x3b20a4][_0x8bc4('0x67')]):_0x2f72b2[_0x8bc4('0x64')][_0x3b20a4][_0x8bc4('0x68')]+'\x20'+_0x2f72b2[_0x8bc4('0x64')][_0x3b20a4][_0x8bc4('0x69')]+(_0x2ad2fa(_0x2f72b2[_0x8bc4('0x64')][_0x3b20a4][_0x8bc4('0x69')])?'\x20'+_0x2f72b2['rules'][_0x3b20a4][_0x8bc4('0x6a')]:'');}return _0x313df9+')';};var _0x40811e={'where':{'id':_0x39cbdf['id']}},_0x585b04,_0x46ac46,_0x4484a0,_0x590790,_0x105dbe;_0x40811e=_[_0x8bc4('0x3e')]({},_0x40811e,_0xf84f90);return db[_0x8bc4('0x2f')][_0x8bc4('0x48')](_0x40811e)[_0x8bc4('0x27')](function(_0x4b7c39){if(_0x4b7c39){_0x585b04=_0x4b7c39;return _0x4b7c39[_0x8bc4('0x6b')]();}return null;})[_0x8bc4('0x27')](function(_0x25759d){if(_0x25759d){if(!_0x25759d[_0x8bc4('0x65')]){throw new db[(_0x8bc4('0x6c'))][(_0x8bc4('0x84'))](_0x8bc4('0x6d'),0x193);}_0x46ac46=_0x25759d;return db[_0x8bc4('0x85')][_0x8bc4('0x41')]({'raw':!![]});}return null;})['then'](function(_0x3871c6){if(_0x3871c6){_0x4484a0=_[_0x8bc4('0x86')](_0x3871c6,'id');var _0x6232ca;var _0x557a51=squel[_0x8bc4('0x6e')]();_0x557a51[_0x8bc4('0x6f')](_0x585b04[_0x8bc4('0x70')]);for(var _0x54086a=0x0;_0x54086a<_0x46ac46[_0x8bc4('0x65')];_0x54086a+=0x1){_0x6232ca=_0x46ac46[_0x54086a]['MetricId']?_0x4484a0[_0x46ac46[_0x54086a][_0x8bc4('0x71')]][_0x8bc4('0x87')]:_0x46ac46[_0x54086a][_0x8bc4('0x68')];_0x6232ca=_0x46ac46[_0x54086a][_0x8bc4('0x72')]?_[_0x8bc4('0x73')](_0x1dd5d1[_0x46ac46[_0x54086a][_0x8bc4('0x72')]],'%s',_0x6232ca):_0x6232ca;_0x6232ca=_0x46ac46[_0x54086a]['format']?_['replace'](_0x32858e[_0x46ac46[_0x54086a][_0x8bc4('0x74')]],'%s',_0x6232ca):_0x6232ca;if(_0x46ac46[_0x54086a][_0x8bc4('0x75')]){_0x557a51[_0x8bc4('0x67')](_0x6232ca);}_0x46ac46[_0x54086a][_0x8bc4('0x88')]&&_0x557a51[_0x8bc4('0x89')](_0x6232ca,_0x46ac46[_0x54086a]['orderBy']===_0x8bc4('0x8a')?![]:!![]);_0x557a51[_0x8bc4('0x68')](_0x6232ca,_0x46ac46[_0x54086a]['alias']||_0x6232ca);}if(_0x585b04[_0x8bc4('0x77')]){_0x585b04[_0x8bc4('0x77')]=JSON['parse'](_0x585b04[_0x8bc4('0x77')]);for(var _0x1f23be=0x0;_0x1f23be<_0x585b04[_0x8bc4('0x77')][_0x8bc4('0x65')];_0x1f23be+=0x1){if(_0x585b04[_0x8bc4('0x77')][_0x1f23be][_0x8bc4('0x30')]&&_[_0x8bc4('0x78')](_0x282db2,_0x585b04[_0x8bc4('0x77')][_0x1f23be][_0x8bc4('0x30')])&&_0x585b04[_0x8bc4('0x77')][_0x1f23be]['parentKey']&&_0x585b04[_0x8bc4('0x77')][_0x1f23be][_0x8bc4('0x79')]&&_0x585b04[_0x8bc4('0x77')][_0x1f23be][_0x8bc4('0x7a')]){_0x557a51[_0x585b04[_0x8bc4('0x77')][_0x1f23be]['type']](_0x585b04[_0x8bc4('0x77')][_0x1f23be][_0x8bc4('0x79')],null,util[_0x8bc4('0x74')](_0x8bc4('0x7b'),_0x585b04[_0x8bc4('0x70')],_0x585b04[_0x8bc4('0x77')][_0x1f23be][_0x8bc4('0x7c')],_0x585b04[_0x8bc4('0x77')][_0x1f23be][_0x8bc4('0x79')],_0x585b04[_0x8bc4('0x77')][_0x1f23be]['foreignKey']));}}}if(_0x585b04[_0x8bc4('0x7d')]){_0x585b04[_0x8bc4('0x7d')]=JSON[_0x8bc4('0x7e')](_0x585b04[_0x8bc4('0x7d')]);_0x557a51['where'](_0x482fa5(_0x585b04[_0x8bc4('0x7d')][_0x8bc4('0x67')]));}_0x105dbe=_0x557a51[_0x8bc4('0x8b')]();_0x557a51[_0x8bc4('0x1e')](_0x53a01c);_0x557a51[_0x8bc4('0x20')](0x0);return;}})[_0x8bc4('0x27')](function(){if(_0x174394[_0x8bc4('0x8c')]===_0x8bc4('0x8d')){return null;}var _0x2d03e3=_[_0x8bc4('0x3e')](_0x174394,{'name':_0x174394[_0x8bc4('0x8e')]||_0x174394['name']||_0x585b04['name'],'basename':_0x2264cd,'savename':util['format']('%s-%s.%s',_0x174394['name']||_0x585b04[_0x8bc4('0x2b')],require('randomstring')[_0x8bc4('0x8f')](0x4),_0x174394[_0x8bc4('0x8c')]||_0x8bc4('0x90')),'reportId':_0x585b04['id'],'reportType':_0x8bc4('0x91')});return db['AnalyticExtractedReport']['create'](_0x2d03e3,{'raw':!![]});})[_0x8bc4('0x27')](function(_0x54b4f){if(_0x585b04[_0x8bc4('0x70')]===_0x8bc4('0x92')){_0x105dbe[_0x8bc4('0x3d')](_0x585b04[_0x8bc4('0x70')]+_0x8bc4('0x93'),_0x174394[_0x8bc4('0x94')],_0x174394['endDate']);}else{_0x105dbe[_0x8bc4('0x3d')](_0x585b04[_0x8bc4('0x70')]+_0x8bc4('0x95'),_0x174394[_0x8bc4('0x94')],_0x174394[_0x8bc4('0x96')]);}if(_0x54b4f){logger['info']('Run\x20Query:',_0x105dbe[_0x8bc4('0x80')]());require(_0x8bc4('0x97'))[_0x8bc4('0x98')](path[_0x8bc4('0x53')](__dirname,_0x8bc4('0x99'),_0x54b4f['output']),[_0x54b4f['id'],_0x105dbe[_0x8bc4('0x80')](),path[_0x8bc4('0x53')](__dirname,'../../files/reports',_0x54b4f[_0x8bc4('0x9a')]),_0x2264cd]);return _0x54b4f;}else{var _0xf752e1=squel[_0x8bc4('0x6e')]();_0xf752e1[_0x8bc4('0x6f')]('('+_0x105dbe['toString']()+')',_0x8bc4('0x9b'));_0xf752e1[_0x8bc4('0x68')](_0x8bc4('0x9c'),_0x8bc4('0x1f'));_0x105dbe[_0x8bc4('0x1e')](_0x174394[_0x8bc4('0x1e')]||_0x53a01c);_0x105dbe[_0x8bc4('0x20')](_0x174394[_0x8bc4('0x20')]||0x0);return dbH[_0x8bc4('0x81')][_0x8bc4('0x34')](_0xf752e1[_0x8bc4('0x80')](),{'type':dbH['sequelize'][_0x8bc4('0x82')][_0x8bc4('0x9d')]})['then'](function(_0x12bb1d){if(!_0x12bb1d['length']){_0x590790=0x0;}else{_0x590790=_0x12bb1d[0x0][_0x8bc4('0x1f')]||0x0;}return dbH[_0x8bc4('0x81')][_0x8bc4('0x34')](_0x105dbe['toString'](),{'type':dbH[_0x8bc4('0x81')][_0x8bc4('0x82')]['SELECT']});})['then'](function(_0x5b86f0){return{'rows':_0x5b86f0||[],'count':_0x590790};});}});}exports[_0x8bc4('0x9e')]=function(_0x1701c2,_0x37d488){return runReport(_0x1701c2[_0x8bc4('0x45')],_0x1701c2[_0x8bc4('0x34')],_0x1701c2[_0x8bc4('0x3f')])[_0x8bc4('0x27')](respondWithResult(_0x37d488,null))[_0x8bc4('0x43')](handleError(_0x37d488,null));};exports['runReport']=runReport;exports[_0x8bc4('0x34')]=function(_0x544b76,_0x23bb9b){var _0x2c88ac=0xa;var _0x50b831=[_0x8bc4('0x53'),_0x8bc4('0x9f'),_0x8bc4('0x54'),'cross_join'];var _0x200eb4={'SUM':_0x8bc4('0x55'),'COUNT':_0x8bc4('0x56'),'COUNT DISTINCT':_0x8bc4('0xa0'),'MAX':_0x8bc4('0x57'),'MIN':'MIN(%s)','AVG':_0x8bc4('0x59'),'GROUP_CONCAT':_0x8bc4('0x83'),'GROUP_CONCAT ASC':_0x8bc4('0x5a'),'GROUP_CONCAT DESC':_0x8bc4('0x5b')};var _0x3f6ada={'SEC_TO_TIME':_0x8bc4('0x5c'),'DATE':_0x8bc4('0x5d'),'HOUR':_0x8bc4('0x5e'),'ROUND':_0x8bc4('0x5f'),'UNIX_TIMESTAMP':_0x8bc4('0x60')};var _0x23adad=function(_0xee2873){return!_[_0x8bc4('0x78')](['IS\x20NULL','IS\x20NOT\x20NULL',_0x8bc4('0x62'),_0x8bc4('0x63')],_0xee2873);};var _0x14c93f=function(_0x501074){if(!_0x501074||!_0x501074[_0x8bc4('0x64')][_0x8bc4('0x65')]){return'';}for(var _0x2ff477='(',_0x1489d2=0x0;_0x1489d2<_0x501074[_0x8bc4('0x64')]['length'];_0x1489d2+=0x1){_0x1489d2>0x0&&(_0x2ff477+='\x20'+_0x501074[_0x8bc4('0x66')]+'\x20');_0x2ff477+=_0x501074['rules'][_0x1489d2][_0x8bc4('0x67')]?_0x14c93f(_0x501074[_0x8bc4('0x64')][_0x1489d2][_0x8bc4('0x67')]):_0x501074[_0x8bc4('0x64')][_0x1489d2][_0x8bc4('0x68')]+'\x20'+_0x501074[_0x8bc4('0x64')][_0x1489d2][_0x8bc4('0x69')]+(_0x23adad(_0x501074[_0x8bc4('0x64')][_0x1489d2]['condition'])?'\x20'+_0x501074[_0x8bc4('0x64')][_0x1489d2]['value']:'');}return _0x2ff477+')';};var _0x58349a={'where':{'id':_0x544b76['params']['id']}},_0x4fea71,_0x299542,_0x174047,_0x213a9f,_0xf3c6c2;_0x58349a=_['merge']({},_0x58349a,_0x544b76['options']);return db['AnalyticDefaultReport'][_0x8bc4('0x48')](_0x58349a)['then'](function(_0x145a7e){if(_0x145a7e){_0x4fea71=_0x145a7e;return _0x145a7e[_0x8bc4('0x6b')]();}return null;})[_0x8bc4('0x27')](function(_0x1f779){if(_0x1f779){if(!_0x1f779[_0x8bc4('0x65')]){throw new db[(_0x8bc4('0x6c'))][(_0x8bc4('0x84'))](_0x8bc4('0x6d'),0x193);}_0x299542=_0x1f779;return db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0x8bc4('0x27')](function(_0xf175de){if(_0xf175de){_0x174047=_[_0x8bc4('0x86')](_0xf175de,'id');var _0x50e388;var _0x24e1a3=squel[_0x8bc4('0x6e')]();_0x24e1a3[_0x8bc4('0x6f')](_0x4fea71[_0x8bc4('0x70')]);for(var _0x63c801=0x0;_0x63c801<_0x299542[_0x8bc4('0x65')];_0x63c801+=0x1){_0x50e388=_0x299542[_0x63c801][_0x8bc4('0x71')]?_0x174047[_0x299542[_0x63c801][_0x8bc4('0x71')]][_0x8bc4('0x87')]:_0x299542[_0x63c801][_0x8bc4('0x68')];_0x50e388=_0x299542[_0x63c801][_0x8bc4('0x72')]?_[_0x8bc4('0x73')](_0x200eb4[_0x299542[_0x63c801]['function']],'%s',_0x50e388):_0x50e388;_0x50e388=_0x299542[_0x63c801][_0x8bc4('0x74')]?_['replace'](_0x3f6ada[_0x299542[_0x63c801][_0x8bc4('0x74')]],'%s',_0x50e388):_0x50e388;if(_0x299542[_0x63c801]['groupBy']){_0x24e1a3[_0x8bc4('0x67')](_0x50e388);}_0x299542[_0x63c801][_0x8bc4('0x88')]&&_0x24e1a3[_0x8bc4('0x89')](_0x50e388,_0x299542[_0x63c801][_0x8bc4('0x88')]==='DESC'?![]:!![]);_0x24e1a3[_0x8bc4('0x68')](_0x50e388,_0x299542[_0x63c801][_0x8bc4('0x76')]||_0x50e388);}if(_0x4fea71[_0x8bc4('0x77')]){_0x4fea71['joins']=JSON[_0x8bc4('0x7e')](_0x4fea71[_0x8bc4('0x77')]);for(var _0x889720=0x0;_0x889720<_0x4fea71[_0x8bc4('0x77')][_0x8bc4('0x65')];_0x889720+=0x1){if(_0x4fea71[_0x8bc4('0x77')][_0x889720][_0x8bc4('0x30')]&&_['includes'](_0x50b831,_0x4fea71[_0x8bc4('0x77')][_0x889720]['type'])&&_0x4fea71[_0x8bc4('0x77')][_0x889720][_0x8bc4('0x7c')]&&_0x4fea71['joins'][_0x889720][_0x8bc4('0x79')]&&_0x4fea71[_0x8bc4('0x77')][_0x889720][_0x8bc4('0x7a')]){_0x24e1a3[_0x4fea71[_0x8bc4('0x77')][_0x889720][_0x8bc4('0x30')]](_0x4fea71[_0x8bc4('0x77')][_0x889720][_0x8bc4('0x79')],null,util[_0x8bc4('0x74')](_0x8bc4('0x7b'),_0x4fea71[_0x8bc4('0x70')],_0x4fea71[_0x8bc4('0x77')][_0x889720][_0x8bc4('0x7c')],_0x4fea71[_0x8bc4('0x77')][_0x889720][_0x8bc4('0x79')],_0x4fea71[_0x8bc4('0x77')][_0x889720][_0x8bc4('0x7a')]));}}}if(_0x4fea71[_0x8bc4('0x7d')]){_0x4fea71[_0x8bc4('0x7d')]=JSON[_0x8bc4('0x7e')](_0x4fea71['conditions']);_0x24e1a3['where'](_0x14c93f(_0x4fea71['conditions'][_0x8bc4('0x67')]));}_0xf3c6c2=_0x24e1a3[_0x8bc4('0x8b')]();_0x24e1a3[_0x8bc4('0x1e')](_0x2c88ac);_0x24e1a3[_0x8bc4('0x20')](0x0);logger['debug'](_0x8bc4('0x7f'),_0x24e1a3[_0x8bc4('0x80')]());return dbH['sequelize'][_0x8bc4('0x34')](_0x24e1a3['toString'](),{'type':dbH[_0x8bc4('0x81')][_0x8bc4('0x82')][_0x8bc4('0x9d')]});}})[_0x8bc4('0x27')](function(){return{'sql':_0xf3c6c2[_0x8bc4('0x80')]()};})[_0x8bc4('0x27')](respondWithResult(_0x23bb9b,null))[_0x8bc4('0x43')](handleError(_0x23bb9b,null));};
\ No newline at end of file
+var _0xf494=['name','send','index','map','AnalyticDefaultReport','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','catch','show','includeAll','find','create','body','user','Reports','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','join','left_join','cross_join','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NOT\x20NULL','IS\x20EMPTY','rules','group','field','value','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','table','MetricId','metric','function','replace','format','orderBy','DESC','alias','joins','parse','foreignTable','%s.%s\x20=\x20%s.%s','parentKey','foreignKey','conditions','debug','Limited\x20Query:','sequelize','toString','QueryTypes','right_join','SUM(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','ROUND(%s)','IS\x20NULL','operator','condition','getFields','groupBy','clone','output','fullPath','%s-%s.%s','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','endDate','info','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','SELECT','run','runReport','IS\x20NOT\x20EMPTY','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','reject','save','update','then','destroy','get','DefaultReports','error','stack'];(function(_0x306c0c,_0x184d7f){var _0x118365=function(_0x1fece1){while(--_0x1fece1){_0x306c0c['push'](_0x306c0c['shift']());}};_0x118365(++_0x184d7f);}(_0xf494,0x1c6));var _0x4f49=function(_0x1602c2,_0x47b449){_0x1602c2=_0x1602c2-0x0;var _0x182f40=_0xf494[_0x1602c2];return _0x182f40;};'use strict';var emlformat=require(_0x4f49('0x0'));var rimraf=require(_0x4f49('0x1'));var zipdir=require(_0x4f49('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x4f49('0x3'));var moment=require(_0x4f49('0x4'));var BPromise=require(_0x4f49('0x5'));var Mustache=require(_0x4f49('0x6'));var util=require(_0x4f49('0x7'));var path=require(_0x4f49('0x8'));var sox=require(_0x4f49('0x9'));var csv=require(_0x4f49('0xa'));var ejs=require(_0x4f49('0xb'));var fs=require('fs');var fs_extra=require(_0x4f49('0xc'));var _=require(_0x4f49('0xd'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x4f49('0xe'));var deskjs=require(_0x4f49('0xf'));var toCsv=require(_0x4f49('0xa'));var querystring=require(_0x4f49('0x10'));var Papa=require(_0x4f49('0x11'));var Redis=require(_0x4f49('0x12'));var authService=require(_0x4f49('0x13'));var qs=require(_0x4f49('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4f49('0x15'));var logger=require(_0x4f49('0x16'))('api');var utils=require(_0x4f49('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x4f49('0x18'))['db'];var dbH=require(_0x4f49('0x18'))['dbH'];function respondWithStatusCode(_0x1e1c37,_0x111a8b){_0x111a8b=_0x111a8b||0xcc;return function(_0x1b9145){if(_0x1b9145){return _0x1e1c37[_0x4f49('0x19')](_0x111a8b);}return _0x1e1c37[_0x4f49('0x1a')](_0x111a8b)[_0x4f49('0x1b')]();};}function respondWithResult(_0xfdb477,_0x5c373e){_0x5c373e=_0x5c373e||0xc8;return function(_0x515ace){if(_0x515ace){return _0xfdb477[_0x4f49('0x1a')](_0x5c373e)[_0x4f49('0x1c')](_0x515ace);}};}function respondWithFilteredResult(_0x5878f4,_0x5bdfaf){return function(_0x2f0a0d){if(_0x2f0a0d){var _0x2ecaaa=typeof _0x5bdfaf[_0x4f49('0x1d')]==='undefined'&&typeof _0x5bdfaf[_0x4f49('0x1e')]===_0x4f49('0x1f');var _0x4e85df=_0x2f0a0d['count'];var _0x5bb23b=_0x2ecaaa?0x0:_0x5bdfaf['offset'];var _0x47f1e8=_0x2ecaaa?_0x2f0a0d[_0x4f49('0x20')]:_0x5bdfaf[_0x4f49('0x1d')]+_0x5bdfaf[_0x4f49('0x1e')];var _0x407042;if(_0x47f1e8>=_0x4e85df){_0x47f1e8=_0x4e85df;_0x407042=0xc8;}else{_0x407042=0xce;}_0x5878f4['status'](_0x407042);return _0x5878f4[_0x4f49('0x21')](_0x4f49('0x22'),_0x5bb23b+'-'+_0x47f1e8+'/'+_0x4e85df)[_0x4f49('0x1c')](_0x2f0a0d);}return null;};}function patchUpdates(_0xaab5e7){return function(_0xea82f8){try{jsonpatch['apply'](_0xea82f8,_0xaab5e7,!![]);}catch(_0x3e7e28){return BPromise[_0x4f49('0x23')](_0x3e7e28);}return _0xea82f8[_0x4f49('0x24')]();};}function saveUpdates(_0x53b57d,_0x40755e){return function(_0x1d70a7){if(_0x1d70a7){return _0x1d70a7[_0x4f49('0x25')](_0x53b57d)[_0x4f49('0x26')](function(_0x9d30aa){return _0x9d30aa;});}return null;};}function removeEntity(_0x36187b,_0x559d98){return function(_0x4e9041){if(_0x4e9041){return _0x4e9041[_0x4f49('0x27')]()[_0x4f49('0x26')](function(){var _0x4fedbb=_0x4e9041[_0x4f49('0x28')]({'plain':!![]});var _0x2c1519=_0x4f49('0x29');return db['UserProfileResource'][_0x4f49('0x27')]({'where':{'type':_0x2c1519,'resourceId':_0x4fedbb['id']}})[_0x4f49('0x26')](function(){return _0x4e9041;});})[_0x4f49('0x26')](function(){_0x36187b[_0x4f49('0x1a')](0xcc)[_0x4f49('0x1b')]();});}};}function handleEntityNotFound(_0x122404,_0x4915af){return function(_0x50c571){if(!_0x50c571){_0x122404[_0x4f49('0x19')](0x194);}return _0x50c571;};}function handleError(_0x2c00ee,_0x605c91){_0x605c91=_0x605c91||0x1f4;return function(_0x560050){logger[_0x4f49('0x2a')](_0x560050[_0x4f49('0x2b')]);if(_0x560050[_0x4f49('0x2c')]){delete _0x560050['name'];}_0x2c00ee['status'](_0x605c91)[_0x4f49('0x2d')](_0x560050);};}exports[_0x4f49('0x2e')]=function(_0x7a6ea0,_0x5e7076){var _0x1eaac6={},_0x35aa33={},_0x173657={'count':0x0,'rows':[]};var _0x2ceda4=_[_0x4f49('0x2f')](db[_0x4f49('0x30')][_0x4f49('0x31')],function(_0x45ae19){return{'name':_0x45ae19[_0x4f49('0x32')],'type':_0x45ae19[_0x4f49('0x33')][_0x4f49('0x34')]};});_0x35aa33[_0x4f49('0x35')]=_[_0x4f49('0x2f')](_0x2ceda4,_0x4f49('0x2c'));_0x35aa33[_0x4f49('0x36')]=_[_0x4f49('0x37')](_0x7a6ea0[_0x4f49('0x36')]);_0x35aa33[_0x4f49('0x38')]=_[_0x4f49('0x39')](_0x35aa33['model'],_0x35aa33[_0x4f49('0x36')]);_0x1eaac6[_0x4f49('0x3a')]=_[_0x4f49('0x39')](_0x35aa33[_0x4f49('0x35')],qs[_0x4f49('0x3b')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x3b')]));_0x1eaac6[_0x4f49('0x3a')]=_0x1eaac6[_0x4f49('0x3a')][_0x4f49('0x3c')]?_0x1eaac6[_0x4f49('0x3a')]:_0x35aa33[_0x4f49('0x35')];if(!_0x7a6ea0[_0x4f49('0x36')]['hasOwnProperty'](_0x4f49('0x3d'))){_0x1eaac6[_0x4f49('0x1e')]=qs[_0x4f49('0x1e')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x1e')]);_0x1eaac6[_0x4f49('0x1d')]=qs[_0x4f49('0x1d')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x1d')]);}_0x1eaac6[_0x4f49('0x3e')]=qs[_0x4f49('0x3f')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x3f')]);_0x1eaac6[_0x4f49('0x40')]=qs['filters'](_[_0x4f49('0x41')](_0x7a6ea0[_0x4f49('0x36')],_0x35aa33['filters']),_0x2ceda4);if(_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x42')]){_0x1eaac6['where']=_[_0x4f49('0x43')](_0x1eaac6[_0x4f49('0x40')],{'$or':_[_0x4f49('0x2f')](_0x2ceda4,function(_0x200b1d){if(_0x200b1d[_0x4f49('0x33')]!==_0x4f49('0x44')){var _0x29e910={};_0x29e910[_0x200b1d['name']]={'$like':'%'+_0x7a6ea0['query']['filter']+'%'};return _0x29e910;}})});}_0x1eaac6=_[_0x4f49('0x43')]({},_0x1eaac6,_0x7a6ea0[_0x4f49('0x45')]);var _0x2e4355={'where':_0x1eaac6[_0x4f49('0x40')]};return db[_0x4f49('0x30')][_0x4f49('0x20')](_0x2e4355)[_0x4f49('0x26')](function(_0x23720a){_0x173657[_0x4f49('0x20')]=_0x23720a;if(_0x7a6ea0['query']['includeAll']){_0x1eaac6[_0x4f49('0x46')]=[{'all':!![]}];}return db[_0x4f49('0x30')][_0x4f49('0x47')](_0x1eaac6);})['then'](function(_0x2d6b56){_0x173657['rows']=_0x2d6b56;return _0x173657;})['then'](respondWithFilteredResult(_0x5e7076,_0x1eaac6))[_0x4f49('0x48')](handleError(_0x5e7076,null));};exports[_0x4f49('0x49')]=function(_0x40eadc,_0x497cb8){var _0x287781={'raw':!![],'where':{'id':_0x40eadc['params']['id']}},_0x11b4df={};_0x11b4df[_0x4f49('0x35')]=_['keys'](db[_0x4f49('0x30')][_0x4f49('0x31')]);_0x11b4df[_0x4f49('0x36')]=_['keys'](_0x40eadc[_0x4f49('0x36')]);_0x11b4df[_0x4f49('0x38')]=_[_0x4f49('0x39')](_0x11b4df[_0x4f49('0x35')],_0x11b4df[_0x4f49('0x36')]);_0x287781[_0x4f49('0x3a')]=_[_0x4f49('0x39')](_0x11b4df[_0x4f49('0x35')],qs[_0x4f49('0x3b')](_0x40eadc[_0x4f49('0x36')]['fields']));_0x287781[_0x4f49('0x3a')]=_0x287781[_0x4f49('0x3a')]['length']?_0x287781[_0x4f49('0x3a')]:_0x11b4df['model'];if(_0x40eadc[_0x4f49('0x36')][_0x4f49('0x4a')]){_0x287781[_0x4f49('0x46')]=[{'all':!![]}];}_0x287781=_[_0x4f49('0x43')]({},_0x287781,_0x40eadc['options']);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x287781)[_0x4f49('0x26')](handleEntityNotFound(_0x497cb8,null))[_0x4f49('0x26')](respondWithResult(_0x497cb8,null))[_0x4f49('0x48')](handleError(_0x497cb8,null));};exports[_0x4f49('0x4c')]=function(_0x37fdb7,_0xd282c){return db[_0x4f49('0x30')][_0x4f49('0x4c')](_0x37fdb7[_0x4f49('0x4d')],{})[_0x4f49('0x26')](function(_0x148031){var _0x2104d0=_0x37fdb7[_0x4f49('0x4e')][_0x4f49('0x28')]({'plain':!![]});if(!_0x2104d0)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2104d0['role']===_0x4f49('0x4e')){var _0x197670=_0x148031[_0x4f49('0x28')]({'plain':!![]});var _0xe46c90=_0x4f49('0x4f');return db[_0x4f49('0x50')][_0x4f49('0x4b')]({'where':{'name':_0xe46c90,'userProfileId':_0x2104d0['userProfileId']},'raw':!![]})[_0x4f49('0x26')](function(_0x4ff0a2){if(_0x4ff0a2&&_0x4ff0a2[_0x4f49('0x51')]===0x0){return db[_0x4f49('0x52')][_0x4f49('0x4c')]({'name':_0x197670[_0x4f49('0x2c')],'resourceId':_0x197670['id'],'type':'DefaultReports','sectionId':_0x4ff0a2['id']},{})[_0x4f49('0x26')](function(){return _0x148031;});}else{return _0x148031;}})['catch'](function(_0x52d18c){logger[_0x4f49('0x2a')](_0x4f49('0x53'),_0x52d18c);throw _0x52d18c;});}return _0x148031;})[_0x4f49('0x26')](respondWithResult(_0xd282c,0xc9))[_0x4f49('0x48')](handleError(_0xd282c,null));};exports['update']=function(_0x599c51,_0xd7f47b){if(_0x599c51[_0x4f49('0x4d')]['id']){delete _0x599c51['body']['id'];}return db[_0x4f49('0x30')]['find']({'where':{'id':_0x599c51['params']['id']}})[_0x4f49('0x26')](handleEntityNotFound(_0xd7f47b,null))['then'](saveUpdates(_0x599c51[_0x4f49('0x4d')],null))['then'](respondWithResult(_0xd7f47b,null))[_0x4f49('0x48')](handleError(_0xd7f47b,null));};exports[_0x4f49('0x27')]=function(_0x2472c9,_0x883408){return db[_0x4f49('0x30')][_0x4f49('0x4b')]({'where':{'id':_0x2472c9[_0x4f49('0x54')]['id']}})[_0x4f49('0x26')](handleEntityNotFound(_0x883408,null))['then'](removeEntity(_0x883408,null))[_0x4f49('0x48')](handleError(_0x883408,null));};exports['preview']=function(_0x213608,_0x1f640d){var _0xc4fc6b=0xa;var _0x467f12=[_0x4f49('0x55'),_0x4f49('0x56'),'right_join',_0x4f49('0x57')];var _0xd3689c={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':_0x4f49('0x59'),'MIN':_0x4f49('0x5a'),'AVG':_0x4f49('0x5b'),'GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0x564bf5={'SEC_TO_TIME':_0x4f49('0x5e'),'DATE':_0x4f49('0x5f'),'HOUR':_0x4f49('0x60'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x21807e=function(_0x265988){return!_[_0x4f49('0x62')](['IS\x20NULL',_0x4f49('0x63'),_0x4f49('0x64'),'IS\x20NOT\x20EMPTY'],_0x265988);};var _0x293839=function(_0x17b15){if(!_0x17b15||!_0x17b15[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x28ea73='(',_0x1b80f2=0x0;_0x1b80f2<_0x17b15[_0x4f49('0x65')][_0x4f49('0x3c')];_0x1b80f2+=0x1){_0x1b80f2>0x0&&(_0x28ea73+='\x20'+_0x17b15['operator']+'\x20');_0x28ea73+=_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x66')]?_0x293839(_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x66')]):_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x67')]+'\x20'+_0x17b15[_0x4f49('0x65')][_0x1b80f2]['condition']+(_0x21807e(_0x17b15[_0x4f49('0x65')][_0x1b80f2]['condition'])?'\x20'+_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x68')]:'');}return _0x28ea73+')';};var _0x4714c7={'where':{'id':_0x213608[_0x4f49('0x54')]['id']}},_0xf29378,_0xc7743e,_0x3f2f3f,_0x61a565,_0x297698;_0x4714c7=_[_0x4f49('0x43')]({},_0x4714c7,_0x213608['options']);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x4714c7)[_0x4f49('0x26')](function(_0x2cdaa4){if(_0x2cdaa4){_0xf29378=_0x2cdaa4;return _0x2cdaa4['getFields']();}return null;})['then'](function(_0x28e8ae){if(_0x28e8ae){if(!_0x28e8ae['length']){throw new db[(_0x4f49('0x69'))][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0xc7743e=_0x28e8ae;return db[_0x4f49('0x6c')][_0x4f49('0x47')]({'raw':!![]});}return null;})[_0x4f49('0x26')](function(_0x179431){if(_0x179431){_0x3f2f3f=_[_0x4f49('0x6d')](_0x179431,'id');var _0x3823f0;var _0x3e9b47=squel[_0x4f49('0x6e')]();_0x3e9b47[_0x4f49('0x6f')](_0xf29378[_0x4f49('0x70')]);for(var _0xd53de8=0x0;_0xd53de8<_0xc7743e[_0x4f49('0x3c')];_0xd53de8+=0x1){_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x71')]?_0x3f2f3f[_0xc7743e[_0xd53de8][_0x4f49('0x71')]][_0x4f49('0x72')]:_0xc7743e[_0xd53de8][_0x4f49('0x67')];_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x73')]?_[_0x4f49('0x74')](_0xd3689c[_0xc7743e[_0xd53de8][_0x4f49('0x73')]],'%s',_0x3823f0):_0x3823f0;_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0x564bf5[_0xc7743e[_0xd53de8][_0x4f49('0x75')]],'%s',_0x3823f0):_0x3823f0;if(_0xc7743e[_0xd53de8]['groupBy']){_0x3e9b47[_0x4f49('0x66')](_0x3823f0);}_0xc7743e[_0xd53de8]['orderBy']&&_0x3e9b47[_0x4f49('0x3e')](_0x3823f0,_0xc7743e[_0xd53de8][_0x4f49('0x76')]===_0x4f49('0x77')?![]:!![]);_0x3e9b47[_0x4f49('0x67')](_0x3823f0,_0xc7743e[_0xd53de8][_0x4f49('0x78')]||_0x3823f0);}if(_0xf29378[_0x4f49('0x79')]){_0xf29378[_0x4f49('0x79')]=JSON[_0x4f49('0x7a')](_0xf29378[_0x4f49('0x79')]);for(var _0x541ac6=0x0;_0x541ac6<_0xf29378['joins'][_0x4f49('0x3c')];_0x541ac6+=0x1){if(_0xf29378['joins'][_0x541ac6][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x467f12,_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x33')])&&_0xf29378[_0x4f49('0x79')][_0x541ac6]['parentKey']&&_0xf29378['joins'][_0x541ac6][_0x4f49('0x7b')]&&_0xf29378[_0x4f49('0x79')][_0x541ac6]['foreignKey']){_0x3e9b47[_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x33')]](_0xf29378['joins'][_0x541ac6][_0x4f49('0x7b')],null,util['format'](_0x4f49('0x7c'),_0xf29378[_0x4f49('0x70')],_0xf29378['joins'][_0x541ac6][_0x4f49('0x7d')],_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x7b')],_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x7e')]));}}}if(_0xf29378[_0x4f49('0x7f')]){_0xf29378['conditions']=JSON[_0x4f49('0x7a')](_0xf29378['conditions']);_0x3e9b47[_0x4f49('0x40')](_0x293839(_0xf29378['conditions'][_0x4f49('0x66')]));}_0x297698=_0x3e9b47['clone']();_0x3e9b47[_0x4f49('0x1e')](_0xc4fc6b);_0x3e9b47[_0x4f49('0x1d')](0x0);logger[_0x4f49('0x80')](_0x4f49('0x81'),_0x3e9b47['toString']());return dbH[_0x4f49('0x82')]['query'](_0x3e9b47[_0x4f49('0x83')](),{'type':dbH['sequelize'][_0x4f49('0x84')]['SELECT']});}})['then'](respondWithResult(_0x1f640d,null))[_0x4f49('0x48')](handleError(_0x1f640d,null));};function runReport(_0x20b2be,_0x16cb4d,_0x4c0e7a){var _0x289810=_0x16cb4d[_0x4f49('0x2c')];var _0x5c33c9=0xa;var _0x5d52ae=['join',_0x4f49('0x56'),_0x4f49('0x85'),_0x4f49('0x57')];var _0x87439={'SUM':_0x4f49('0x86'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':_0x4f49('0x59'),'MIN':_0x4f49('0x5a'),'AVG':'AVG(%s)','GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':_0x4f49('0x87'),'GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0x2902a1={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x4f49('0x5f'),'HOUR':_0x4f49('0x60'),'ROUND':_0x4f49('0x88'),'UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x389679=function(_0x5304c3){return!_[_0x4f49('0x62')]([_0x4f49('0x89'),'IS\x20NOT\x20NULL',_0x4f49('0x64'),'IS\x20NOT\x20EMPTY'],_0x5304c3);};var _0x351a33=function(_0x4d72a0){if(!_0x4d72a0||!_0x4d72a0[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x2ef19e='(',_0x6ad599=0x0;_0x6ad599<_0x4d72a0[_0x4f49('0x65')]['length'];_0x6ad599+=0x1){_0x6ad599>0x0&&(_0x2ef19e+='\x20'+_0x4d72a0[_0x4f49('0x8a')]+'\x20');_0x2ef19e+=_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x66')]?_0x351a33(_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['group']):_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['field']+'\x20'+_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['condition']+(_0x389679(_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x8b')])?'\x20'+_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x68')]:'');}return _0x2ef19e+')';};var _0x111e90={'where':{'id':_0x20b2be['id']}},_0xd253ed,_0x323a3a,_0xe0adc3,_0x3a26ff,_0x64f0ee;_0x111e90=_['merge']({},_0x111e90,_0x4c0e7a);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x111e90)[_0x4f49('0x26')](function(_0x299849){if(_0x299849){_0xd253ed=_0x299849;return _0x299849[_0x4f49('0x8c')]();}return null;})[_0x4f49('0x26')](function(_0x55b28b){if(_0x55b28b){if(!_0x55b28b[_0x4f49('0x3c')]){throw new db[(_0x4f49('0x69'))][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0x323a3a=_0x55b28b;return db['AnalyticMetric'][_0x4f49('0x47')]({'raw':!![]});}return null;})['then'](function(_0x3c4e88){if(_0x3c4e88){_0xe0adc3=_[_0x4f49('0x6d')](_0x3c4e88,'id');var _0x5c5d2;var _0xa880a2=squel['select']();_0xa880a2[_0x4f49('0x6f')](_0xd253ed[_0x4f49('0x70')]);for(var _0x11c0a0=0x0;_0x11c0a0<_0x323a3a[_0x4f49('0x3c')];_0x11c0a0+=0x1){_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x71')]?_0xe0adc3[_0x323a3a[_0x11c0a0][_0x4f49('0x71')]][_0x4f49('0x72')]:_0x323a3a[_0x11c0a0][_0x4f49('0x67')];_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x73')]?_[_0x4f49('0x74')](_0x87439[_0x323a3a[_0x11c0a0][_0x4f49('0x73')]],'%s',_0x5c5d2):_0x5c5d2;_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0x2902a1[_0x323a3a[_0x11c0a0][_0x4f49('0x75')]],'%s',_0x5c5d2):_0x5c5d2;if(_0x323a3a[_0x11c0a0][_0x4f49('0x8d')]){_0xa880a2[_0x4f49('0x66')](_0x5c5d2);}_0x323a3a[_0x11c0a0][_0x4f49('0x76')]&&_0xa880a2[_0x4f49('0x3e')](_0x5c5d2,_0x323a3a[_0x11c0a0]['orderBy']===_0x4f49('0x77')?![]:!![]);_0xa880a2[_0x4f49('0x67')](_0x5c5d2,_0x323a3a[_0x11c0a0][_0x4f49('0x78')]||_0x5c5d2);}if(_0xd253ed[_0x4f49('0x79')]){_0xd253ed['joins']=JSON[_0x4f49('0x7a')](_0xd253ed[_0x4f49('0x79')]);for(var _0x594460=0x0;_0x594460<_0xd253ed[_0x4f49('0x79')]['length'];_0x594460+=0x1){if(_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x5d52ae,_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x33')])&&_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7d')]&&_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7b')]&&_0xd253ed[_0x4f49('0x79')][_0x594460]['foreignKey']){_0xa880a2[_0xd253ed['joins'][_0x594460][_0x4f49('0x33')]](_0xd253ed['joins'][_0x594460][_0x4f49('0x7b')],null,util[_0x4f49('0x75')]('%s.%s\x20=\x20%s.%s',_0xd253ed['table'],_0xd253ed[_0x4f49('0x79')][_0x594460]['parentKey'],_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7b')],_0xd253ed[_0x4f49('0x79')][_0x594460]['foreignKey']));}}}if(_0xd253ed[_0x4f49('0x7f')]){_0xd253ed['conditions']=JSON[_0x4f49('0x7a')](_0xd253ed[_0x4f49('0x7f')]);_0xa880a2[_0x4f49('0x40')](_0x351a33(_0xd253ed['conditions'][_0x4f49('0x66')]));}_0x64f0ee=_0xa880a2[_0x4f49('0x8e')]();_0xa880a2[_0x4f49('0x1e')](_0x5c33c9);_0xa880a2['offset'](0x0);return;}})['then'](function(){if(_0x16cb4d[_0x4f49('0x8f')]==='web'){return null;}var _0x2bc9df=_[_0x4f49('0x43')](_0x16cb4d,{'name':_0x16cb4d[_0x4f49('0x90')]||_0x16cb4d['name']||_0xd253ed[_0x4f49('0x2c')],'basename':_0x289810,'savename':util['format'](_0x4f49('0x91'),_0x16cb4d[_0x4f49('0x2c')]||_0xd253ed[_0x4f49('0x2c')],require('randomstring')[_0x4f49('0x92')](0x4),_0x16cb4d[_0x4f49('0x8f')]||_0x4f49('0x93')),'reportId':_0xd253ed['id'],'reportType':_0x4f49('0x94')});return db[_0x4f49('0x95')][_0x4f49('0x4c')](_0x2bc9df,{'raw':!![]});})['then'](function(_0x5b6ac7){if(_0xd253ed[_0x4f49('0x70')]===_0x4f49('0x96')){_0x64f0ee[_0x4f49('0x40')](_0xd253ed[_0x4f49('0x70')]+_0x4f49('0x97'),_0x16cb4d[_0x4f49('0x98')],_0x16cb4d[_0x4f49('0x99')]);}else{_0x64f0ee[_0x4f49('0x40')](_0xd253ed[_0x4f49('0x70')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x16cb4d[_0x4f49('0x98')],_0x16cb4d[_0x4f49('0x99')]);}if(_0x5b6ac7){logger[_0x4f49('0x9a')]('Run\x20Query:',_0x64f0ee[_0x4f49('0x83')]());require(_0x4f49('0x9b'))[_0x4f49('0x9c')](path['join'](__dirname,_0x4f49('0x9d'),_0x5b6ac7[_0x4f49('0x8f')]),[_0x5b6ac7['id'],_0x64f0ee[_0x4f49('0x83')](),path['join'](__dirname,_0x4f49('0x9e'),_0x5b6ac7[_0x4f49('0x9f')]),_0x289810]);return _0x5b6ac7;}else{var _0x5efb11=squel['select']();_0x5efb11[_0x4f49('0x6f')]('('+_0x64f0ee[_0x4f49('0x83')]()+')',_0x4f49('0xa0'));_0x5efb11[_0x4f49('0x67')](_0x4f49('0xa1'),_0x4f49('0x20'));_0x64f0ee['limit'](_0x16cb4d['limit']||_0x5c33c9);_0x64f0ee['offset'](_0x16cb4d[_0x4f49('0x1d')]||0x0);return dbH[_0x4f49('0x82')]['query'](_0x5efb11[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')][_0x4f49('0x84')]['SELECT']})['then'](function(_0x3633b5){if(!_0x3633b5['length']){_0x3a26ff=0x0;}else{_0x3a26ff=_0x3633b5[0x0][_0x4f49('0x20')]||0x0;}return dbH[_0x4f49('0x82')][_0x4f49('0x36')](_0x64f0ee[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')]['QueryTypes'][_0x4f49('0xa2')]});})[_0x4f49('0x26')](function(_0x45c938){return{'rows':_0x45c938||[],'count':_0x3a26ff};});}});}exports[_0x4f49('0xa3')]=function(_0x4a4d75,_0x93e85d){return runReport(_0x4a4d75[_0x4f49('0x54')],_0x4a4d75['query'],_0x4a4d75[_0x4f49('0x45')])[_0x4f49('0x26')](respondWithResult(_0x93e85d,null))[_0x4f49('0x48')](handleError(_0x93e85d,null));};exports[_0x4f49('0xa4')]=runReport;exports[_0x4f49('0x36')]=function(_0x40991b,_0x56290f){var _0x4994b6=0xa;var _0x1c7d87=[_0x4f49('0x55'),_0x4f49('0x56'),_0x4f49('0x85'),_0x4f49('0x57')];var _0x5cd00a={'SUM':_0x4f49('0x86'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':'MAX(%s)','MIN':'MIN(%s)','AVG':_0x4f49('0x5b'),'GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':_0x4f49('0x87'),'GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0xd876f1={'SEC_TO_TIME':_0x4f49('0x5e'),'DATE':_0x4f49('0x5f'),'HOUR':'HOUR(%s)','ROUND':_0x4f49('0x88'),'UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x1ae2c9=function(_0x566634){return!_[_0x4f49('0x62')]([_0x4f49('0x89'),_0x4f49('0x63'),'IS\x20EMPTY',_0x4f49('0xa5')],_0x566634);};var _0x541dc2=function(_0x4061bf){if(!_0x4061bf||!_0x4061bf[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x1bc18d='(',_0x5e6103=0x0;_0x5e6103<_0x4061bf[_0x4f49('0x65')][_0x4f49('0x3c')];_0x5e6103+=0x1){_0x5e6103>0x0&&(_0x1bc18d+='\x20'+_0x4061bf[_0x4f49('0x8a')]+'\x20');_0x1bc18d+=_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x66')]?_0x541dc2(_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x66')]):_0x4061bf[_0x4f49('0x65')][_0x5e6103]['field']+'\x20'+_0x4061bf['rules'][_0x5e6103][_0x4f49('0x8b')]+(_0x1ae2c9(_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x8b')])?'\x20'+_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x68')]:'');}return _0x1bc18d+')';};var _0x29dbab={'where':{'id':_0x40991b[_0x4f49('0x54')]['id']}},_0x5f459b,_0x1d090f,_0x37d2f4,_0x5bcb36,_0x3f04fa;_0x29dbab=_[_0x4f49('0x43')]({},_0x29dbab,_0x40991b['options']);return db['AnalyticDefaultReport'][_0x4f49('0x4b')](_0x29dbab)[_0x4f49('0x26')](function(_0x200848){if(_0x200848){_0x5f459b=_0x200848;return _0x200848['getFields']();}return null;})[_0x4f49('0x26')](function(_0x48f4bc){if(_0x48f4bc){if(!_0x48f4bc[_0x4f49('0x3c')]){throw new db['Sequelize'][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0x1d090f=_0x48f4bc;return db['AnalyticMetric'][_0x4f49('0x47')]({'raw':!![]});}return null;})[_0x4f49('0x26')](function(_0x513bc9){if(_0x513bc9){_0x37d2f4=_[_0x4f49('0x6d')](_0x513bc9,'id');var _0x47567c;var _0x5f1538=squel[_0x4f49('0x6e')]();_0x5f1538[_0x4f49('0x6f')](_0x5f459b[_0x4f49('0x70')]);for(var _0xd91e48=0x0;_0xd91e48<_0x1d090f[_0x4f49('0x3c')];_0xd91e48+=0x1){_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x71')]?_0x37d2f4[_0x1d090f[_0xd91e48]['MetricId']][_0x4f49('0x72')]:_0x1d090f[_0xd91e48][_0x4f49('0x67')];_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x73')]?_['replace'](_0x5cd00a[_0x1d090f[_0xd91e48][_0x4f49('0x73')]],'%s',_0x47567c):_0x47567c;_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0xd876f1[_0x1d090f[_0xd91e48][_0x4f49('0x75')]],'%s',_0x47567c):_0x47567c;if(_0x1d090f[_0xd91e48][_0x4f49('0x8d')]){_0x5f1538[_0x4f49('0x66')](_0x47567c);}_0x1d090f[_0xd91e48][_0x4f49('0x76')]&&_0x5f1538['order'](_0x47567c,_0x1d090f[_0xd91e48][_0x4f49('0x76')]==='DESC'?![]:!![]);_0x5f1538['field'](_0x47567c,_0x1d090f[_0xd91e48][_0x4f49('0x78')]||_0x47567c);}if(_0x5f459b['joins']){_0x5f459b[_0x4f49('0x79')]=JSON[_0x4f49('0x7a')](_0x5f459b[_0x4f49('0x79')]);for(var _0x85eb3f=0x0;_0x85eb3f<_0x5f459b[_0x4f49('0x79')][_0x4f49('0x3c')];_0x85eb3f+=0x1){if(_0x5f459b['joins'][_0x85eb3f][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x1c7d87,_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x33')])&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7d')]&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f]['foreignTable']&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7e')]){_0x5f1538[_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x33')]](_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7b')],null,util[_0x4f49('0x75')](_0x4f49('0x7c'),_0x5f459b[_0x4f49('0x70')],_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7d')],_0x5f459b[_0x4f49('0x79')][_0x85eb3f]['foreignTable'],_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7e')]));}}}if(_0x5f459b['conditions']){_0x5f459b[_0x4f49('0x7f')]=JSON[_0x4f49('0x7a')](_0x5f459b[_0x4f49('0x7f')]);_0x5f1538[_0x4f49('0x40')](_0x541dc2(_0x5f459b[_0x4f49('0x7f')][_0x4f49('0x66')]));}_0x3f04fa=_0x5f1538['clone']();_0x5f1538['limit'](_0x4994b6);_0x5f1538['offset'](0x0);logger['debug'](_0x4f49('0x81'),_0x5f1538['toString']());return dbH[_0x4f49('0x82')][_0x4f49('0x36')](_0x5f1538[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')][_0x4f49('0x84')][_0x4f49('0xa2')]});}})['then'](function(){return{'sql':_0x3f04fa[_0x4f49('0x83')]()};})['then'](respondWithResult(_0x56290f,null))[_0x4f49('0x48')](handleError(_0x56290f,null));};
\ No newline at end of file