Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 534e452..50ef2b3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdbf5=['ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','select','from','table','MetricId','metric','function','replace','format','groupBy','orderBy','DESC','alias','joins','parse','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','clone','debug','Limited\x20Query:','toString','sequelize','QueryTypes','SELECT','left_join','right_join','MIN(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','findAll','keyBy','No\x20available\x20data','output','web','fullPath','%s-%s.%s','randomstring','generate','default','.calldate\x20BETWEEN\x20?\x20AND\x20?','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','startDate','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','runReport','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/license/util','../../mysqldb','dbH','end','status','json','count','offset','limit','set','apply','reject','save','update','then','get','DefaultReports','UserProfileResource','destroy','sendStatus','error','stack','name','index','map','AnalyticDefaultReport','rawAttributes','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','options','include','rows','catch','show','keys','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','Reports','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','params','body','preview','join','cross_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','AVG(%s)','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','value','getFields','Sequelize'];(function(_0x53ccf2,_0x13cb67){var _0x5a2964=function(_0x3b0514){while(--_0x3b0514){_0x53ccf2['push'](_0x53ccf2['shift']());}};_0x5a2964(++_0x13cb67);}(_0xdbf5,0x18c));var _0x5dbf=function(_0x2628cb,_0x1c5223){_0x2628cb=_0x2628cb-0x0;var _0x1e7d8f=_0xdbf5[_0x2628cb];return _0x1e7d8f;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x5dbf('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x5dbf('0x1'));var rp=require(_0x5dbf('0x2'));var moment=require(_0x5dbf('0x3'));var BPromise=require(_0x5dbf('0x4'));var Mustache=require(_0x5dbf('0x5'));var util=require(_0x5dbf('0x6'));var path=require(_0x5dbf('0x7'));var sox=require(_0x5dbf('0x8'));var csv=require(_0x5dbf('0x9'));var ejs=require(_0x5dbf('0xa'));var fs=require('fs');var _=require(_0x5dbf('0xb'));var squel=require(_0x5dbf('0xc'));var crypto=require(_0x5dbf('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x5dbf('0xe'));var toCsv=require('to-csv');var querystring=require(_0x5dbf('0xf'));var Papa=require(_0x5dbf('0x10'));var Redis=require(_0x5dbf('0x11'));var authService=require(_0x5dbf('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x5dbf('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x5dbf('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x5dbf('0x15'));var db=require('../../mysqldb')['db'];var dbH=require(_0x5dbf('0x16'))[_0x5dbf('0x17')];function respondWithStatusCode(_0x1453a9,_0x7cb848){_0x7cb848=_0x7cb848||0xcc;return function(_0x14493a){if(_0x14493a){return _0x1453a9['sendStatus'](_0x7cb848);}return _0x1453a9['status'](_0x7cb848)[_0x5dbf('0x18')]();};}function respondWithResult(_0x3480c8,_0x48e7fd){_0x48e7fd=_0x48e7fd||0xc8;return function(_0x19624e){if(_0x19624e){return _0x3480c8[_0x5dbf('0x19')](_0x48e7fd)[_0x5dbf('0x1a')](_0x19624e);}};}function respondWithFilteredResult(_0x2dfa44,_0x181816){return function(_0x472eb9){if(_0x472eb9){var _0x2d32cc=_0x472eb9[_0x5dbf('0x1b')],_0x50ef1d=_0x181816[_0x5dbf('0x1c')],_0x499cd9=_0x181816[_0x5dbf('0x1c')]+_0x181816[_0x5dbf('0x1d')],_0x16dc82;if(_0x499cd9>=_0x2d32cc){_0x499cd9=_0x2d32cc;_0x16dc82=0xc8;}else{_0x16dc82=0xce;}_0x2dfa44['status'](_0x16dc82);return _0x2dfa44[_0x5dbf('0x1e')]('Content-Range',_0x50ef1d+'-'+_0x499cd9+'/'+_0x2d32cc)['json'](_0x472eb9);}return null;};}function patchUpdates(_0x577ca2){return function(_0x23d1e7){try{jsonpatch[_0x5dbf('0x1f')](_0x23d1e7,_0x577ca2,!![]);}catch(_0x358d46){return BPromise[_0x5dbf('0x20')](_0x358d46);}return _0x23d1e7[_0x5dbf('0x21')]();};}function saveUpdates(_0x5b2518,_0x2764ea){return function(_0x58e9ac){if(_0x58e9ac){return _0x58e9ac[_0x5dbf('0x22')](_0x5b2518)[_0x5dbf('0x23')](function(_0x14d133){return _0x14d133;});}return null;};}function removeEntity(_0x43a612,_0x3b763c){return function(_0x2f154e){if(_0x2f154e){return _0x2f154e['destroy']()[_0x5dbf('0x23')](function(){var _0x3e3a2d=_0x2f154e[_0x5dbf('0x24')]({'plain':!![]});var _0x2079fc=_0x5dbf('0x25');return db[_0x5dbf('0x26')][_0x5dbf('0x27')]({'where':{'type':_0x2079fc,'resourceId':_0x3e3a2d['id']}})[_0x5dbf('0x23')](function(){return _0x2f154e;});})[_0x5dbf('0x23')](function(){_0x43a612[_0x5dbf('0x19')](0xcc)[_0x5dbf('0x18')]();});}};}function handleEntityNotFound(_0x232c77,_0x3f9e60){return function(_0x407741){if(!_0x407741){_0x232c77[_0x5dbf('0x28')](0x194);}return _0x407741;};}function handleError(_0x17f135,_0x466985){_0x466985=_0x466985||0x1f4;return function(_0x3f8341){logger[_0x5dbf('0x29')](_0x3f8341[_0x5dbf('0x2a')]);if(_0x3f8341[_0x5dbf('0x2b')]){delete _0x3f8341[_0x5dbf('0x2b')];}_0x17f135[_0x5dbf('0x19')](_0x466985)['send'](_0x3f8341);};}exports[_0x5dbf('0x2c')]=function(_0x24dc99,_0xc4748){var _0x1fb9a7={},_0x38825a={},_0x6a276d={'count':0x0,'rows':[]};var _0x2a65c5=_[_0x5dbf('0x2d')](db[_0x5dbf('0x2e')][_0x5dbf('0x2f')],function(_0x294dd7){return{'name':_0x294dd7['fieldName'],'type':_0x294dd7['type'][_0x5dbf('0x30')]};});_0x38825a[_0x5dbf('0x31')]=_[_0x5dbf('0x2d')](_0x2a65c5,_0x5dbf('0x2b'));_0x38825a[_0x5dbf('0x32')]=_['keys'](_0x24dc99['query']);_0x38825a[_0x5dbf('0x33')]=_[_0x5dbf('0x34')](_0x38825a['model'],_0x38825a[_0x5dbf('0x32')]);_0x1fb9a7[_0x5dbf('0x35')]=_[_0x5dbf('0x34')](_0x38825a[_0x5dbf('0x31')],qs[_0x5dbf('0x36')](_0x24dc99['query'][_0x5dbf('0x36')]));_0x1fb9a7[_0x5dbf('0x35')]=_0x1fb9a7[_0x5dbf('0x35')][_0x5dbf('0x37')]?_0x1fb9a7[_0x5dbf('0x35')]:_0x38825a['model'];if(!_0x24dc99[_0x5dbf('0x32')][_0x5dbf('0x38')](_0x5dbf('0x39'))){_0x1fb9a7[_0x5dbf('0x1d')]=qs['limit'](_0x24dc99[_0x5dbf('0x32')][_0x5dbf('0x1d')]);_0x1fb9a7[_0x5dbf('0x1c')]=qs[_0x5dbf('0x1c')](_0x24dc99[_0x5dbf('0x32')][_0x5dbf('0x1c')]);}_0x1fb9a7[_0x5dbf('0x3a')]=qs[_0x5dbf('0x3b')](_0x24dc99[_0x5dbf('0x32')][_0x5dbf('0x3b')]);_0x1fb9a7[_0x5dbf('0x3c')]=qs['filters'](_[_0x5dbf('0x3d')](_0x24dc99[_0x5dbf('0x32')],_0x38825a[_0x5dbf('0x33')]),_0x2a65c5);if(_0x24dc99['query'][_0x5dbf('0x3e')]){_0x1fb9a7[_0x5dbf('0x3c')]=_[_0x5dbf('0x3f')](_0x1fb9a7['where'],{'$or':_[_0x5dbf('0x2d')](_0x2a65c5,function(_0x45cb4d){if(_0x45cb4d[_0x5dbf('0x40')]!=='VIRTUAL'){var _0x4527fb={};_0x4527fb[_0x45cb4d[_0x5dbf('0x2b')]]={'$like':'%'+_0x24dc99[_0x5dbf('0x32')][_0x5dbf('0x3e')]+'%'};return _0x4527fb;}})});}_0x1fb9a7=_[_0x5dbf('0x3f')]({},_0x1fb9a7,_0x24dc99[_0x5dbf('0x41')]);var _0x321ae3={'where':_0x1fb9a7[_0x5dbf('0x3c')]};return db['AnalyticDefaultReport']['count'](_0x321ae3)['then'](function(_0x555e61){_0x6a276d[_0x5dbf('0x1b')]=_0x555e61;if(_0x24dc99[_0x5dbf('0x32')]['includeAll']){_0x1fb9a7[_0x5dbf('0x42')]=[{'all':!![]}];}return db[_0x5dbf('0x2e')]['findAll'](_0x1fb9a7);})[_0x5dbf('0x23')](function(_0x9824a0){_0x6a276d[_0x5dbf('0x43')]=_0x9824a0;return _0x6a276d;})[_0x5dbf('0x23')](respondWithFilteredResult(_0xc4748,_0x1fb9a7))[_0x5dbf('0x44')](handleError(_0xc4748,null));};exports[_0x5dbf('0x45')]=function(_0x2745df,_0x1c020a){var _0xf5bdc5={'raw':!![],'where':{'id':_0x2745df['params']['id']}},_0x2718e9={};_0x2718e9[_0x5dbf('0x31')]=_[_0x5dbf('0x46')](db[_0x5dbf('0x2e')]['rawAttributes']);_0x2718e9[_0x5dbf('0x32')]=_[_0x5dbf('0x46')](_0x2745df[_0x5dbf('0x32')]);_0x2718e9[_0x5dbf('0x33')]=_['intersection'](_0x2718e9[_0x5dbf('0x31')],_0x2718e9['query']);_0xf5bdc5[_0x5dbf('0x35')]=_[_0x5dbf('0x34')](_0x2718e9[_0x5dbf('0x31')],qs[_0x5dbf('0x36')](_0x2745df['query']['fields']));_0xf5bdc5[_0x5dbf('0x35')]=_0xf5bdc5[_0x5dbf('0x35')][_0x5dbf('0x37')]?_0xf5bdc5['attributes']:_0x2718e9[_0x5dbf('0x31')];if(_0x2745df['query']['includeAll']){_0xf5bdc5['include']=[{'all':!![]}];}_0xf5bdc5=_['merge']({},_0xf5bdc5,_0x2745df[_0x5dbf('0x41')]);return db[_0x5dbf('0x2e')]['find'](_0xf5bdc5)[_0x5dbf('0x23')](handleEntityNotFound(_0x1c020a,null))[_0x5dbf('0x23')](respondWithResult(_0x1c020a,null))['catch'](handleError(_0x1c020a,null));};exports[_0x5dbf('0x47')]=function(_0x214539,_0x5b6990){return db[_0x5dbf('0x2e')]['create'](_0x214539['body'],{})[_0x5dbf('0x23')](function(_0x2a3d30){var _0x17a1c0=_0x214539['user']['get']({'plain':!![]});if(!_0x17a1c0)throw new Error(_0x5dbf('0x48'));if(_0x17a1c0[_0x5dbf('0x49')]===_0x5dbf('0x4a')){var _0x307a00=_0x2a3d30[_0x5dbf('0x24')]({'plain':!![]});var _0x3c169b=_0x5dbf('0x4b');return db[_0x5dbf('0x4c')]['find']({'where':{'name':_0x3c169b,'userProfileId':_0x17a1c0[_0x5dbf('0x4d')]},'raw':!![]})[_0x5dbf('0x23')](function(_0x2927a3){if(_0x2927a3&&_0x2927a3[_0x5dbf('0x4e')]===0x0){return db[_0x5dbf('0x26')][_0x5dbf('0x47')]({'name':_0x307a00[_0x5dbf('0x2b')],'resourceId':_0x307a00['id'],'type':'DefaultReports','sectionId':_0x2927a3['id']},{})[_0x5dbf('0x23')](function(){return _0x2a3d30;});}else{return _0x2a3d30;}})['catch'](function(_0x32c13d){logger[_0x5dbf('0x29')](_0x5dbf('0x4f'),_0x32c13d);throw _0x32c13d;});}return _0x2a3d30;})[_0x5dbf('0x23')](respondWithResult(_0x5b6990,0xc9))[_0x5dbf('0x44')](handleError(_0x5b6990,null));};exports[_0x5dbf('0x22')]=function(_0x353d0f,_0x48403a){if(_0x353d0f['body']['id']){delete _0x353d0f['body']['id'];}return db[_0x5dbf('0x2e')][_0x5dbf('0x50')]({'where':{'id':_0x353d0f[_0x5dbf('0x51')]['id']}})['then'](handleEntityNotFound(_0x48403a,null))['then'](saveUpdates(_0x353d0f[_0x5dbf('0x52')],null))[_0x5dbf('0x23')](respondWithResult(_0x48403a,null))[_0x5dbf('0x44')](handleError(_0x48403a,null));};exports['destroy']=function(_0x2c9876,_0x56633d){return db[_0x5dbf('0x2e')][_0x5dbf('0x50')]({'where':{'id':_0x2c9876[_0x5dbf('0x51')]['id']}})['then'](handleEntityNotFound(_0x56633d,null))['then'](removeEntity(_0x56633d,null))[_0x5dbf('0x44')](handleError(_0x56633d,null));};exports[_0x5dbf('0x53')]=function(_0x129367,_0x3fd5d5){var _0x4c034f=0xa;var _0xfcc43c=[_0x5dbf('0x54'),'left_join','right_join',_0x5dbf('0x55')];var _0x14bdb1={'SUM':_0x5dbf('0x56'),'COUNT':_0x5dbf('0x57'),'COUNT DISTINCT':_0x5dbf('0x58'),'MAX':_0x5dbf('0x59'),'MIN':'MIN(%s)','AVG':_0x5dbf('0x5a'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x38f253={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x5dbf('0x5b'),'HOUR':_0x5dbf('0x5c'),'ROUND':_0x5dbf('0x5d'),'UNIX_TIMESTAMP':_0x5dbf('0x5e')};var _0x461ffb=function(_0x28d1eb){return!_[_0x5dbf('0x5f')]([_0x5dbf('0x60'),_0x5dbf('0x61'),_0x5dbf('0x62'),_0x5dbf('0x63')],_0x28d1eb);};var _0x2ca889=function(_0x1c1b4b){if(!_0x1c1b4b||!_0x1c1b4b[_0x5dbf('0x64')][_0x5dbf('0x37')]){return'';}for(var _0x53ab1a='(',_0x3fbc3d=0x0;_0x3fbc3d<_0x1c1b4b['rules'][_0x5dbf('0x37')];_0x3fbc3d+=0x1){_0x3fbc3d>0x0&&(_0x53ab1a+='\x20'+_0x1c1b4b[_0x5dbf('0x65')]+'\x20');_0x53ab1a+=_0x1c1b4b[_0x5dbf('0x64')][_0x3fbc3d][_0x5dbf('0x66')]?_0x2ca889(_0x1c1b4b['rules'][_0x3fbc3d][_0x5dbf('0x66')]):_0x1c1b4b[_0x5dbf('0x64')][_0x3fbc3d][_0x5dbf('0x67')]+'\x20'+_0x1c1b4b[_0x5dbf('0x64')][_0x3fbc3d][_0x5dbf('0x68')]+(_0x461ffb(_0x1c1b4b[_0x5dbf('0x64')][_0x3fbc3d]['condition'])?'\x20'+_0x1c1b4b[_0x5dbf('0x64')][_0x3fbc3d][_0x5dbf('0x69')]:'');}return _0x53ab1a+')';};var _0x3b0465={'where':{'id':_0x129367[_0x5dbf('0x51')]['id']}},_0x18bc53,_0x4d18d,_0x3f7508,_0x2870c3,_0x1cc4eb;_0x3b0465=_[_0x5dbf('0x3f')]({},_0x3b0465,_0x129367[_0x5dbf('0x41')]);return db[_0x5dbf('0x2e')]['find'](_0x3b0465)['then'](function(_0x119ae6){if(_0x119ae6){_0x18bc53=_0x119ae6;return _0x119ae6[_0x5dbf('0x6a')]();}return null;})[_0x5dbf('0x23')](function(_0x110713){if(_0x110713){if(!_0x110713[_0x5dbf('0x37')]){throw new db[(_0x5dbf('0x6b'))][(_0x5dbf('0x6c'))](_0x5dbf('0x6d'),0x193);}_0x4d18d=_0x110713;return db[_0x5dbf('0x6e')]['findAll']({'raw':!![]});}return null;})['then'](function(_0x49005c){if(_0x49005c){_0x3f7508=_['keyBy'](_0x49005c,'id');var _0x408b51;var _0x398326=squel[_0x5dbf('0x6f')]();_0x398326[_0x5dbf('0x70')](_0x18bc53[_0x5dbf('0x71')]);for(var _0xe3ad3=0x0;_0xe3ad3<_0x4d18d['length'];_0xe3ad3+=0x1){_0x408b51=_0x4d18d[_0xe3ad3]['MetricId']?_0x3f7508[_0x4d18d[_0xe3ad3][_0x5dbf('0x72')]][_0x5dbf('0x73')]:_0x4d18d[_0xe3ad3]['field'];_0x408b51=_0x4d18d[_0xe3ad3][_0x5dbf('0x74')]?_[_0x5dbf('0x75')](_0x14bdb1[_0x4d18d[_0xe3ad3][_0x5dbf('0x74')]],'%s',_0x408b51):_0x408b51;_0x408b51=_0x4d18d[_0xe3ad3][_0x5dbf('0x76')]?_['replace'](_0x38f253[_0x4d18d[_0xe3ad3][_0x5dbf('0x76')]],'%s',_0x408b51):_0x408b51;if(_0x4d18d[_0xe3ad3][_0x5dbf('0x77')]){_0x398326[_0x5dbf('0x66')](_0x408b51);}_0x4d18d[_0xe3ad3][_0x5dbf('0x78')]&&_0x398326[_0x5dbf('0x3a')](_0x408b51,_0x4d18d[_0xe3ad3]['orderBy']===_0x5dbf('0x79')?![]:!![]);_0x398326[_0x5dbf('0x67')](_0x408b51,_0x4d18d[_0xe3ad3][_0x5dbf('0x7a')]||_0x408b51);}if(_0x18bc53[_0x5dbf('0x7b')]){_0x18bc53['joins']=JSON[_0x5dbf('0x7c')](_0x18bc53['joins']);for(var _0x2ba37f=0x0;_0x2ba37f<_0x18bc53[_0x5dbf('0x7b')][_0x5dbf('0x37')];_0x2ba37f+=0x1){if(_0x18bc53['joins'][_0x2ba37f][_0x5dbf('0x40')]&&_[_0x5dbf('0x5f')](_0xfcc43c,_0x18bc53[_0x5dbf('0x7b')][_0x2ba37f][_0x5dbf('0x40')])&&_0x18bc53['joins'][_0x2ba37f][_0x5dbf('0x7d')]&&_0x18bc53[_0x5dbf('0x7b')][_0x2ba37f][_0x5dbf('0x7e')]&&_0x18bc53[_0x5dbf('0x7b')][_0x2ba37f][_0x5dbf('0x7f')]){_0x398326[_0x18bc53[_0x5dbf('0x7b')][_0x2ba37f]['type']](_0x18bc53[_0x5dbf('0x7b')][_0x2ba37f][_0x5dbf('0x7e')],null,util['format'](_0x5dbf('0x80'),_0x18bc53[_0x5dbf('0x71')],_0x18bc53[_0x5dbf('0x7b')][_0x2ba37f][_0x5dbf('0x7d')],_0x18bc53[_0x5dbf('0x7b')][_0x2ba37f][_0x5dbf('0x7e')],_0x18bc53[_0x5dbf('0x7b')][_0x2ba37f][_0x5dbf('0x7f')]));}}}if(_0x18bc53[_0x5dbf('0x81')]){_0x18bc53[_0x5dbf('0x81')]=JSON[_0x5dbf('0x7c')](_0x18bc53[_0x5dbf('0x81')]);_0x398326[_0x5dbf('0x3c')](_0x2ca889(_0x18bc53[_0x5dbf('0x81')][_0x5dbf('0x66')]));}_0x1cc4eb=_0x398326[_0x5dbf('0x82')]();_0x398326['limit'](_0x4c034f);_0x398326[_0x5dbf('0x1c')](0x0);logger[_0x5dbf('0x83')](_0x5dbf('0x84'),_0x398326[_0x5dbf('0x85')]());return db['sequelize'][_0x5dbf('0x32')](_0x398326[_0x5dbf('0x85')](),{'type':db[_0x5dbf('0x86')][_0x5dbf('0x87')][_0x5dbf('0x88')]});}})['then'](respondWithResult(_0x3fd5d5,null))[_0x5dbf('0x44')](handleError(_0x3fd5d5,null));};function runReport(_0x1ba14c,_0x4e0117,_0x5d02f7){var _0x3dac55=_0x4e0117[_0x5dbf('0x2b')];var _0x1efe3f=0xa;var _0x8ca7de=[_0x5dbf('0x54'),_0x5dbf('0x89'),_0x5dbf('0x8a'),'cross_join'];var _0x310078={'SUM':_0x5dbf('0x56'),'COUNT':_0x5dbf('0x57'),'COUNT DISTINCT':_0x5dbf('0x58'),'MAX':_0x5dbf('0x59'),'MIN':_0x5dbf('0x8b'),'AVG':'AVG(%s)','GROUP_CONCAT':_0x5dbf('0x8c'),'GROUP_CONCAT ASC':_0x5dbf('0x8d'),'GROUP_CONCAT DESC':_0x5dbf('0x8e')};var _0x2c5a6e={'SEC_TO_TIME':_0x5dbf('0x8f'),'DATE':'DATE(%s)','HOUR':_0x5dbf('0x5c'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x5924d2=function(_0x496306){return!_[_0x5dbf('0x5f')]([_0x5dbf('0x60'),_0x5dbf('0x61'),_0x5dbf('0x62'),_0x5dbf('0x63')],_0x496306);};var _0x4cb92d=function(_0x5b9f19){if(!_0x5b9f19||!_0x5b9f19[_0x5dbf('0x64')]['length']){return'';}for(var _0x25315f='(',_0x6e4f3c=0x0;_0x6e4f3c<_0x5b9f19['rules'][_0x5dbf('0x37')];_0x6e4f3c+=0x1){_0x6e4f3c>0x0&&(_0x25315f+='\x20'+_0x5b9f19['operator']+'\x20');_0x25315f+=_0x5b9f19[_0x5dbf('0x64')][_0x6e4f3c][_0x5dbf('0x66')]?_0x4cb92d(_0x5b9f19[_0x5dbf('0x64')][_0x6e4f3c][_0x5dbf('0x66')]):_0x5b9f19[_0x5dbf('0x64')][_0x6e4f3c]['field']+'\x20'+_0x5b9f19[_0x5dbf('0x64')][_0x6e4f3c][_0x5dbf('0x68')]+(_0x5924d2(_0x5b9f19[_0x5dbf('0x64')][_0x6e4f3c][_0x5dbf('0x68')])?'\x20'+_0x5b9f19['rules'][_0x6e4f3c][_0x5dbf('0x69')]:'');}return _0x25315f+')';};var _0x4f89ae={'where':{'id':_0x1ba14c['id']}},_0x2244aa,_0x285d54,_0x10bf3a,_0xc3ce87,_0x1445ec;_0x4f89ae=_[_0x5dbf('0x3f')]({},_0x4f89ae,_0x5d02f7);return db['AnalyticDefaultReport']['find'](_0x4f89ae)[_0x5dbf('0x23')](function(_0x1bd06b){if(_0x1bd06b){_0x2244aa=_0x1bd06b;return _0x1bd06b[_0x5dbf('0x6a')]();}return null;})['then'](function(_0x5434a0){if(_0x5434a0){if(!_0x5434a0['length']){throw new db[(_0x5dbf('0x6b'))][(_0x5dbf('0x6c'))](_0x5dbf('0x6d'),0x193);}_0x285d54=_0x5434a0;return db[_0x5dbf('0x6e')][_0x5dbf('0x90')]({'raw':!![]});}return null;})[_0x5dbf('0x23')](function(_0x5ba5bb){if(_0x5ba5bb){_0x10bf3a=_[_0x5dbf('0x91')](_0x5ba5bb,'id');var _0x15a6ed;var _0x5768fe=squel['select']();_0x5768fe[_0x5dbf('0x70')](_0x2244aa['table']);for(var _0x492cc8=0x0;_0x492cc8<_0x285d54[_0x5dbf('0x37')];_0x492cc8+=0x1){_0x15a6ed=_0x285d54[_0x492cc8][_0x5dbf('0x72')]?_0x10bf3a[_0x285d54[_0x492cc8][_0x5dbf('0x72')]]['metric']:_0x285d54[_0x492cc8][_0x5dbf('0x67')];_0x15a6ed=_0x285d54[_0x492cc8][_0x5dbf('0x74')]?_['replace'](_0x310078[_0x285d54[_0x492cc8][_0x5dbf('0x74')]],'%s',_0x15a6ed):_0x15a6ed;_0x15a6ed=_0x285d54[_0x492cc8][_0x5dbf('0x76')]?_[_0x5dbf('0x75')](_0x2c5a6e[_0x285d54[_0x492cc8][_0x5dbf('0x76')]],'%s',_0x15a6ed):_0x15a6ed;if(_0x285d54[_0x492cc8][_0x5dbf('0x77')]){_0x5768fe[_0x5dbf('0x66')](_0x15a6ed);}_0x285d54[_0x492cc8][_0x5dbf('0x78')]&&_0x5768fe[_0x5dbf('0x3a')](_0x15a6ed,_0x285d54[_0x492cc8]['orderBy']==='DESC'?![]:!![]);_0x5768fe['field'](_0x15a6ed,_0x285d54[_0x492cc8][_0x5dbf('0x7a')]||_0x15a6ed);}if(_0x2244aa[_0x5dbf('0x7b')]){_0x2244aa[_0x5dbf('0x7b')]=JSON[_0x5dbf('0x7c')](_0x2244aa[_0x5dbf('0x7b')]);for(var _0x339804=0x0;_0x339804<_0x2244aa[_0x5dbf('0x7b')][_0x5dbf('0x37')];_0x339804+=0x1){if(_0x2244aa[_0x5dbf('0x7b')][_0x339804][_0x5dbf('0x40')]&&_['includes'](_0x8ca7de,_0x2244aa[_0x5dbf('0x7b')][_0x339804][_0x5dbf('0x40')])&&_0x2244aa[_0x5dbf('0x7b')][_0x339804][_0x5dbf('0x7d')]&&_0x2244aa[_0x5dbf('0x7b')][_0x339804][_0x5dbf('0x7e')]&&_0x2244aa[_0x5dbf('0x7b')][_0x339804][_0x5dbf('0x7f')]){_0x5768fe[_0x2244aa['joins'][_0x339804]['type']](_0x2244aa[_0x5dbf('0x7b')][_0x339804]['foreignTable'],null,util['format'](_0x5dbf('0x80'),_0x2244aa['table'],_0x2244aa['joins'][_0x339804]['parentKey'],_0x2244aa['joins'][_0x339804][_0x5dbf('0x7e')],_0x2244aa['joins'][_0x339804][_0x5dbf('0x7f')]));}}}if(_0x2244aa[_0x5dbf('0x81')]){_0x2244aa[_0x5dbf('0x81')]=JSON['parse'](_0x2244aa[_0x5dbf('0x81')]);_0x5768fe[_0x5dbf('0x3c')](_0x4cb92d(_0x2244aa[_0x5dbf('0x81')]['group']));}_0x1445ec=_0x5768fe[_0x5dbf('0x82')]();_0x5768fe[_0x5dbf('0x1d')](_0x1efe3f);_0x5768fe[_0x5dbf('0x1c')](0x0);logger['debug'](_0x5dbf('0x84'),_0x5768fe[_0x5dbf('0x85')]());return db[_0x5dbf('0x86')]['query'](_0x5768fe[_0x5dbf('0x85')](),{'type':db[_0x5dbf('0x86')][_0x5dbf('0x87')]['SELECT']});}})['then'](function(_0x515c30){if(!_0x515c30[_0x5dbf('0x37')]){throw new db[(_0x5dbf('0x6b'))][(_0x5dbf('0x6c'))](_0x5dbf('0x92'),0xcc);}if(_0x4e0117[_0x5dbf('0x93')]===_0x5dbf('0x94')){return null;}var _0x4df7b5=_[_0x5dbf('0x3f')](_0x4e0117,{'name':_0x4e0117[_0x5dbf('0x95')]||_0x4e0117[_0x5dbf('0x2b')]||_0x2244aa['name'],'basename':_0x3dac55,'savename':util[_0x5dbf('0x76')](_0x5dbf('0x96'),_0x4e0117[_0x5dbf('0x2b')]||_0x2244aa[_0x5dbf('0x2b')],require(_0x5dbf('0x97'))[_0x5dbf('0x98')](0x4),_0x4e0117[_0x5dbf('0x93')]||'csv'),'reportId':_0x2244aa['id'],'reportType':_0x5dbf('0x99')});return db['AnalyticExtractedReport'][_0x5dbf('0x47')](_0x4df7b5,{'raw':!![]});})[_0x5dbf('0x23')](function(_0x1d01e4){if(_0x2244aa['table']==='cdr'){_0x1445ec['where'](_0x2244aa[_0x5dbf('0x71')]+_0x5dbf('0x9a'),_0x4e0117['startDate'],_0x4e0117[_0x5dbf('0x9b')]);}else{_0x1445ec['where'](_0x2244aa[_0x5dbf('0x71')]+_0x5dbf('0x9c'),_0x4e0117[_0x5dbf('0x9d')],_0x4e0117['endDate']);}if(_0x1d01e4){logger[_0x5dbf('0x9e')](_0x5dbf('0x9f'),_0x1445ec[_0x5dbf('0x85')]());require(_0x5dbf('0xa0'))[_0x5dbf('0xa1')](path[_0x5dbf('0x54')](__dirname,_0x5dbf('0xa2'),_0x1d01e4['output']),[_0x1d01e4['id'],_0x1445ec[_0x5dbf('0x85')](),path['join'](__dirname,_0x5dbf('0xa3'),_0x1d01e4[_0x5dbf('0xa4')]),_0x3dac55]);return _0x1d01e4;}else{var _0x33be00=squel['select']();_0x33be00[_0x5dbf('0x70')]('('+_0x1445ec[_0x5dbf('0x85')]()+')',_0x5dbf('0xa5'));_0x33be00[_0x5dbf('0x67')](_0x5dbf('0xa6'),_0x5dbf('0x1b'));_0x1445ec['limit'](_0x4e0117[_0x5dbf('0x1d')]||_0x1efe3f);_0x1445ec['offset'](_0x4e0117[_0x5dbf('0x1c')]||0x0);return dbH[_0x5dbf('0x86')][_0x5dbf('0x32')](_0x33be00[_0x5dbf('0x85')](),{'type':dbH[_0x5dbf('0x86')][_0x5dbf('0x87')]['SELECT']})[_0x5dbf('0x23')](function(_0x2481a5){if(!_0x2481a5[_0x5dbf('0x37')]){_0xc3ce87=0x0;}else{_0xc3ce87=_0x2481a5[0x0]['count']||0x0;}return dbH[_0x5dbf('0x86')]['query'](_0x1445ec['toString'](),{'type':dbH[_0x5dbf('0x86')][_0x5dbf('0x87')][_0x5dbf('0x88')]});})[_0x5dbf('0x23')](function(_0x2531f1){return{'rows':_0x2531f1||[],'count':_0xc3ce87};});}});}exports['run']=function(_0x52d3c2,_0x4f38a0){return runReport(_0x52d3c2[_0x5dbf('0x51')],_0x52d3c2[_0x5dbf('0x32')],_0x52d3c2[_0x5dbf('0x41')])[_0x5dbf('0x23')](respondWithResult(_0x4f38a0,null))[_0x5dbf('0x44')](handleError(_0x4f38a0,null));};exports[_0x5dbf('0xa7')]=runReport;exports[_0x5dbf('0x32')]=function(_0x236754,_0x5c6f2a){var _0xac0935=0xa;var _0x16c80d=[_0x5dbf('0x54'),_0x5dbf('0x89'),_0x5dbf('0x8a'),_0x5dbf('0x55')];var _0x15b27e={'SUM':_0x5dbf('0x56'),'COUNT':_0x5dbf('0x57'),'COUNT DISTINCT':_0x5dbf('0x58'),'MAX':'MAX(%s)','MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0x5dbf('0x8c'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x5dbf('0x8e')};var _0x5d0c87={'SEC_TO_TIME':_0x5dbf('0x8f'),'DATE':_0x5dbf('0x5b'),'HOUR':_0x5dbf('0x5c'),'ROUND':_0x5dbf('0x5d'),'UNIX_TIMESTAMP':_0x5dbf('0x5e')};var _0x4f8dde=function(_0x9186e){return!_[_0x5dbf('0x5f')]([_0x5dbf('0x60'),_0x5dbf('0x61'),_0x5dbf('0x62'),'IS\x20NOT\x20EMPTY'],_0x9186e);};var _0x3177d5=function(_0x2ef762){if(!_0x2ef762||!_0x2ef762[_0x5dbf('0x64')][_0x5dbf('0x37')]){return'';}for(var _0x588ad8='(',_0x355e4e=0x0;_0x355e4e<_0x2ef762[_0x5dbf('0x64')][_0x5dbf('0x37')];_0x355e4e+=0x1){_0x355e4e>0x0&&(_0x588ad8+='\x20'+_0x2ef762[_0x5dbf('0x65')]+'\x20');_0x588ad8+=_0x2ef762[_0x5dbf('0x64')][_0x355e4e][_0x5dbf('0x66')]?_0x3177d5(_0x2ef762[_0x5dbf('0x64')][_0x355e4e]['group']):_0x2ef762['rules'][_0x355e4e]['field']+'\x20'+_0x2ef762[_0x5dbf('0x64')][_0x355e4e][_0x5dbf('0x68')]+(_0x4f8dde(_0x2ef762['rules'][_0x355e4e][_0x5dbf('0x68')])?'\x20'+_0x2ef762['rules'][_0x355e4e][_0x5dbf('0x69')]:'');}return _0x588ad8+')';};var _0x4b835e={'where':{'id':_0x236754[_0x5dbf('0x51')]['id']}},_0x50b2be,_0x2f7063,_0x3540d0,_0x2eafe0,_0x1fcac1;_0x4b835e=_[_0x5dbf('0x3f')]({},_0x4b835e,_0x236754['options']);return db[_0x5dbf('0x2e')][_0x5dbf('0x50')](_0x4b835e)[_0x5dbf('0x23')](function(_0x2410fc){if(_0x2410fc){_0x50b2be=_0x2410fc;return _0x2410fc[_0x5dbf('0x6a')]();}return null;})[_0x5dbf('0x23')](function(_0x153401){if(_0x153401){if(!_0x153401[_0x5dbf('0x37')]){throw new db[(_0x5dbf('0x6b'))]['ValidationErrorItem'](_0x5dbf('0x6d'),0x193);}_0x2f7063=_0x153401;return db[_0x5dbf('0x6e')][_0x5dbf('0x90')]({'raw':!![]});}return null;})[_0x5dbf('0x23')](function(_0x380b2c){if(_0x380b2c){_0x3540d0=_[_0x5dbf('0x91')](_0x380b2c,'id');var _0x9e9248;var _0x1ec7dd=squel[_0x5dbf('0x6f')]();_0x1ec7dd[_0x5dbf('0x70')](_0x50b2be[_0x5dbf('0x71')]);for(var _0x43ee4c=0x0;_0x43ee4c<_0x2f7063[_0x5dbf('0x37')];_0x43ee4c+=0x1){_0x9e9248=_0x2f7063[_0x43ee4c][_0x5dbf('0x72')]?_0x3540d0[_0x2f7063[_0x43ee4c][_0x5dbf('0x72')]][_0x5dbf('0x73')]:_0x2f7063[_0x43ee4c][_0x5dbf('0x67')];_0x9e9248=_0x2f7063[_0x43ee4c][_0x5dbf('0x74')]?_[_0x5dbf('0x75')](_0x15b27e[_0x2f7063[_0x43ee4c]['function']],'%s',_0x9e9248):_0x9e9248;_0x9e9248=_0x2f7063[_0x43ee4c][_0x5dbf('0x76')]?_['replace'](_0x5d0c87[_0x2f7063[_0x43ee4c][_0x5dbf('0x76')]],'%s',_0x9e9248):_0x9e9248;if(_0x2f7063[_0x43ee4c]['groupBy']){_0x1ec7dd[_0x5dbf('0x66')](_0x9e9248);}_0x2f7063[_0x43ee4c]['orderBy']&&_0x1ec7dd[_0x5dbf('0x3a')](_0x9e9248,_0x2f7063[_0x43ee4c][_0x5dbf('0x78')]===_0x5dbf('0x79')?![]:!![]);_0x1ec7dd['field'](_0x9e9248,_0x2f7063[_0x43ee4c][_0x5dbf('0x7a')]||_0x9e9248);}if(_0x50b2be[_0x5dbf('0x7b')]){_0x50b2be[_0x5dbf('0x7b')]=JSON[_0x5dbf('0x7c')](_0x50b2be[_0x5dbf('0x7b')]);for(var _0x3f0136=0x0;_0x3f0136<_0x50b2be[_0x5dbf('0x7b')]['length'];_0x3f0136+=0x1){if(_0x50b2be[_0x5dbf('0x7b')][_0x3f0136][_0x5dbf('0x40')]&&_['includes'](_0x16c80d,_0x50b2be[_0x5dbf('0x7b')][_0x3f0136]['type'])&&_0x50b2be['joins'][_0x3f0136][_0x5dbf('0x7d')]&&_0x50b2be[_0x5dbf('0x7b')][_0x3f0136]['foreignTable']&&_0x50b2be[_0x5dbf('0x7b')][_0x3f0136]['foreignKey']){_0x1ec7dd[_0x50b2be['joins'][_0x3f0136][_0x5dbf('0x40')]](_0x50b2be['joins'][_0x3f0136][_0x5dbf('0x7e')],null,util[_0x5dbf('0x76')](_0x5dbf('0x80'),_0x50b2be[_0x5dbf('0x71')],_0x50b2be[_0x5dbf('0x7b')][_0x3f0136][_0x5dbf('0x7d')],_0x50b2be[_0x5dbf('0x7b')][_0x3f0136][_0x5dbf('0x7e')],_0x50b2be[_0x5dbf('0x7b')][_0x3f0136][_0x5dbf('0x7f')]));}}}if(_0x50b2be[_0x5dbf('0x81')]){_0x50b2be[_0x5dbf('0x81')]=JSON[_0x5dbf('0x7c')](_0x50b2be['conditions']);_0x1ec7dd[_0x5dbf('0x3c')](_0x3177d5(_0x50b2be[_0x5dbf('0x81')][_0x5dbf('0x66')]));}_0x1fcac1=_0x1ec7dd[_0x5dbf('0x82')]();_0x1ec7dd[_0x5dbf('0x1d')](_0xac0935);_0x1ec7dd[_0x5dbf('0x1c')](0x0);logger['debug'](_0x5dbf('0x84'),_0x1ec7dd[_0x5dbf('0x85')]());return db[_0x5dbf('0x86')][_0x5dbf('0x32')](_0x1ec7dd['toString'](),{'type':db[_0x5dbf('0x86')][_0x5dbf('0x87')][_0x5dbf('0x88')]});}})[_0x5dbf('0x23')](function(){return{'sql':_0x1fcac1[_0x5dbf('0x85')]()};})[_0x5dbf('0x23')](respondWithResult(_0x5c6f2a,null))[_0x5dbf('0x44')](handleError(_0x5c6f2a,null));};
\ No newline at end of file
+var _0x7a54=['options','AnalyticDefaultReport','includeAll','include','show','keys','attributes','create','body','user','role','get','Reports','UserProfileSection','userProfileId','UserProfileResource','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','find','params','right_join','cross_join','SUM(%s)','COUNT(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','DATE(%s)','ROUND(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20NOT\x20EMPTY','rules','group','condition','value','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','findAll','keyBy','select','from','MetricId','metric','field','function','replace','format','orderBy','DESC','joins','parse','type','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','table','conditions','debug','toString','sequelize','QueryTypes','SELECT','join','left_join','COUNT(DISTINCT\x20%s)','MAX(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','IS\x20EMPTY','operator','groupBy','alias','output','web','fullPath','%s-%s.%s','generate','default','AnalyticExtractedReport','cdr','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','info','Run\x20Query:','child_process','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','getFields','clone','Limited\x20Query:','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','to-csv','fs-extra','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','status','end','json','limit','count','offset','Content-Range','apply','save','then','destroy','DefaultReports','error','stack','name','index','map','fieldName','model','query','filters','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','VIRTUAL','merge'];(function(_0x3e3bee,_0x4f91fe){var _0x3ae14c=function(_0x3861a0){while(--_0x3861a0){_0x3e3bee['push'](_0x3e3bee['shift']());}};_0x3ae14c(++_0x4f91fe);}(_0x7a54,0x106));var _0x47a5=function(_0x273b37,_0x51b576){_0x273b37=_0x273b37-0x0;var _0x242606=_0x7a54[_0x273b37];return _0x242606;};'use strict';var emlformat=require(_0x47a5('0x0'));var rimraf=require(_0x47a5('0x1'));var zipdir=require(_0x47a5('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x47a5('0x3'));var moment=require(_0x47a5('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x47a5('0x5'));var util=require(_0x47a5('0x6'));var path=require(_0x47a5('0x7'));var sox=require(_0x47a5('0x8'));var csv=require(_0x47a5('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x47a5('0xa'));var _=require('lodash');var squel=require(_0x47a5('0xb'));var crypto=require(_0x47a5('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x47a5('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x47a5('0xe'));var authService=require(_0x47a5('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x47a5('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x47a5('0x11'));var utils=require(_0x47a5('0x12'));var config=require(_0x47a5('0x13'));var licenseUtil=require(_0x47a5('0x14'));var db=require(_0x47a5('0x15'))['db'];var dbH=require(_0x47a5('0x15'))[_0x47a5('0x16')];function respondWithStatusCode(_0x5beb89,_0x44bd3e){_0x44bd3e=_0x44bd3e||0xcc;return function(_0x221b54){if(_0x221b54){return _0x5beb89[_0x47a5('0x17')](_0x44bd3e);}return _0x5beb89[_0x47a5('0x18')](_0x44bd3e)[_0x47a5('0x19')]();};}function respondWithResult(_0x620ee9,_0x3c6c46){_0x3c6c46=_0x3c6c46||0xc8;return function(_0x190faa){if(_0x190faa){return _0x620ee9['status'](_0x3c6c46)[_0x47a5('0x1a')](_0x190faa);}};}function respondWithFilteredResult(_0x11faf5,_0x3b001e){return function(_0x2a2cbb){if(_0x2a2cbb){var _0x1ef44c=typeof _0x3b001e['offset']==='undefined'&&typeof _0x3b001e[_0x47a5('0x1b')]==='undefined';var _0x5247fd=_0x2a2cbb[_0x47a5('0x1c')];var _0xaf70a6=_0x1ef44c?0x0:_0x3b001e[_0x47a5('0x1d')];var _0x1ef371=_0x1ef44c?_0x2a2cbb[_0x47a5('0x1c')]:_0x3b001e[_0x47a5('0x1d')]+_0x3b001e[_0x47a5('0x1b')];var _0xe3c618;if(_0x1ef371>=_0x5247fd){_0x1ef371=_0x5247fd;_0xe3c618=0xc8;}else{_0xe3c618=0xce;}_0x11faf5[_0x47a5('0x18')](_0xe3c618);return _0x11faf5['set'](_0x47a5('0x1e'),_0xaf70a6+'-'+_0x1ef371+'/'+_0x5247fd)[_0x47a5('0x1a')](_0x2a2cbb);}return null;};}function patchUpdates(_0x47cf3c){return function(_0x2b0360){try{jsonpatch[_0x47a5('0x1f')](_0x2b0360,_0x47cf3c,!![]);}catch(_0x36874d){return BPromise['reject'](_0x36874d);}return _0x2b0360[_0x47a5('0x20')]();};}function saveUpdates(_0x2f142b,_0x23db32){return function(_0x7a9f9e){if(_0x7a9f9e){return _0x7a9f9e['update'](_0x2f142b)[_0x47a5('0x21')](function(_0x385687){return _0x385687;});}return null;};}function removeEntity(_0x513981,_0x28747d){return function(_0xc4cd63){if(_0xc4cd63){return _0xc4cd63[_0x47a5('0x22')]()[_0x47a5('0x21')](function(){var _0x3abd6a=_0xc4cd63['get']({'plain':!![]});var _0x53078a=_0x47a5('0x23');return db['UserProfileResource'][_0x47a5('0x22')]({'where':{'type':_0x53078a,'resourceId':_0x3abd6a['id']}})['then'](function(){return _0xc4cd63;});})[_0x47a5('0x21')](function(){_0x513981[_0x47a5('0x18')](0xcc)[_0x47a5('0x19')]();});}};}function handleEntityNotFound(_0x1dac65,_0x21f296){return function(_0x3ba0b7){if(!_0x3ba0b7){_0x1dac65[_0x47a5('0x17')](0x194);}return _0x3ba0b7;};}function handleError(_0x136b14,_0x16631f){_0x16631f=_0x16631f||0x1f4;return function(_0x361bfa){logger[_0x47a5('0x24')](_0x361bfa[_0x47a5('0x25')]);if(_0x361bfa[_0x47a5('0x26')]){delete _0x361bfa['name'];}_0x136b14[_0x47a5('0x18')](_0x16631f)['send'](_0x361bfa);};}exports[_0x47a5('0x27')]=function(_0x9ac908,_0x16901f){var _0x4d6b57={},_0x256650={},_0x625952={'count':0x0,'rows':[]};var _0x39b50b=_[_0x47a5('0x28')](db['AnalyticDefaultReport']['rawAttributes'],function(_0x6f9a12){return{'name':_0x6f9a12[_0x47a5('0x29')],'type':_0x6f9a12['type']['key']};});_0x256650[_0x47a5('0x2a')]=_[_0x47a5('0x28')](_0x39b50b,'name');_0x256650[_0x47a5('0x2b')]=_['keys'](_0x9ac908[_0x47a5('0x2b')]);_0x256650[_0x47a5('0x2c')]=_['intersection'](_0x256650['model'],_0x256650[_0x47a5('0x2b')]);_0x4d6b57['attributes']=_[_0x47a5('0x2d')](_0x256650[_0x47a5('0x2a')],qs[_0x47a5('0x2e')](_0x9ac908['query'][_0x47a5('0x2e')]));_0x4d6b57['attributes']=_0x4d6b57['attributes'][_0x47a5('0x2f')]?_0x4d6b57['attributes']:_0x256650[_0x47a5('0x2a')];if(!_0x9ac908['query'][_0x47a5('0x30')](_0x47a5('0x31'))){_0x4d6b57[_0x47a5('0x1b')]=qs[_0x47a5('0x1b')](_0x9ac908[_0x47a5('0x2b')][_0x47a5('0x1b')]);_0x4d6b57[_0x47a5('0x1d')]=qs[_0x47a5('0x1d')](_0x9ac908[_0x47a5('0x2b')]['offset']);}_0x4d6b57[_0x47a5('0x32')]=qs[_0x47a5('0x33')](_0x9ac908['query'][_0x47a5('0x33')]);_0x4d6b57[_0x47a5('0x34')]=qs[_0x47a5('0x2c')](_['pick'](_0x9ac908[_0x47a5('0x2b')],_0x256650[_0x47a5('0x2c')]),_0x39b50b);if(_0x9ac908['query'][_0x47a5('0x35')]){_0x4d6b57[_0x47a5('0x34')]=_['merge'](_0x4d6b57['where'],{'$or':_['map'](_0x39b50b,function(_0x12d9f2){if(_0x12d9f2['type']!==_0x47a5('0x36')){var _0x1f9631={};_0x1f9631[_0x12d9f2[_0x47a5('0x26')]]={'$like':'%'+_0x9ac908[_0x47a5('0x2b')][_0x47a5('0x35')]+'%'};return _0x1f9631;}})});}_0x4d6b57=_[_0x47a5('0x37')]({},_0x4d6b57,_0x9ac908[_0x47a5('0x38')]);var _0x1f3d01={'where':_0x4d6b57[_0x47a5('0x34')]};return db[_0x47a5('0x39')][_0x47a5('0x1c')](_0x1f3d01)[_0x47a5('0x21')](function(_0x23d6d8){_0x625952['count']=_0x23d6d8;if(_0x9ac908[_0x47a5('0x2b')][_0x47a5('0x3a')]){_0x4d6b57[_0x47a5('0x3b')]=[{'all':!![]}];}return db[_0x47a5('0x39')]['findAll'](_0x4d6b57);})[_0x47a5('0x21')](function(_0x528ef3){_0x625952['rows']=_0x528ef3;return _0x625952;})['then'](respondWithFilteredResult(_0x16901f,_0x4d6b57))['catch'](handleError(_0x16901f,null));};exports[_0x47a5('0x3c')]=function(_0x5ec4e5,_0x2bb502){var _0x3a740b={'raw':!![],'where':{'id':_0x5ec4e5['params']['id']}},_0x448610={};_0x448610[_0x47a5('0x2a')]=_[_0x47a5('0x3d')](db['AnalyticDefaultReport']['rawAttributes']);_0x448610[_0x47a5('0x2b')]=_['keys'](_0x5ec4e5[_0x47a5('0x2b')]);_0x448610[_0x47a5('0x2c')]=_[_0x47a5('0x2d')](_0x448610[_0x47a5('0x2a')],_0x448610[_0x47a5('0x2b')]);_0x3a740b[_0x47a5('0x3e')]=_[_0x47a5('0x2d')](_0x448610[_0x47a5('0x2a')],qs[_0x47a5('0x2e')](_0x5ec4e5[_0x47a5('0x2b')][_0x47a5('0x2e')]));_0x3a740b[_0x47a5('0x3e')]=_0x3a740b[_0x47a5('0x3e')][_0x47a5('0x2f')]?_0x3a740b[_0x47a5('0x3e')]:_0x448610[_0x47a5('0x2a')];if(_0x5ec4e5['query'][_0x47a5('0x3a')]){_0x3a740b[_0x47a5('0x3b')]=[{'all':!![]}];}_0x3a740b=_['merge']({},_0x3a740b,_0x5ec4e5['options']);return db[_0x47a5('0x39')]['find'](_0x3a740b)[_0x47a5('0x21')](handleEntityNotFound(_0x2bb502,null))[_0x47a5('0x21')](respondWithResult(_0x2bb502,null))['catch'](handleError(_0x2bb502,null));};exports['create']=function(_0x3d85cc,_0x52d409){return db[_0x47a5('0x39')][_0x47a5('0x3f')](_0x3d85cc[_0x47a5('0x40')],{})[_0x47a5('0x21')](function(_0x44fe8a){var _0x26acd2=_0x3d85cc[_0x47a5('0x41')]['get']({'plain':!![]});if(!_0x26acd2)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x26acd2[_0x47a5('0x42')]===_0x47a5('0x41')){var _0x1163e3=_0x44fe8a[_0x47a5('0x43')]({'plain':!![]});var _0x2c7020=_0x47a5('0x44');return db[_0x47a5('0x45')]['find']({'where':{'name':_0x2c7020,'userProfileId':_0x26acd2[_0x47a5('0x46')]},'raw':!![]})[_0x47a5('0x21')](function(_0x5f6a){if(_0x5f6a&&_0x5f6a['autoAssociation']===0x0){return db[_0x47a5('0x47')]['create']({'name':_0x1163e3[_0x47a5('0x26')],'resourceId':_0x1163e3['id'],'type':_0x47a5('0x23'),'sectionId':_0x5f6a['id']},{})[_0x47a5('0x21')](function(){return _0x44fe8a;});}else{return _0x44fe8a;}})[_0x47a5('0x48')](function(_0x588551){logger[_0x47a5('0x24')](_0x47a5('0x49'),_0x588551);throw _0x588551;});}return _0x44fe8a;})[_0x47a5('0x21')](respondWithResult(_0x52d409,0xc9))[_0x47a5('0x48')](handleError(_0x52d409,null));};exports[_0x47a5('0x4a')]=function(_0x6a53b3,_0x24e9f4){if(_0x6a53b3['body']['id']){delete _0x6a53b3[_0x47a5('0x40')]['id'];}return db[_0x47a5('0x39')][_0x47a5('0x4b')]({'where':{'id':_0x6a53b3[_0x47a5('0x4c')]['id']}})[_0x47a5('0x21')](handleEntityNotFound(_0x24e9f4,null))[_0x47a5('0x21')](saveUpdates(_0x6a53b3['body'],null))[_0x47a5('0x21')](respondWithResult(_0x24e9f4,null))[_0x47a5('0x48')](handleError(_0x24e9f4,null));};exports[_0x47a5('0x22')]=function(_0x53871e,_0x4c5ed){return db[_0x47a5('0x39')][_0x47a5('0x4b')]({'where':{'id':_0x53871e['params']['id']}})['then'](handleEntityNotFound(_0x4c5ed,null))[_0x47a5('0x21')](removeEntity(_0x4c5ed,null))[_0x47a5('0x48')](handleError(_0x4c5ed,null));};exports['preview']=function(_0x4cf792,_0x6d6b2b){var _0x4d6a82=0xa;var _0x16bb8a=['join','left_join',_0x47a5('0x4d'),_0x47a5('0x4e')];var _0x53eedf={'SUM':_0x47a5('0x4f'),'COUNT':_0x47a5('0x50'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':'MAX(%s)','MIN':_0x47a5('0x51'),'AVG':_0x47a5('0x52'),'GROUP_CONCAT':_0x47a5('0x53'),'GROUP_CONCAT ASC':_0x47a5('0x54'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x199621={'SEC_TO_TIME':_0x47a5('0x55'),'DATE':_0x47a5('0x56'),'HOUR':'HOUR(%s)','ROUND':_0x47a5('0x57'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x485e3c=function(_0x470da6){return!_[_0x47a5('0x58')]([_0x47a5('0x59'),_0x47a5('0x5a'),'IS\x20EMPTY',_0x47a5('0x5b')],_0x470da6);};var _0x5d1550=function(_0x5cbe97){if(!_0x5cbe97||!_0x5cbe97['rules']['length']){return'';}for(var _0x212d92='(',_0x6cd4ea=0x0;_0x6cd4ea<_0x5cbe97[_0x47a5('0x5c')]['length'];_0x6cd4ea+=0x1){_0x6cd4ea>0x0&&(_0x212d92+='\x20'+_0x5cbe97['operator']+'\x20');_0x212d92+=_0x5cbe97[_0x47a5('0x5c')][_0x6cd4ea][_0x47a5('0x5d')]?_0x5d1550(_0x5cbe97[_0x47a5('0x5c')][_0x6cd4ea][_0x47a5('0x5d')]):_0x5cbe97[_0x47a5('0x5c')][_0x6cd4ea]['field']+'\x20'+_0x5cbe97[_0x47a5('0x5c')][_0x6cd4ea]['condition']+(_0x485e3c(_0x5cbe97[_0x47a5('0x5c')][_0x6cd4ea][_0x47a5('0x5e')])?'\x20'+_0x5cbe97['rules'][_0x6cd4ea][_0x47a5('0x5f')]:'');}return _0x212d92+')';};var _0x345104={'where':{'id':_0x4cf792[_0x47a5('0x4c')]['id']}},_0x132854,_0x3e8274,_0x2d6494,_0x215634,_0x35cca8;_0x345104=_['merge']({},_0x345104,_0x4cf792[_0x47a5('0x38')]);return db[_0x47a5('0x39')][_0x47a5('0x4b')](_0x345104)[_0x47a5('0x21')](function(_0x396cb0){if(_0x396cb0){_0x132854=_0x396cb0;return _0x396cb0['getFields']();}return null;})[_0x47a5('0x21')](function(_0xdfcecc){if(_0xdfcecc){if(!_0xdfcecc[_0x47a5('0x2f')]){throw new db[(_0x47a5('0x60'))][(_0x47a5('0x61'))](_0x47a5('0x62'),0x193);}_0x3e8274=_0xdfcecc;return db[_0x47a5('0x63')][_0x47a5('0x64')]({'raw':!![]});}return null;})[_0x47a5('0x21')](function(_0x44cb90){if(_0x44cb90){_0x2d6494=_[_0x47a5('0x65')](_0x44cb90,'id');var _0x44fda9;var _0x3c0006=squel[_0x47a5('0x66')]();_0x3c0006[_0x47a5('0x67')](_0x132854['table']);for(var _0x42dd7d=0x0;_0x42dd7d<_0x3e8274[_0x47a5('0x2f')];_0x42dd7d+=0x1){_0x44fda9=_0x3e8274[_0x42dd7d][_0x47a5('0x68')]?_0x2d6494[_0x3e8274[_0x42dd7d]['MetricId']][_0x47a5('0x69')]:_0x3e8274[_0x42dd7d][_0x47a5('0x6a')];_0x44fda9=_0x3e8274[_0x42dd7d][_0x47a5('0x6b')]?_[_0x47a5('0x6c')](_0x53eedf[_0x3e8274[_0x42dd7d]['function']],'%s',_0x44fda9):_0x44fda9;_0x44fda9=_0x3e8274[_0x42dd7d][_0x47a5('0x6d')]?_['replace'](_0x199621[_0x3e8274[_0x42dd7d][_0x47a5('0x6d')]],'%s',_0x44fda9):_0x44fda9;if(_0x3e8274[_0x42dd7d]['groupBy']){_0x3c0006[_0x47a5('0x5d')](_0x44fda9);}_0x3e8274[_0x42dd7d]['orderBy']&&_0x3c0006[_0x47a5('0x32')](_0x44fda9,_0x3e8274[_0x42dd7d][_0x47a5('0x6e')]===_0x47a5('0x6f')?![]:!![]);_0x3c0006['field'](_0x44fda9,_0x3e8274[_0x42dd7d]['alias']||_0x44fda9);}if(_0x132854['joins']){_0x132854[_0x47a5('0x70')]=JSON[_0x47a5('0x71')](_0x132854[_0x47a5('0x70')]);for(var _0x117510=0x0;_0x117510<_0x132854['joins'][_0x47a5('0x2f')];_0x117510+=0x1){if(_0x132854[_0x47a5('0x70')][_0x117510][_0x47a5('0x72')]&&_[_0x47a5('0x58')](_0x16bb8a,_0x132854[_0x47a5('0x70')][_0x117510][_0x47a5('0x72')])&&_0x132854[_0x47a5('0x70')][_0x117510][_0x47a5('0x73')]&&_0x132854[_0x47a5('0x70')][_0x117510][_0x47a5('0x74')]&&_0x132854[_0x47a5('0x70')][_0x117510][_0x47a5('0x75')]){_0x3c0006[_0x132854['joins'][_0x117510][_0x47a5('0x72')]](_0x132854['joins'][_0x117510][_0x47a5('0x74')],null,util[_0x47a5('0x6d')](_0x47a5('0x76'),_0x132854[_0x47a5('0x77')],_0x132854[_0x47a5('0x70')][_0x117510][_0x47a5('0x73')],_0x132854[_0x47a5('0x70')][_0x117510][_0x47a5('0x74')],_0x132854[_0x47a5('0x70')][_0x117510][_0x47a5('0x75')]));}}}if(_0x132854[_0x47a5('0x78')]){_0x132854[_0x47a5('0x78')]=JSON[_0x47a5('0x71')](_0x132854[_0x47a5('0x78')]);_0x3c0006[_0x47a5('0x34')](_0x5d1550(_0x132854['conditions']['group']));}_0x35cca8=_0x3c0006['clone']();_0x3c0006['limit'](_0x4d6a82);_0x3c0006[_0x47a5('0x1d')](0x0);logger[_0x47a5('0x79')]('Limited\x20Query:',_0x3c0006[_0x47a5('0x7a')]());return dbH[_0x47a5('0x7b')][_0x47a5('0x2b')](_0x3c0006[_0x47a5('0x7a')](),{'type':dbH[_0x47a5('0x7b')][_0x47a5('0x7c')][_0x47a5('0x7d')]});}})[_0x47a5('0x21')](respondWithResult(_0x6d6b2b,null))[_0x47a5('0x48')](handleError(_0x6d6b2b,null));};function runReport(_0x1ffe3c,_0x24a6c1,_0x5e5f16){var _0x18fa31=_0x24a6c1[_0x47a5('0x26')];var _0x420671=0xa;var _0x4f35ff=[_0x47a5('0x7e'),_0x47a5('0x7f'),_0x47a5('0x4d'),'cross_join'];var _0x19dc8c={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':_0x47a5('0x80'),'MAX':_0x47a5('0x81'),'MIN':_0x47a5('0x51'),'AVG':_0x47a5('0x52'),'GROUP_CONCAT':_0x47a5('0x53'),'GROUP_CONCAT ASC':_0x47a5('0x54'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x592322={'SEC_TO_TIME':_0x47a5('0x55'),'DATE':'DATE(%s)','HOUR':_0x47a5('0x82'),'ROUND':_0x47a5('0x57'),'UNIX_TIMESTAMP':_0x47a5('0x83')};var _0xb16bdd=function(_0x53ea2b){return!_[_0x47a5('0x58')](['IS\x20NULL','IS\x20NOT\x20NULL',_0x47a5('0x84'),_0x47a5('0x5b')],_0x53ea2b);};var _0x5b91f7=function(_0x1926bd){if(!_0x1926bd||!_0x1926bd[_0x47a5('0x5c')][_0x47a5('0x2f')]){return'';}for(var _0x4c25ec='(',_0x280372=0x0;_0x280372<_0x1926bd['rules'][_0x47a5('0x2f')];_0x280372+=0x1){_0x280372>0x0&&(_0x4c25ec+='\x20'+_0x1926bd[_0x47a5('0x85')]+'\x20');_0x4c25ec+=_0x1926bd[_0x47a5('0x5c')][_0x280372]['group']?_0x5b91f7(_0x1926bd[_0x47a5('0x5c')][_0x280372][_0x47a5('0x5d')]):_0x1926bd[_0x47a5('0x5c')][_0x280372]['field']+'\x20'+_0x1926bd[_0x47a5('0x5c')][_0x280372]['condition']+(_0xb16bdd(_0x1926bd[_0x47a5('0x5c')][_0x280372]['condition'])?'\x20'+_0x1926bd[_0x47a5('0x5c')][_0x280372][_0x47a5('0x5f')]:'');}return _0x4c25ec+')';};var _0x20a742={'where':{'id':_0x1ffe3c['id']}},_0x211fbf,_0x51738b,_0x42fcce,_0x2ae130,_0x23c393;_0x20a742=_[_0x47a5('0x37')]({},_0x20a742,_0x5e5f16);return db[_0x47a5('0x39')]['find'](_0x20a742)['then'](function(_0x569550){if(_0x569550){_0x211fbf=_0x569550;return _0x569550['getFields']();}return null;})[_0x47a5('0x21')](function(_0xa8809a){if(_0xa8809a){if(!_0xa8809a[_0x47a5('0x2f')]){throw new db['Sequelize'][(_0x47a5('0x61'))](_0x47a5('0x62'),0x193);}_0x51738b=_0xa8809a;return db['AnalyticMetric'][_0x47a5('0x64')]({'raw':!![]});}return null;})[_0x47a5('0x21')](function(_0x19acfa){if(_0x19acfa){_0x42fcce=_[_0x47a5('0x65')](_0x19acfa,'id');var _0x58dacd;var _0x4b5353=squel[_0x47a5('0x66')]();_0x4b5353[_0x47a5('0x67')](_0x211fbf['table']);for(var _0x27d422=0x0;_0x27d422<_0x51738b[_0x47a5('0x2f')];_0x27d422+=0x1){_0x58dacd=_0x51738b[_0x27d422]['MetricId']?_0x42fcce[_0x51738b[_0x27d422][_0x47a5('0x68')]][_0x47a5('0x69')]:_0x51738b[_0x27d422][_0x47a5('0x6a')];_0x58dacd=_0x51738b[_0x27d422]['function']?_[_0x47a5('0x6c')](_0x19dc8c[_0x51738b[_0x27d422]['function']],'%s',_0x58dacd):_0x58dacd;_0x58dacd=_0x51738b[_0x27d422][_0x47a5('0x6d')]?_['replace'](_0x592322[_0x51738b[_0x27d422][_0x47a5('0x6d')]],'%s',_0x58dacd):_0x58dacd;if(_0x51738b[_0x27d422][_0x47a5('0x86')]){_0x4b5353['group'](_0x58dacd);}_0x51738b[_0x27d422][_0x47a5('0x6e')]&&_0x4b5353['order'](_0x58dacd,_0x51738b[_0x27d422][_0x47a5('0x6e')]===_0x47a5('0x6f')?![]:!![]);_0x4b5353[_0x47a5('0x6a')](_0x58dacd,_0x51738b[_0x27d422][_0x47a5('0x87')]||_0x58dacd);}if(_0x211fbf['joins']){_0x211fbf[_0x47a5('0x70')]=JSON['parse'](_0x211fbf['joins']);for(var _0x2bb2df=0x0;_0x2bb2df<_0x211fbf[_0x47a5('0x70')][_0x47a5('0x2f')];_0x2bb2df+=0x1){if(_0x211fbf[_0x47a5('0x70')][_0x2bb2df][_0x47a5('0x72')]&&_['includes'](_0x4f35ff,_0x211fbf[_0x47a5('0x70')][_0x2bb2df][_0x47a5('0x72')])&&_0x211fbf[_0x47a5('0x70')][_0x2bb2df][_0x47a5('0x73')]&&_0x211fbf['joins'][_0x2bb2df][_0x47a5('0x74')]&&_0x211fbf['joins'][_0x2bb2df][_0x47a5('0x75')]){_0x4b5353[_0x211fbf[_0x47a5('0x70')][_0x2bb2df][_0x47a5('0x72')]](_0x211fbf[_0x47a5('0x70')][_0x2bb2df][_0x47a5('0x74')],null,util[_0x47a5('0x6d')](_0x47a5('0x76'),_0x211fbf[_0x47a5('0x77')],_0x211fbf[_0x47a5('0x70')][_0x2bb2df]['parentKey'],_0x211fbf[_0x47a5('0x70')][_0x2bb2df][_0x47a5('0x74')],_0x211fbf['joins'][_0x2bb2df][_0x47a5('0x75')]));}}}if(_0x211fbf[_0x47a5('0x78')]){_0x211fbf[_0x47a5('0x78')]=JSON['parse'](_0x211fbf['conditions']);_0x4b5353[_0x47a5('0x34')](_0x5b91f7(_0x211fbf[_0x47a5('0x78')]['group']));}_0x23c393=_0x4b5353['clone']();_0x4b5353[_0x47a5('0x1b')](_0x420671);_0x4b5353[_0x47a5('0x1d')](0x0);return;}})['then'](function(){if(_0x24a6c1[_0x47a5('0x88')]===_0x47a5('0x89')){return null;}var _0x4c9e6a=_[_0x47a5('0x37')](_0x24a6c1,{'name':_0x24a6c1[_0x47a5('0x8a')]||_0x24a6c1[_0x47a5('0x26')]||_0x211fbf[_0x47a5('0x26')],'basename':_0x18fa31,'savename':util[_0x47a5('0x6d')](_0x47a5('0x8b'),_0x24a6c1['name']||_0x211fbf['name'],require('randomstring')[_0x47a5('0x8c')](0x4),_0x24a6c1[_0x47a5('0x88')]||'csv'),'reportId':_0x211fbf['id'],'reportType':_0x47a5('0x8d')});return db[_0x47a5('0x8e')][_0x47a5('0x3f')](_0x4c9e6a,{'raw':!![]});})[_0x47a5('0x21')](function(_0xcdbfd7){if(_0x211fbf['table']===_0x47a5('0x8f')){_0x23c393['where'](_0x211fbf['table']+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x24a6c1[_0x47a5('0x90')],_0x24a6c1['endDate']);}else{_0x23c393[_0x47a5('0x34')](_0x211fbf[_0x47a5('0x77')]+_0x47a5('0x91'),_0x24a6c1['startDate'],_0x24a6c1[_0x47a5('0x92')]);}if(_0xcdbfd7){logger[_0x47a5('0x93')](_0x47a5('0x94'),_0x23c393[_0x47a5('0x7a')]());require(_0x47a5('0x95'))['fork'](path[_0x47a5('0x7e')](__dirname,_0x47a5('0x96'),_0xcdbfd7['output']),[_0xcdbfd7['id'],_0x23c393[_0x47a5('0x7a')](),path[_0x47a5('0x7e')](__dirname,_0x47a5('0x97'),_0xcdbfd7[_0x47a5('0x98')]),_0x18fa31]);return _0xcdbfd7;}else{var _0x3c117a=squel[_0x47a5('0x66')]();_0x3c117a['from']('('+_0x23c393[_0x47a5('0x7a')]()+')',_0x47a5('0x99'));_0x3c117a['field'](_0x47a5('0x9a'),_0x47a5('0x1c'));_0x23c393[_0x47a5('0x1b')](_0x24a6c1[_0x47a5('0x1b')]||_0x420671);_0x23c393['offset'](_0x24a6c1['offset']||0x0);return dbH['sequelize']['query'](_0x3c117a[_0x47a5('0x7a')](),{'type':dbH[_0x47a5('0x7b')][_0x47a5('0x7c')][_0x47a5('0x7d')]})[_0x47a5('0x21')](function(_0x6bc37b){if(!_0x6bc37b[_0x47a5('0x2f')]){_0x2ae130=0x0;}else{_0x2ae130=_0x6bc37b[0x0][_0x47a5('0x1c')]||0x0;}return dbH['sequelize'][_0x47a5('0x2b')](_0x23c393[_0x47a5('0x7a')](),{'type':dbH[_0x47a5('0x7b')][_0x47a5('0x7c')]['SELECT']});})['then'](function(_0x3770ae){return{'rows':_0x3770ae||[],'count':_0x2ae130};});}});}exports['run']=function(_0x4cb8e4,_0x1b6a5c){return runReport(_0x4cb8e4[_0x47a5('0x4c')],_0x4cb8e4['query'],_0x4cb8e4[_0x47a5('0x38')])[_0x47a5('0x21')](respondWithResult(_0x1b6a5c,null))[_0x47a5('0x48')](handleError(_0x1b6a5c,null));};exports['runReport']=runReport;exports[_0x47a5('0x2b')]=function(_0xee23c7,_0x48a491){var _0x1172fd=0xa;var _0x280b7b=[_0x47a5('0x7e'),_0x47a5('0x7f'),_0x47a5('0x4d'),_0x47a5('0x4e')];var _0x482c87={'SUM':_0x47a5('0x4f'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x47a5('0x80'),'MAX':_0x47a5('0x81'),'MIN':_0x47a5('0x51'),'AVG':_0x47a5('0x52'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0x47a5('0x54'),'GROUP_CONCAT DESC':_0x47a5('0x9b')};var _0x151540={'SEC_TO_TIME':_0x47a5('0x55'),'DATE':_0x47a5('0x56'),'HOUR':_0x47a5('0x82'),'ROUND':_0x47a5('0x57'),'UNIX_TIMESTAMP':_0x47a5('0x83')};var _0x1b3e82=function(_0xa2045c){return!_[_0x47a5('0x58')]([_0x47a5('0x59'),'IS\x20NOT\x20NULL',_0x47a5('0x84'),_0x47a5('0x5b')],_0xa2045c);};var _0x591bde=function(_0x55d955){if(!_0x55d955||!_0x55d955[_0x47a5('0x5c')][_0x47a5('0x2f')]){return'';}for(var _0x2ccf21='(',_0x2ff467=0x0;_0x2ff467<_0x55d955['rules'][_0x47a5('0x2f')];_0x2ff467+=0x1){_0x2ff467>0x0&&(_0x2ccf21+='\x20'+_0x55d955[_0x47a5('0x85')]+'\x20');_0x2ccf21+=_0x55d955[_0x47a5('0x5c')][_0x2ff467][_0x47a5('0x5d')]?_0x591bde(_0x55d955[_0x47a5('0x5c')][_0x2ff467][_0x47a5('0x5d')]):_0x55d955[_0x47a5('0x5c')][_0x2ff467]['field']+'\x20'+_0x55d955['rules'][_0x2ff467][_0x47a5('0x5e')]+(_0x1b3e82(_0x55d955['rules'][_0x2ff467][_0x47a5('0x5e')])?'\x20'+_0x55d955['rules'][_0x2ff467][_0x47a5('0x5f')]:'');}return _0x2ccf21+')';};var _0x8b4354={'where':{'id':_0xee23c7[_0x47a5('0x4c')]['id']}},_0x134c1a,_0x2bc7ae,_0x49cb8c,_0x220557,_0x11f07b;_0x8b4354=_['merge']({},_0x8b4354,_0xee23c7['options']);return db[_0x47a5('0x39')][_0x47a5('0x4b')](_0x8b4354)[_0x47a5('0x21')](function(_0xfccf9c){if(_0xfccf9c){_0x134c1a=_0xfccf9c;return _0xfccf9c[_0x47a5('0x9c')]();}return null;})[_0x47a5('0x21')](function(_0x1c0323){if(_0x1c0323){if(!_0x1c0323[_0x47a5('0x2f')]){throw new db['Sequelize'][(_0x47a5('0x61'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x2bc7ae=_0x1c0323;return db[_0x47a5('0x63')][_0x47a5('0x64')]({'raw':!![]});}return null;})['then'](function(_0x48d4cf){if(_0x48d4cf){_0x49cb8c=_[_0x47a5('0x65')](_0x48d4cf,'id');var _0x41d2da;var _0x530387=squel[_0x47a5('0x66')]();_0x530387[_0x47a5('0x67')](_0x134c1a[_0x47a5('0x77')]);for(var _0x44567e=0x0;_0x44567e<_0x2bc7ae['length'];_0x44567e+=0x1){_0x41d2da=_0x2bc7ae[_0x44567e][_0x47a5('0x68')]?_0x49cb8c[_0x2bc7ae[_0x44567e]['MetricId']]['metric']:_0x2bc7ae[_0x44567e]['field'];_0x41d2da=_0x2bc7ae[_0x44567e][_0x47a5('0x6b')]?_['replace'](_0x482c87[_0x2bc7ae[_0x44567e][_0x47a5('0x6b')]],'%s',_0x41d2da):_0x41d2da;_0x41d2da=_0x2bc7ae[_0x44567e][_0x47a5('0x6d')]?_[_0x47a5('0x6c')](_0x151540[_0x2bc7ae[_0x44567e][_0x47a5('0x6d')]],'%s',_0x41d2da):_0x41d2da;if(_0x2bc7ae[_0x44567e][_0x47a5('0x86')]){_0x530387[_0x47a5('0x5d')](_0x41d2da);}_0x2bc7ae[_0x44567e][_0x47a5('0x6e')]&&_0x530387[_0x47a5('0x32')](_0x41d2da,_0x2bc7ae[_0x44567e][_0x47a5('0x6e')]===_0x47a5('0x6f')?![]:!![]);_0x530387[_0x47a5('0x6a')](_0x41d2da,_0x2bc7ae[_0x44567e][_0x47a5('0x87')]||_0x41d2da);}if(_0x134c1a[_0x47a5('0x70')]){_0x134c1a[_0x47a5('0x70')]=JSON[_0x47a5('0x71')](_0x134c1a['joins']);for(var _0xdd95c8=0x0;_0xdd95c8<_0x134c1a[_0x47a5('0x70')][_0x47a5('0x2f')];_0xdd95c8+=0x1){if(_0x134c1a[_0x47a5('0x70')][_0xdd95c8]['type']&&_[_0x47a5('0x58')](_0x280b7b,_0x134c1a['joins'][_0xdd95c8][_0x47a5('0x72')])&&_0x134c1a['joins'][_0xdd95c8][_0x47a5('0x73')]&&_0x134c1a[_0x47a5('0x70')][_0xdd95c8][_0x47a5('0x74')]&&_0x134c1a['joins'][_0xdd95c8][_0x47a5('0x75')]){_0x530387[_0x134c1a[_0x47a5('0x70')][_0xdd95c8][_0x47a5('0x72')]](_0x134c1a['joins'][_0xdd95c8]['foreignTable'],null,util[_0x47a5('0x6d')](_0x47a5('0x76'),_0x134c1a[_0x47a5('0x77')],_0x134c1a[_0x47a5('0x70')][_0xdd95c8][_0x47a5('0x73')],_0x134c1a['joins'][_0xdd95c8][_0x47a5('0x74')],_0x134c1a['joins'][_0xdd95c8][_0x47a5('0x75')]));}}}if(_0x134c1a[_0x47a5('0x78')]){_0x134c1a[_0x47a5('0x78')]=JSON[_0x47a5('0x71')](_0x134c1a['conditions']);_0x530387['where'](_0x591bde(_0x134c1a[_0x47a5('0x78')][_0x47a5('0x5d')]));}_0x11f07b=_0x530387[_0x47a5('0x9d')]();_0x530387[_0x47a5('0x1b')](_0x1172fd);_0x530387[_0x47a5('0x1d')](0x0);logger[_0x47a5('0x79')](_0x47a5('0x9e'),_0x530387[_0x47a5('0x7a')]());return dbH[_0x47a5('0x7b')]['query'](_0x530387['toString'](),{'type':dbH[_0x47a5('0x7b')]['QueryTypes'][_0x47a5('0x7d')]});}})[_0x47a5('0x21')](function(){return{'sql':_0x11f07b[_0x47a5('0x7a')]()};})['then'](respondWithResult(_0x48a491,null))[_0x47a5('0x48')](handleError(_0x48a491,null));};
\ No newline at end of file