Built motion from commit fe909640.|2.6.8
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index da2c0b5..f140e07 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9c6f=['Unable\x20to\x20retrieve\x20the\x20current\x20user','Reports','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','preview','join','right_join','cross_join','SUM(%s)','COUNT(%s)','MAX(%s)','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)','DATE(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','rules','operator','group','field','condition','value','getFields','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','MetricId','replace','format','groupBy','orderBy','DESC','alias','joins','parentKey','foreignTable','%s.%s\x20=\x20%s.%s','table','foreignKey','conditions','parse','debug','Limited\x20Query:','toString','QueryTypes','SELECT','left_join','COUNT(DISTINCT\x20%s)','AVG(%s)','ROUND(%s)','IS\x20NOT\x20EMPTY','Sequelize','metric','function','clone','sequelize','No\x20available\x20data','output','randomstring','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','info','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','runReport','html-pdf','eml-format','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','dbH','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','then','destroy','get','DefaultReports','end','error','stack','name','map','AnalyticDefaultReport','rawAttributes','fieldName','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','options','includeAll','findAll','rows','catch','params','keys','length','include','find','create','body','user'];(function(_0x4b5b5a,_0x3da7cb){var _0x40207e=function(_0x52f46c){while(--_0x52f46c){_0x4b5b5a['push'](_0x4b5b5a['shift']());}};_0x40207e(++_0x3da7cb);}(_0x9c6f,0x1a8));var _0xf9c6=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x9c6f[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xf9c6('0x0'));var emlformat=require(_0xf9c6('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xf9c6('0x2'));var rp=require(_0xf9c6('0x3'));var moment=require(_0xf9c6('0x4'));var BPromise=require(_0xf9c6('0x5'));var Mustache=require('mustache');var util=require(_0xf9c6('0x6'));var path=require(_0xf9c6('0x7'));var sox=require(_0xf9c6('0x8'));var csv=require(_0xf9c6('0x9'));var ejs=require(_0xf9c6('0xa'));var fs=require('fs');var _=require(_0xf9c6('0xb'));var squel=require(_0xf9c6('0xc'));var crypto=require('crypto');var jsforce=require(_0xf9c6('0xd'));var deskjs=require(_0xf9c6('0xe'));var toCsv=require(_0xf9c6('0x9'));var querystring=require(_0xf9c6('0xf'));var Papa=require(_0xf9c6('0x10'));var Redis=require(_0xf9c6('0x11'));var authService=require(_0xf9c6('0x12'));var qs=require(_0xf9c6('0x13'));var as=require(_0xf9c6('0x14'));var hardwareService=require(_0xf9c6('0x15'));var logger=require(_0xf9c6('0x16'))(_0xf9c6('0x17'));var utils=require('../../config/utils');var config=require(_0xf9c6('0x18'));var db=require(_0xf9c6('0x19'))['db'];var dbH=require(_0xf9c6('0x19'))[_0xf9c6('0x1a')];function respondWithStatusCode(_0x284c0f,_0x430930){_0x430930=_0x430930||0xcc;return function(_0x19e0f5){if(_0x19e0f5){return _0x284c0f[_0xf9c6('0x1b')](_0x430930);}return _0x284c0f[_0xf9c6('0x1c')](_0x430930)['end']();};}function respondWithResult(_0x187c09,_0x50a74f){_0x50a74f=_0x50a74f||0xc8;return function(_0x2d9488){if(_0x2d9488){return _0x187c09[_0xf9c6('0x1c')](_0x50a74f)[_0xf9c6('0x1d')](_0x2d9488);}};}function respondWithFilteredResult(_0x3366b7,_0x1115a3){return function(_0x468031){if(_0x468031){var _0x2d3213=_0x468031[_0xf9c6('0x1e')],_0x98daae=_0x1115a3[_0xf9c6('0x1f')],_0x208984=_0x1115a3[_0xf9c6('0x1f')]+_0x1115a3[_0xf9c6('0x20')],_0x278305;if(_0x208984>=_0x2d3213){_0x208984=_0x2d3213;_0x278305=0xc8;}else{_0x278305=0xce;}_0x3366b7[_0xf9c6('0x1c')](_0x278305);return _0x3366b7[_0xf9c6('0x21')](_0xf9c6('0x22'),_0x98daae+'-'+_0x208984+'/'+_0x2d3213)[_0xf9c6('0x1d')](_0x468031);}return null;};}function patchUpdates(_0x593568){return function(_0x5ec00f){try{jsonpatch[_0xf9c6('0x23')](_0x5ec00f,_0x593568,!![]);}catch(_0x2c970b){return BPromise[_0xf9c6('0x24')](_0x2c970b);}return _0x5ec00f['save']();};}function saveUpdates(_0x5c5aeb,_0x41f3){return function(_0x25e9e8){if(_0x25e9e8){return _0x25e9e8['update'](_0x5c5aeb)[_0xf9c6('0x25')](function(_0x1b0a05){return _0x1b0a05;});}return null;};}function removeEntity(_0x591cbc,_0x520e1b){return function(_0x228b8e){if(_0x228b8e){return _0x228b8e[_0xf9c6('0x26')]()['then'](function(){var _0x3c1cff=_0x228b8e[_0xf9c6('0x27')]({'plain':!![]});var _0x2c08f9=_0xf9c6('0x28');return db['UserProfileResource'][_0xf9c6('0x26')]({'where':{'type':_0x2c08f9,'resourceId':_0x3c1cff['id']}})[_0xf9c6('0x25')](function(){return _0x228b8e;});})['then'](function(){_0x591cbc[_0xf9c6('0x1c')](0xcc)[_0xf9c6('0x29')]();});}};}function handleEntityNotFound(_0x22214e,_0x6eab50){return function(_0x1d2518){if(!_0x1d2518){_0x22214e['sendStatus'](0x194);}return _0x1d2518;};}function handleError(_0x95251f,_0x53bb0e){_0x53bb0e=_0x53bb0e||0x1f4;return function(_0x9203c5){logger[_0xf9c6('0x2a')](_0x9203c5[_0xf9c6('0x2b')]);if(_0x9203c5[_0xf9c6('0x2c')]){delete _0x9203c5[_0xf9c6('0x2c')];}_0x95251f[_0xf9c6('0x1c')](_0x53bb0e)['send'](_0x9203c5);};}exports['index']=function(_0x3012d4,_0x3b3ad8){var _0x4ee157={},_0x4a9b3={},_0x25ec22={'count':0x0,'rows':[]};var _0x5bf82d=_[_0xf9c6('0x2d')](db[_0xf9c6('0x2e')][_0xf9c6('0x2f')],function(_0x5f1533){return{'name':_0x5f1533[_0xf9c6('0x30')],'type':_0x5f1533['type']['key']};});_0x4a9b3['model']=_['map'](_0x5bf82d,_0xf9c6('0x2c'));_0x4a9b3['query']=_['keys'](_0x3012d4[_0xf9c6('0x31')]);_0x4a9b3[_0xf9c6('0x32')]=_[_0xf9c6('0x33')](_0x4a9b3[_0xf9c6('0x34')],_0x4a9b3['query']);_0x4ee157[_0xf9c6('0x35')]=_[_0xf9c6('0x33')](_0x4a9b3[_0xf9c6('0x34')],qs[_0xf9c6('0x36')](_0x3012d4['query']['fields']));_0x4ee157['attributes']=_0x4ee157['attributes']['length']?_0x4ee157['attributes']:_0x4a9b3[_0xf9c6('0x34')];if(!_0x3012d4[_0xf9c6('0x31')][_0xf9c6('0x37')](_0xf9c6('0x38'))){_0x4ee157[_0xf9c6('0x20')]=qs[_0xf9c6('0x20')](_0x3012d4['query']['limit']);_0x4ee157[_0xf9c6('0x1f')]=qs[_0xf9c6('0x1f')](_0x3012d4[_0xf9c6('0x31')][_0xf9c6('0x1f')]);}_0x4ee157[_0xf9c6('0x39')]=qs['sort'](_0x3012d4[_0xf9c6('0x31')][_0xf9c6('0x3a')]);_0x4ee157[_0xf9c6('0x3b')]=qs[_0xf9c6('0x32')](_[_0xf9c6('0x3c')](_0x3012d4['query'],_0x4a9b3[_0xf9c6('0x32')]),_0x5bf82d);if(_0x3012d4[_0xf9c6('0x31')][_0xf9c6('0x3d')]){_0x4ee157[_0xf9c6('0x3b')]=_[_0xf9c6('0x3e')](_0x4ee157[_0xf9c6('0x3b')],{'$or':_['map'](_0x5bf82d,function(_0x52b886){if(_0x52b886[_0xf9c6('0x3f')]!=='VIRTUAL'){var _0x249330={};_0x249330[_0x52b886[_0xf9c6('0x2c')]]={'$like':'%'+_0x3012d4['query'][_0xf9c6('0x3d')]+'%'};return _0x249330;}})});}_0x4ee157=_[_0xf9c6('0x3e')]({},_0x4ee157,_0x3012d4[_0xf9c6('0x40')]);var _0x10bfb6={'where':_0x4ee157[_0xf9c6('0x3b')]};return db[_0xf9c6('0x2e')][_0xf9c6('0x1e')](_0x10bfb6)[_0xf9c6('0x25')](function(_0x77a5e1){_0x25ec22['count']=_0x77a5e1;if(_0x3012d4[_0xf9c6('0x31')][_0xf9c6('0x41')]){_0x4ee157['include']=[{'all':!![]}];}return db[_0xf9c6('0x2e')][_0xf9c6('0x42')](_0x4ee157);})[_0xf9c6('0x25')](function(_0x424bda){_0x25ec22[_0xf9c6('0x43')]=_0x424bda;return _0x25ec22;})[_0xf9c6('0x25')](respondWithFilteredResult(_0x3b3ad8,_0x4ee157))[_0xf9c6('0x44')](handleError(_0x3b3ad8,null));};exports['show']=function(_0x3a0b99,_0x403e0a){var _0x4d17ee={'raw':!![],'where':{'id':_0x3a0b99[_0xf9c6('0x45')]['id']}},_0x33d1eb={};_0x33d1eb['model']=_[_0xf9c6('0x46')](db['AnalyticDefaultReport']['rawAttributes']);_0x33d1eb[_0xf9c6('0x31')]=_['keys'](_0x3a0b99[_0xf9c6('0x31')]);_0x33d1eb[_0xf9c6('0x32')]=_['intersection'](_0x33d1eb[_0xf9c6('0x34')],_0x33d1eb[_0xf9c6('0x31')]);_0x4d17ee['attributes']=_[_0xf9c6('0x33')](_0x33d1eb[_0xf9c6('0x34')],qs[_0xf9c6('0x36')](_0x3a0b99[_0xf9c6('0x31')][_0xf9c6('0x36')]));_0x4d17ee[_0xf9c6('0x35')]=_0x4d17ee[_0xf9c6('0x35')][_0xf9c6('0x47')]?_0x4d17ee[_0xf9c6('0x35')]:_0x33d1eb[_0xf9c6('0x34')];if(_0x3a0b99[_0xf9c6('0x31')][_0xf9c6('0x41')]){_0x4d17ee[_0xf9c6('0x48')]=[{'all':!![]}];}_0x4d17ee=_[_0xf9c6('0x3e')]({},_0x4d17ee,_0x3a0b99[_0xf9c6('0x40')]);return db[_0xf9c6('0x2e')][_0xf9c6('0x49')](_0x4d17ee)[_0xf9c6('0x25')](handleEntityNotFound(_0x403e0a,null))[_0xf9c6('0x25')](respondWithResult(_0x403e0a,null))[_0xf9c6('0x44')](handleError(_0x403e0a,null));};exports[_0xf9c6('0x4a')]=function(_0xfdddf2,_0x4dc53d){return db['AnalyticDefaultReport'][_0xf9c6('0x4a')](_0xfdddf2[_0xf9c6('0x4b')],{})[_0xf9c6('0x25')](function(_0x308225){var _0x20fe96=_0xfdddf2[_0xf9c6('0x4c')][_0xf9c6('0x27')]({'plain':!![]});if(!_0x20fe96)throw new Error(_0xf9c6('0x4d'));if(_0x20fe96['role']==='user'){var _0x5241db=_0x308225[_0xf9c6('0x27')]({'plain':!![]});var _0xc0d5c=_0xf9c6('0x4e');return db[_0xf9c6('0x4f')][_0xf9c6('0x49')]({'where':{'name':_0xc0d5c,'userProfileId':_0x20fe96[_0xf9c6('0x50')]},'raw':!![]})[_0xf9c6('0x25')](function(_0x180b0f){if(_0x180b0f&&_0x180b0f[_0xf9c6('0x51')]===0x0){return db[_0xf9c6('0x52')]['create']({'name':_0x5241db[_0xf9c6('0x2c')],'resourceId':_0x5241db['id'],'type':'DefaultReports','sectionId':_0x180b0f['id']},{})['then'](function(){return _0x308225;});}else{return _0x308225;}})[_0xf9c6('0x44')](function(_0xfe375f){logger['error'](_0xf9c6('0x53'),_0xfe375f);throw _0xfe375f;});}return _0x308225;})[_0xf9c6('0x25')](respondWithResult(_0x4dc53d,0xc9))[_0xf9c6('0x44')](handleError(_0x4dc53d,null));};exports[_0xf9c6('0x54')]=function(_0x58cb6e,_0x5275c5){if(_0x58cb6e[_0xf9c6('0x4b')]['id']){delete _0x58cb6e[_0xf9c6('0x4b')]['id'];}return db[_0xf9c6('0x2e')][_0xf9c6('0x49')]({'where':{'id':_0x58cb6e[_0xf9c6('0x45')]['id']}})['then'](handleEntityNotFound(_0x5275c5,null))['then'](saveUpdates(_0x58cb6e['body'],null))['then'](respondWithResult(_0x5275c5,null))[_0xf9c6('0x44')](handleError(_0x5275c5,null));};exports[_0xf9c6('0x26')]=function(_0x5c7b4a,_0x305e9a){return db['AnalyticDefaultReport']['find']({'where':{'id':_0x5c7b4a[_0xf9c6('0x45')]['id']}})[_0xf9c6('0x25')](handleEntityNotFound(_0x305e9a,null))['then'](removeEntity(_0x305e9a,null))[_0xf9c6('0x44')](handleError(_0x305e9a,null));};exports[_0xf9c6('0x55')]=function(_0x4068b6,_0x5c2e48){var _0x151c37=0xa;var _0x161d25=[_0xf9c6('0x56'),'left_join',_0xf9c6('0x57'),_0xf9c6('0x58')];var _0x26e17e={'SUM':_0xf9c6('0x59'),'COUNT':_0xf9c6('0x5a'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xf9c6('0x5b'),'MIN':_0xf9c6('0x5c'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xf9c6('0x5d'),'GROUP_CONCAT ASC':_0xf9c6('0x5e'),'GROUP_CONCAT DESC':_0xf9c6('0x5f')};var _0x4a5512={'SEC_TO_TIME':_0xf9c6('0x60'),'DATE':_0xf9c6('0x61'),'HOUR':_0xf9c6('0x62'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xf9c6('0x63')};var _0x458eb8=function(_0x394991){return!_[_0xf9c6('0x64')]([_0xf9c6('0x65'),_0xf9c6('0x66'),_0xf9c6('0x67'),'IS\x20NOT\x20EMPTY'],_0x394991);};var _0x26a5a8=function(_0x4e1710){if(!_0x4e1710||!_0x4e1710[_0xf9c6('0x68')][_0xf9c6('0x47')]){return'';}for(var _0x5b6e09='(',_0x26bf2e=0x0;_0x26bf2e<_0x4e1710[_0xf9c6('0x68')][_0xf9c6('0x47')];_0x26bf2e+=0x1){_0x26bf2e>0x0&&(_0x5b6e09+='\x20'+_0x4e1710[_0xf9c6('0x69')]+'\x20');_0x5b6e09+=_0x4e1710[_0xf9c6('0x68')][_0x26bf2e][_0xf9c6('0x6a')]?_0x26a5a8(_0x4e1710[_0xf9c6('0x68')][_0x26bf2e][_0xf9c6('0x6a')]):_0x4e1710[_0xf9c6('0x68')][_0x26bf2e][_0xf9c6('0x6b')]+'\x20'+_0x4e1710[_0xf9c6('0x68')][_0x26bf2e][_0xf9c6('0x6c')]+(_0x458eb8(_0x4e1710[_0xf9c6('0x68')][_0x26bf2e][_0xf9c6('0x6c')])?'\x20'+_0x4e1710[_0xf9c6('0x68')][_0x26bf2e][_0xf9c6('0x6d')]:'');}return _0x5b6e09+')';};var _0x4a00b2={'where':{'id':_0x4068b6[_0xf9c6('0x45')]['id']}},_0x29fc1e,_0x58e603,_0x264029,_0x1604a9,_0x480008;_0x4a00b2=_['merge']({},_0x4a00b2,_0x4068b6[_0xf9c6('0x40')]);return db[_0xf9c6('0x2e')][_0xf9c6('0x49')](_0x4a00b2)['then'](function(_0x4a824d){if(_0x4a824d){_0x29fc1e=_0x4a824d;return _0x4a824d[_0xf9c6('0x6e')]();}return null;})['then'](function(_0x344b0a){if(_0x344b0a){if(!_0x344b0a[_0xf9c6('0x47')]){throw new db['Sequelize'][(_0xf9c6('0x6f'))](_0xf9c6('0x70'),0x193);}_0x58e603=_0x344b0a;return db[_0xf9c6('0x71')][_0xf9c6('0x42')]({'raw':!![]});}return null;})[_0xf9c6('0x25')](function(_0x3b2d61){if(_0x3b2d61){_0x264029=_[_0xf9c6('0x72')](_0x3b2d61,'id');var _0x27041b;var _0x2b3939=squel[_0xf9c6('0x73')]();_0x2b3939[_0xf9c6('0x74')](_0x29fc1e['table']);for(var _0x121962=0x0;_0x121962<_0x58e603[_0xf9c6('0x47')];_0x121962+=0x1){_0x27041b=_0x58e603[_0x121962][_0xf9c6('0x75')]?_0x264029[_0x58e603[_0x121962][_0xf9c6('0x75')]]['metric']:_0x58e603[_0x121962][_0xf9c6('0x6b')];_0x27041b=_0x58e603[_0x121962]['function']?_[_0xf9c6('0x76')](_0x26e17e[_0x58e603[_0x121962]['function']],'%s',_0x27041b):_0x27041b;_0x27041b=_0x58e603[_0x121962][_0xf9c6('0x77')]?_['replace'](_0x4a5512[_0x58e603[_0x121962][_0xf9c6('0x77')]],'%s',_0x27041b):_0x27041b;if(_0x58e603[_0x121962][_0xf9c6('0x78')]){_0x2b3939[_0xf9c6('0x6a')](_0x27041b);}_0x58e603[_0x121962]['orderBy']&&_0x2b3939[_0xf9c6('0x39')](_0x27041b,_0x58e603[_0x121962][_0xf9c6('0x79')]===_0xf9c6('0x7a')?![]:!![]);_0x2b3939['field'](_0x27041b,_0x58e603[_0x121962][_0xf9c6('0x7b')]||_0x27041b);}if(_0x29fc1e['joins']){_0x29fc1e['joins']=JSON['parse'](_0x29fc1e[_0xf9c6('0x7c')]);for(var _0x55383a=0x0;_0x55383a<_0x29fc1e['joins']['length'];_0x55383a+=0x1){if(_0x29fc1e[_0xf9c6('0x7c')][_0x55383a]['type']&&_[_0xf9c6('0x64')](_0x161d25,_0x29fc1e[_0xf9c6('0x7c')][_0x55383a]['type'])&&_0x29fc1e['joins'][_0x55383a][_0xf9c6('0x7d')]&&_0x29fc1e[_0xf9c6('0x7c')][_0x55383a][_0xf9c6('0x7e')]&&_0x29fc1e[_0xf9c6('0x7c')][_0x55383a]['foreignKey']){_0x2b3939[_0x29fc1e[_0xf9c6('0x7c')][_0x55383a][_0xf9c6('0x3f')]](_0x29fc1e[_0xf9c6('0x7c')][_0x55383a][_0xf9c6('0x7e')],null,util[_0xf9c6('0x77')](_0xf9c6('0x7f'),_0x29fc1e[_0xf9c6('0x80')],_0x29fc1e[_0xf9c6('0x7c')][_0x55383a][_0xf9c6('0x7d')],_0x29fc1e[_0xf9c6('0x7c')][_0x55383a]['foreignTable'],_0x29fc1e[_0xf9c6('0x7c')][_0x55383a][_0xf9c6('0x81')]));}}}if(_0x29fc1e[_0xf9c6('0x82')]){_0x29fc1e['conditions']=JSON[_0xf9c6('0x83')](_0x29fc1e[_0xf9c6('0x82')]);_0x2b3939['where'](_0x26a5a8(_0x29fc1e[_0xf9c6('0x82')][_0xf9c6('0x6a')]));}_0x480008=_0x2b3939['clone']();_0x2b3939[_0xf9c6('0x20')](_0x151c37);_0x2b3939[_0xf9c6('0x1f')](0x0);logger[_0xf9c6('0x84')](_0xf9c6('0x85'),_0x2b3939[_0xf9c6('0x86')]());return db['sequelize'][_0xf9c6('0x31')](_0x2b3939[_0xf9c6('0x86')](),{'type':db['sequelize'][_0xf9c6('0x87')][_0xf9c6('0x88')]});}})['then'](respondWithResult(_0x5c2e48,null))[_0xf9c6('0x44')](handleError(_0x5c2e48,null));};function runReport(_0x24b18a,_0x3a113b,_0x46e139){var _0x10d4b2=_0x3a113b[_0xf9c6('0x2c')];var _0x221d65=0xa;var _0x4e6a83=[_0xf9c6('0x56'),_0xf9c6('0x89'),'right_join',_0xf9c6('0x58')];var _0x42db50={'SUM':_0xf9c6('0x59'),'COUNT':_0xf9c6('0x5a'),'COUNT DISTINCT':_0xf9c6('0x8a'),'MAX':_0xf9c6('0x5b'),'MIN':_0xf9c6('0x5c'),'AVG':_0xf9c6('0x8b'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xf9c6('0x5e'),'GROUP_CONCAT DESC':_0xf9c6('0x5f')};var _0x218a4a={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xf9c6('0x61'),'HOUR':_0xf9c6('0x62'),'ROUND':_0xf9c6('0x8c'),'UNIX_TIMESTAMP':_0xf9c6('0x63')};var _0x247991=function(_0x10057f){return!_['includes']([_0xf9c6('0x65'),_0xf9c6('0x66'),_0xf9c6('0x67'),_0xf9c6('0x8d')],_0x10057f);};var _0x5f3577=function(_0x4c1a08){if(!_0x4c1a08||!_0x4c1a08['rules'][_0xf9c6('0x47')]){return'';}for(var _0x363e22='(',_0x1cbab3=0x0;_0x1cbab3<_0x4c1a08[_0xf9c6('0x68')][_0xf9c6('0x47')];_0x1cbab3+=0x1){_0x1cbab3>0x0&&(_0x363e22+='\x20'+_0x4c1a08[_0xf9c6('0x69')]+'\x20');_0x363e22+=_0x4c1a08['rules'][_0x1cbab3]['group']?_0x5f3577(_0x4c1a08['rules'][_0x1cbab3][_0xf9c6('0x6a')]):_0x4c1a08[_0xf9c6('0x68')][_0x1cbab3][_0xf9c6('0x6b')]+'\x20'+_0x4c1a08[_0xf9c6('0x68')][_0x1cbab3][_0xf9c6('0x6c')]+(_0x247991(_0x4c1a08[_0xf9c6('0x68')][_0x1cbab3][_0xf9c6('0x6c')])?'\x20'+_0x4c1a08[_0xf9c6('0x68')][_0x1cbab3]['value']:'');}return _0x363e22+')';};var _0x87f795={'where':{'id':_0x24b18a['id']}},_0x1af160,_0x22d459,_0x5b9aa9,_0x52c294,_0x316045;_0x87f795=_['merge']({},_0x87f795,_0x46e139);return db['AnalyticDefaultReport']['find'](_0x87f795)[_0xf9c6('0x25')](function(_0x1c77d5){if(_0x1c77d5){_0x1af160=_0x1c77d5;return _0x1c77d5[_0xf9c6('0x6e')]();}return null;})[_0xf9c6('0x25')](function(_0x56cde8){if(_0x56cde8){if(!_0x56cde8['length']){throw new db[(_0xf9c6('0x8e'))]['ValidationErrorItem'](_0xf9c6('0x70'),0x193);}_0x22d459=_0x56cde8;return db[_0xf9c6('0x71')]['findAll']({'raw':!![]});}return null;})[_0xf9c6('0x25')](function(_0xe97b38){if(_0xe97b38){_0x5b9aa9=_['keyBy'](_0xe97b38,'id');var _0x121387;var _0x124d65=squel[_0xf9c6('0x73')]();_0x124d65[_0xf9c6('0x74')](_0x1af160[_0xf9c6('0x80')]);for(var _0x28b214=0x0;_0x28b214<_0x22d459[_0xf9c6('0x47')];_0x28b214+=0x1){_0x121387=_0x22d459[_0x28b214][_0xf9c6('0x75')]?_0x5b9aa9[_0x22d459[_0x28b214][_0xf9c6('0x75')]][_0xf9c6('0x8f')]:_0x22d459[_0x28b214]['field'];_0x121387=_0x22d459[_0x28b214][_0xf9c6('0x90')]?_[_0xf9c6('0x76')](_0x42db50[_0x22d459[_0x28b214][_0xf9c6('0x90')]],'%s',_0x121387):_0x121387;_0x121387=_0x22d459[_0x28b214]['format']?_['replace'](_0x218a4a[_0x22d459[_0x28b214][_0xf9c6('0x77')]],'%s',_0x121387):_0x121387;if(_0x22d459[_0x28b214][_0xf9c6('0x78')]){_0x124d65[_0xf9c6('0x6a')](_0x121387);}_0x22d459[_0x28b214][_0xf9c6('0x79')]&&_0x124d65['order'](_0x121387,_0x22d459[_0x28b214][_0xf9c6('0x79')]==='DESC'?![]:!![]);_0x124d65[_0xf9c6('0x6b')](_0x121387,_0x22d459[_0x28b214][_0xf9c6('0x7b')]||_0x121387);}if(_0x1af160[_0xf9c6('0x7c')]){_0x1af160['joins']=JSON['parse'](_0x1af160['joins']);for(var _0x44650d=0x0;_0x44650d<_0x1af160['joins'][_0xf9c6('0x47')];_0x44650d+=0x1){if(_0x1af160['joins'][_0x44650d]['type']&&_['includes'](_0x4e6a83,_0x1af160[_0xf9c6('0x7c')][_0x44650d][_0xf9c6('0x3f')])&&_0x1af160[_0xf9c6('0x7c')][_0x44650d]['parentKey']&&_0x1af160[_0xf9c6('0x7c')][_0x44650d][_0xf9c6('0x7e')]&&_0x1af160[_0xf9c6('0x7c')][_0x44650d]['foreignKey']){_0x124d65[_0x1af160[_0xf9c6('0x7c')][_0x44650d][_0xf9c6('0x3f')]](_0x1af160[_0xf9c6('0x7c')][_0x44650d][_0xf9c6('0x7e')],null,util[_0xf9c6('0x77')]('%s.%s\x20=\x20%s.%s',_0x1af160[_0xf9c6('0x80')],_0x1af160[_0xf9c6('0x7c')][_0x44650d][_0xf9c6('0x7d')],_0x1af160[_0xf9c6('0x7c')][_0x44650d][_0xf9c6('0x7e')],_0x1af160[_0xf9c6('0x7c')][_0x44650d]['foreignKey']));}}}if(_0x1af160['conditions']){_0x1af160['conditions']=JSON['parse'](_0x1af160[_0xf9c6('0x82')]);_0x124d65['where'](_0x5f3577(_0x1af160[_0xf9c6('0x82')][_0xf9c6('0x6a')]));}_0x316045=_0x124d65[_0xf9c6('0x91')]();_0x124d65[_0xf9c6('0x20')](_0x221d65);_0x124d65[_0xf9c6('0x1f')](0x0);logger['debug'](_0xf9c6('0x85'),_0x124d65['toString']());return db[_0xf9c6('0x92')]['query'](_0x124d65[_0xf9c6('0x86')](),{'type':db[_0xf9c6('0x92')][_0xf9c6('0x87')][_0xf9c6('0x88')]});}})['then'](function(_0x59b791){if(!_0x59b791[_0xf9c6('0x47')]){throw new db[(_0xf9c6('0x8e'))][(_0xf9c6('0x6f'))](_0xf9c6('0x93'),0xcc);}if(_0x3a113b[_0xf9c6('0x94')]==='web'){return null;}var _0x35a257=_[_0xf9c6('0x3e')](_0x3a113b,{'name':_0x3a113b['fullPath']||_0x3a113b[_0xf9c6('0x2c')]||_0x1af160[_0xf9c6('0x2c')],'basename':_0x10d4b2,'savename':util[_0xf9c6('0x77')]('%s-%s.%s',_0x3a113b[_0xf9c6('0x2c')]||_0x1af160[_0xf9c6('0x2c')],require(_0xf9c6('0x95'))['generate'](0x4),_0x3a113b['output']||_0xf9c6('0x96')),'reportId':_0x1af160['id'],'reportType':_0xf9c6('0x97')});return db[_0xf9c6('0x98')][_0xf9c6('0x4a')](_0x35a257,{'raw':!![]});})['then'](function(_0x302387){if(_0x1af160['table']===_0xf9c6('0x99')){_0x316045[_0xf9c6('0x3b')](_0x1af160[_0xf9c6('0x80')]+_0xf9c6('0x9a'),_0x3a113b[_0xf9c6('0x9b')],_0x3a113b['endDate']);}else{_0x316045['where'](_0x1af160[_0xf9c6('0x80')]+_0xf9c6('0x9c'),_0x3a113b[_0xf9c6('0x9b')],_0x3a113b[_0xf9c6('0x9d')]);}if(_0x302387){logger[_0xf9c6('0x9e')]('Run\x20Query:',_0x316045[_0xf9c6('0x86')]());require(_0xf9c6('0x9f'))[_0xf9c6('0xa0')](path[_0xf9c6('0x56')](__dirname,_0xf9c6('0xa1'),_0x302387[_0xf9c6('0x94')]),[_0x302387['id'],_0x316045[_0xf9c6('0x86')](),path[_0xf9c6('0x56')](__dirname,_0xf9c6('0xa2'),_0x302387[_0xf9c6('0xa3')]),_0x10d4b2]);return _0x302387;}else{var _0x102199=squel[_0xf9c6('0x73')]();_0x102199[_0xf9c6('0x74')]('('+_0x316045[_0xf9c6('0x86')]()+')',_0xf9c6('0xa4'));_0x102199[_0xf9c6('0x6b')](_0xf9c6('0xa5'),_0xf9c6('0x1e'));_0x316045['limit'](_0x3a113b[_0xf9c6('0x20')]||_0x221d65);_0x316045[_0xf9c6('0x1f')](_0x3a113b[_0xf9c6('0x1f')]||0x0);return dbH[_0xf9c6('0x92')][_0xf9c6('0x31')](_0x102199[_0xf9c6('0x86')](),{'type':dbH[_0xf9c6('0x92')]['QueryTypes'][_0xf9c6('0x88')]})[_0xf9c6('0x25')](function(_0x46b74d){if(!_0x46b74d[_0xf9c6('0x47')]){_0x52c294=0x0;}else{_0x52c294=_0x46b74d[0x0][_0xf9c6('0x1e')]||0x0;}return dbH[_0xf9c6('0x92')][_0xf9c6('0x31')](_0x316045[_0xf9c6('0x86')](),{'type':dbH[_0xf9c6('0x92')][_0xf9c6('0x87')]['SELECT']});})['then'](function(_0x1a4aae){return{'rows':_0x1a4aae||[],'count':_0x52c294};});}});}exports['run']=function(_0x1ad3a3,_0x403f15){return runReport(_0x1ad3a3[_0xf9c6('0x45')],_0x1ad3a3[_0xf9c6('0x31')],_0x1ad3a3[_0xf9c6('0x40')])[_0xf9c6('0x25')](respondWithResult(_0x403f15,null))[_0xf9c6('0x44')](handleError(_0x403f15,null));};exports[_0xf9c6('0xa6')]=runReport;exports[_0xf9c6('0x31')]=function(_0xaf62e1,_0x17ffd9){var _0xea2881=0xa;var _0x1f4ebe=[_0xf9c6('0x56'),_0xf9c6('0x89'),_0xf9c6('0x57'),_0xf9c6('0x58')];var _0x22e1df={'SUM':'SUM(%s)','COUNT':_0xf9c6('0x5a'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':'MAX(%s)','MIN':_0xf9c6('0x5c'),'AVG':_0xf9c6('0x8b'),'GROUP_CONCAT':_0xf9c6('0x5d'),'GROUP_CONCAT ASC':_0xf9c6('0x5e'),'GROUP_CONCAT DESC':_0xf9c6('0x5f')};var _0x3ae21b={'SEC_TO_TIME':_0xf9c6('0x60'),'DATE':_0xf9c6('0x61'),'HOUR':_0xf9c6('0x62'),'ROUND':_0xf9c6('0x8c'),'UNIX_TIMESTAMP':_0xf9c6('0x63')};var _0x5c0428=function(_0x3197b2){return!_[_0xf9c6('0x64')]([_0xf9c6('0x65'),_0xf9c6('0x66'),_0xf9c6('0x67'),_0xf9c6('0x8d')],_0x3197b2);};var _0x1c82bc=function(_0x5b7edb){if(!_0x5b7edb||!_0x5b7edb['rules'][_0xf9c6('0x47')]){return'';}for(var _0x3a8ee0='(',_0x54d04e=0x0;_0x54d04e<_0x5b7edb[_0xf9c6('0x68')]['length'];_0x54d04e+=0x1){_0x54d04e>0x0&&(_0x3a8ee0+='\x20'+_0x5b7edb[_0xf9c6('0x69')]+'\x20');_0x3a8ee0+=_0x5b7edb[_0xf9c6('0x68')][_0x54d04e][_0xf9c6('0x6a')]?_0x1c82bc(_0x5b7edb[_0xf9c6('0x68')][_0x54d04e][_0xf9c6('0x6a')]):_0x5b7edb[_0xf9c6('0x68')][_0x54d04e][_0xf9c6('0x6b')]+'\x20'+_0x5b7edb[_0xf9c6('0x68')][_0x54d04e][_0xf9c6('0x6c')]+(_0x5c0428(_0x5b7edb[_0xf9c6('0x68')][_0x54d04e][_0xf9c6('0x6c')])?'\x20'+_0x5b7edb[_0xf9c6('0x68')][_0x54d04e][_0xf9c6('0x6d')]:'');}return _0x3a8ee0+')';};var _0x59c604={'where':{'id':_0xaf62e1[_0xf9c6('0x45')]['id']}},_0x4558f4,_0x545bbd,_0x23010b,_0x1be4ea,_0x5e8729;_0x59c604=_[_0xf9c6('0x3e')]({},_0x59c604,_0xaf62e1[_0xf9c6('0x40')]);return db[_0xf9c6('0x2e')][_0xf9c6('0x49')](_0x59c604)[_0xf9c6('0x25')](function(_0x3ac6e5){if(_0x3ac6e5){_0x4558f4=_0x3ac6e5;return _0x3ac6e5[_0xf9c6('0x6e')]();}return null;})['then'](function(_0x442b2){if(_0x442b2){if(!_0x442b2[_0xf9c6('0x47')]){throw new db[(_0xf9c6('0x8e'))][(_0xf9c6('0x6f'))](_0xf9c6('0x70'),0x193);}_0x545bbd=_0x442b2;return db['AnalyticMetric'][_0xf9c6('0x42')]({'raw':!![]});}return null;})['then'](function(_0x2cd700){if(_0x2cd700){_0x23010b=_[_0xf9c6('0x72')](_0x2cd700,'id');var _0x103ac7;var _0xb7036c=squel[_0xf9c6('0x73')]();_0xb7036c['from'](_0x4558f4[_0xf9c6('0x80')]);for(var _0x10ea3c=0x0;_0x10ea3c<_0x545bbd[_0xf9c6('0x47')];_0x10ea3c+=0x1){_0x103ac7=_0x545bbd[_0x10ea3c][_0xf9c6('0x75')]?_0x23010b[_0x545bbd[_0x10ea3c][_0xf9c6('0x75')]][_0xf9c6('0x8f')]:_0x545bbd[_0x10ea3c][_0xf9c6('0x6b')];_0x103ac7=_0x545bbd[_0x10ea3c][_0xf9c6('0x90')]?_[_0xf9c6('0x76')](_0x22e1df[_0x545bbd[_0x10ea3c][_0xf9c6('0x90')]],'%s',_0x103ac7):_0x103ac7;_0x103ac7=_0x545bbd[_0x10ea3c][_0xf9c6('0x77')]?_[_0xf9c6('0x76')](_0x3ae21b[_0x545bbd[_0x10ea3c]['format']],'%s',_0x103ac7):_0x103ac7;if(_0x545bbd[_0x10ea3c][_0xf9c6('0x78')]){_0xb7036c['group'](_0x103ac7);}_0x545bbd[_0x10ea3c]['orderBy']&&_0xb7036c[_0xf9c6('0x39')](_0x103ac7,_0x545bbd[_0x10ea3c][_0xf9c6('0x79')]==='DESC'?![]:!![]);_0xb7036c[_0xf9c6('0x6b')](_0x103ac7,_0x545bbd[_0x10ea3c]['alias']||_0x103ac7);}if(_0x4558f4[_0xf9c6('0x7c')]){_0x4558f4[_0xf9c6('0x7c')]=JSON[_0xf9c6('0x83')](_0x4558f4[_0xf9c6('0x7c')]);for(var _0x1c960d=0x0;_0x1c960d<_0x4558f4[_0xf9c6('0x7c')][_0xf9c6('0x47')];_0x1c960d+=0x1){if(_0x4558f4[_0xf9c6('0x7c')][_0x1c960d][_0xf9c6('0x3f')]&&_[_0xf9c6('0x64')](_0x1f4ebe,_0x4558f4[_0xf9c6('0x7c')][_0x1c960d][_0xf9c6('0x3f')])&&_0x4558f4[_0xf9c6('0x7c')][_0x1c960d][_0xf9c6('0x7d')]&&_0x4558f4['joins'][_0x1c960d][_0xf9c6('0x7e')]&&_0x4558f4[_0xf9c6('0x7c')][_0x1c960d][_0xf9c6('0x81')]){_0xb7036c[_0x4558f4['joins'][_0x1c960d][_0xf9c6('0x3f')]](_0x4558f4['joins'][_0x1c960d][_0xf9c6('0x7e')],null,util[_0xf9c6('0x77')](_0xf9c6('0x7f'),_0x4558f4['table'],_0x4558f4[_0xf9c6('0x7c')][_0x1c960d]['parentKey'],_0x4558f4[_0xf9c6('0x7c')][_0x1c960d]['foreignTable'],_0x4558f4['joins'][_0x1c960d][_0xf9c6('0x81')]));}}}if(_0x4558f4['conditions']){_0x4558f4[_0xf9c6('0x82')]=JSON[_0xf9c6('0x83')](_0x4558f4[_0xf9c6('0x82')]);_0xb7036c[_0xf9c6('0x3b')](_0x1c82bc(_0x4558f4['conditions'][_0xf9c6('0x6a')]));}_0x5e8729=_0xb7036c[_0xf9c6('0x91')]();_0xb7036c[_0xf9c6('0x20')](_0xea2881);_0xb7036c[_0xf9c6('0x1f')](0x0);logger[_0xf9c6('0x84')]('Limited\x20Query:',_0xb7036c['toString']());return db[_0xf9c6('0x92')][_0xf9c6('0x31')](_0xb7036c[_0xf9c6('0x86')](),{'type':db['sequelize'][_0xf9c6('0x87')][_0xf9c6('0x88')]});}})[_0xf9c6('0x25')](function(){return{'sql':_0x5e8729[_0xf9c6('0x86')]()};})[_0xf9c6('0x25')](respondWithResult(_0x17ffd9,null))[_0xf9c6('0x44')](handleError(_0x17ffd9,null));};
\ No newline at end of file
+var _0x3f8a=['get','DefaultReports','end','error','stack','name','send','index','map','AnalyticDefaultReport','rawAttributes','type','key','keys','intersection','model','attributes','fields','query','order','sort','filters','pick','filter','merge','VIRTUAL','options','where','include','findAll','catch','show','params','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','preview','join','left_join','right_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','length','operator','group','field','value','getFields','Sequelize','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','table','MetricId','function','replace','format','groupBy','orderBy','alias','joins','parse','parentKey','foreignTable','foreignKey','conditions','Limited\x20Query:','sequelize','toString','SELECT','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','IS\x20NULL','condition','ValidationErrorItem','metric','DESC','clone','output','web','fullPath','%s-%s.%s','randomstring','generate','csv','default','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','countTable','COUNT(*)','QueryTypes','run','runReport','%s.%s\x20=\x20%s.%s','debug','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','status','offset','undefined','limit','count','set','json','apply','reject','save','update','destroy','then'];(function(_0x570b93,_0x478f34){var _0x2dc417=function(_0x2e0d05){while(--_0x2e0d05){_0x570b93['push'](_0x570b93['shift']());}};_0x2dc417(++_0x478f34);}(_0x3f8a,0x1d5));var _0xa3f8=function(_0x452c3a,_0xd8155b){_0x452c3a=_0x452c3a-0x0;var _0x54e03f=_0x3f8a[_0x452c3a];return _0x54e03f;};'use strict';var emlformat=require(_0xa3f8('0x0'));var rimraf=require(_0xa3f8('0x1'));var zipdir=require(_0xa3f8('0x2'));var jsonpatch=require(_0xa3f8('0x3'));var rp=require('request-promise');var moment=require(_0xa3f8('0x4'));var BPromise=require(_0xa3f8('0x5'));var Mustache=require(_0xa3f8('0x6'));var util=require(_0xa3f8('0x7'));var path=require(_0xa3f8('0x8'));var sox=require(_0xa3f8('0x9'));var csv=require(_0xa3f8('0xa'));var ejs=require(_0xa3f8('0xb'));var fs=require('fs');var fs_extra=require(_0xa3f8('0xc'));var _=require(_0xa3f8('0xd'));var squel=require(_0xa3f8('0xe'));var crypto=require(_0xa3f8('0xf'));var jsforce=require(_0xa3f8('0x10'));var deskjs=require(_0xa3f8('0x11'));var toCsv=require(_0xa3f8('0xa'));var querystring=require(_0xa3f8('0x12'));var Papa=require(_0xa3f8('0x13'));var Redis=require('ioredis');var authService=require(_0xa3f8('0x14'));var qs=require(_0xa3f8('0x15'));var as=require(_0xa3f8('0x16'));var hardwareService=require(_0xa3f8('0x17'));var logger=require('../../config/logger')(_0xa3f8('0x18'));var utils=require(_0xa3f8('0x19'));var config=require(_0xa3f8('0x1a'));var licenseUtil=require(_0xa3f8('0x1b'));var db=require(_0xa3f8('0x1c'))['db'];var dbH=require(_0xa3f8('0x1c'))[_0xa3f8('0x1d')];function respondWithStatusCode(_0x63de8b,_0x324aa8){_0x324aa8=_0x324aa8||0xcc;return function(_0x36b1b8){if(_0x36b1b8){return _0x63de8b[_0xa3f8('0x1e')](_0x324aa8);}return _0x63de8b[_0xa3f8('0x1f')](_0x324aa8)['end']();};}function respondWithResult(_0x2d8f74,_0xe55848){_0xe55848=_0xe55848||0xc8;return function(_0x45014f){if(_0x45014f){return _0x2d8f74[_0xa3f8('0x1f')](_0xe55848)['json'](_0x45014f);}};}function respondWithFilteredResult(_0x39c450,_0x33b98e){return function(_0x46a8d9){if(_0x46a8d9){var _0x8cd130=typeof _0x33b98e[_0xa3f8('0x20')]===_0xa3f8('0x21')&&typeof _0x33b98e[_0xa3f8('0x22')]===_0xa3f8('0x21');var _0x2cb49f=_0x46a8d9[_0xa3f8('0x23')];var _0x54b870=_0x8cd130?0x0:_0x33b98e[_0xa3f8('0x20')];var _0x5a0e18=_0x8cd130?_0x46a8d9[_0xa3f8('0x23')]:_0x33b98e[_0xa3f8('0x20')]+_0x33b98e[_0xa3f8('0x22')];var _0x46042d;if(_0x5a0e18>=_0x2cb49f){_0x5a0e18=_0x2cb49f;_0x46042d=0xc8;}else{_0x46042d=0xce;}_0x39c450['status'](_0x46042d);return _0x39c450[_0xa3f8('0x24')]('Content-Range',_0x54b870+'-'+_0x5a0e18+'/'+_0x2cb49f)[_0xa3f8('0x25')](_0x46a8d9);}return null;};}function patchUpdates(_0x58336d){return function(_0x4066bb){try{jsonpatch[_0xa3f8('0x26')](_0x4066bb,_0x58336d,!![]);}catch(_0x353daa){return BPromise[_0xa3f8('0x27')](_0x353daa);}return _0x4066bb[_0xa3f8('0x28')]();};}function saveUpdates(_0x1e5f30,_0x187352){return function(_0x490717){if(_0x490717){return _0x490717[_0xa3f8('0x29')](_0x1e5f30)['then'](function(_0x3ce57b){return _0x3ce57b;});}return null;};}function removeEntity(_0xa5a697,_0x24985a){return function(_0x37b290){if(_0x37b290){return _0x37b290[_0xa3f8('0x2a')]()[_0xa3f8('0x2b')](function(){var _0x6e3cb4=_0x37b290[_0xa3f8('0x2c')]({'plain':!![]});var _0x1e22b8=_0xa3f8('0x2d');return db['UserProfileResource'][_0xa3f8('0x2a')]({'where':{'type':_0x1e22b8,'resourceId':_0x6e3cb4['id']}})[_0xa3f8('0x2b')](function(){return _0x37b290;});})[_0xa3f8('0x2b')](function(){_0xa5a697['status'](0xcc)[_0xa3f8('0x2e')]();});}};}function handleEntityNotFound(_0x57f6be,_0xbad6a6){return function(_0x3a3746){if(!_0x3a3746){_0x57f6be[_0xa3f8('0x1e')](0x194);}return _0x3a3746;};}function handleError(_0x4ea213,_0x458824){_0x458824=_0x458824||0x1f4;return function(_0x5e69e2){logger[_0xa3f8('0x2f')](_0x5e69e2[_0xa3f8('0x30')]);if(_0x5e69e2[_0xa3f8('0x31')]){delete _0x5e69e2[_0xa3f8('0x31')];}_0x4ea213[_0xa3f8('0x1f')](_0x458824)[_0xa3f8('0x32')](_0x5e69e2);};}exports[_0xa3f8('0x33')]=function(_0x424a3e,_0x25f9f5){var _0x290a4e={},_0x6e83b0={},_0x57c465={'count':0x0,'rows':[]};var _0x4404da=_[_0xa3f8('0x34')](db[_0xa3f8('0x35')][_0xa3f8('0x36')],function(_0x3bb4b0){return{'name':_0x3bb4b0['fieldName'],'type':_0x3bb4b0[_0xa3f8('0x37')][_0xa3f8('0x38')]};});_0x6e83b0['model']=_[_0xa3f8('0x34')](_0x4404da,_0xa3f8('0x31'));_0x6e83b0['query']=_[_0xa3f8('0x39')](_0x424a3e['query']);_0x6e83b0['filters']=_[_0xa3f8('0x3a')](_0x6e83b0[_0xa3f8('0x3b')],_0x6e83b0['query']);_0x290a4e[_0xa3f8('0x3c')]=_['intersection'](_0x6e83b0[_0xa3f8('0x3b')],qs[_0xa3f8('0x3d')](_0x424a3e[_0xa3f8('0x3e')][_0xa3f8('0x3d')]));_0x290a4e['attributes']=_0x290a4e[_0xa3f8('0x3c')]['length']?_0x290a4e[_0xa3f8('0x3c')]:_0x6e83b0['model'];if(!_0x424a3e[_0xa3f8('0x3e')]['hasOwnProperty']('nolimit')){_0x290a4e['limit']=qs[_0xa3f8('0x22')](_0x424a3e[_0xa3f8('0x3e')][_0xa3f8('0x22')]);_0x290a4e[_0xa3f8('0x20')]=qs['offset'](_0x424a3e[_0xa3f8('0x3e')][_0xa3f8('0x20')]);}_0x290a4e[_0xa3f8('0x3f')]=qs[_0xa3f8('0x40')](_0x424a3e[_0xa3f8('0x3e')][_0xa3f8('0x40')]);_0x290a4e['where']=qs[_0xa3f8('0x41')](_[_0xa3f8('0x42')](_0x424a3e[_0xa3f8('0x3e')],_0x6e83b0['filters']),_0x4404da);if(_0x424a3e[_0xa3f8('0x3e')][_0xa3f8('0x43')]){_0x290a4e['where']=_[_0xa3f8('0x44')](_0x290a4e['where'],{'$or':_[_0xa3f8('0x34')](_0x4404da,function(_0x5a077c){if(_0x5a077c[_0xa3f8('0x37')]!==_0xa3f8('0x45')){var _0x9a00e7={};_0x9a00e7[_0x5a077c[_0xa3f8('0x31')]]={'$like':'%'+_0x424a3e[_0xa3f8('0x3e')]['filter']+'%'};return _0x9a00e7;}})});}_0x290a4e=_[_0xa3f8('0x44')]({},_0x290a4e,_0x424a3e[_0xa3f8('0x46')]);var _0x4db9c5={'where':_0x290a4e[_0xa3f8('0x47')]};return db['AnalyticDefaultReport'][_0xa3f8('0x23')](_0x4db9c5)[_0xa3f8('0x2b')](function(_0x1542cc){_0x57c465[_0xa3f8('0x23')]=_0x1542cc;if(_0x424a3e[_0xa3f8('0x3e')]['includeAll']){_0x290a4e[_0xa3f8('0x48')]=[{'all':!![]}];}return db[_0xa3f8('0x35')][_0xa3f8('0x49')](_0x290a4e);})[_0xa3f8('0x2b')](function(_0x337808){_0x57c465['rows']=_0x337808;return _0x57c465;})[_0xa3f8('0x2b')](respondWithFilteredResult(_0x25f9f5,_0x290a4e))[_0xa3f8('0x4a')](handleError(_0x25f9f5,null));};exports[_0xa3f8('0x4b')]=function(_0x32e371,_0x2a124b){var _0x314dba={'raw':!![],'where':{'id':_0x32e371[_0xa3f8('0x4c')]['id']}},_0x497217={};_0x497217[_0xa3f8('0x3b')]=_[_0xa3f8('0x39')](db[_0xa3f8('0x35')][_0xa3f8('0x36')]);_0x497217[_0xa3f8('0x3e')]=_['keys'](_0x32e371['query']);_0x497217['filters']=_[_0xa3f8('0x3a')](_0x497217[_0xa3f8('0x3b')],_0x497217[_0xa3f8('0x3e')]);_0x314dba[_0xa3f8('0x3c')]=_[_0xa3f8('0x3a')](_0x497217[_0xa3f8('0x3b')],qs['fields'](_0x32e371[_0xa3f8('0x3e')][_0xa3f8('0x3d')]));_0x314dba[_0xa3f8('0x3c')]=_0x314dba[_0xa3f8('0x3c')]['length']?_0x314dba[_0xa3f8('0x3c')]:_0x497217[_0xa3f8('0x3b')];if(_0x32e371[_0xa3f8('0x3e')]['includeAll']){_0x314dba['include']=[{'all':!![]}];}_0x314dba=_['merge']({},_0x314dba,_0x32e371[_0xa3f8('0x46')]);return db[_0xa3f8('0x35')]['find'](_0x314dba)[_0xa3f8('0x2b')](handleEntityNotFound(_0x2a124b,null))[_0xa3f8('0x2b')](respondWithResult(_0x2a124b,null))[_0xa3f8('0x4a')](handleError(_0x2a124b,null));};exports[_0xa3f8('0x4d')]=function(_0x14932f,_0x3c74b5){return db[_0xa3f8('0x35')][_0xa3f8('0x4d')](_0x14932f[_0xa3f8('0x4e')],{})[_0xa3f8('0x2b')](function(_0x338554){var _0x29d8f5=_0x14932f[_0xa3f8('0x4f')][_0xa3f8('0x2c')]({'plain':!![]});if(!_0x29d8f5)throw new Error(_0xa3f8('0x50'));if(_0x29d8f5[_0xa3f8('0x51')]===_0xa3f8('0x4f')){var _0x559ae7=_0x338554['get']({'plain':!![]});var _0x1fad80=_0xa3f8('0x52');return db['UserProfileSection'][_0xa3f8('0x53')]({'where':{'name':_0x1fad80,'userProfileId':_0x29d8f5[_0xa3f8('0x54')]},'raw':!![]})[_0xa3f8('0x2b')](function(_0xaff79b){if(_0xaff79b&&_0xaff79b[_0xa3f8('0x55')]===0x0){return db[_0xa3f8('0x56')][_0xa3f8('0x4d')]({'name':_0x559ae7[_0xa3f8('0x31')],'resourceId':_0x559ae7['id'],'type':_0xa3f8('0x2d'),'sectionId':_0xaff79b['id']},{})[_0xa3f8('0x2b')](function(){return _0x338554;});}else{return _0x338554;}})[_0xa3f8('0x4a')](function(_0x3752fa){logger[_0xa3f8('0x2f')](_0xa3f8('0x57'),_0x3752fa);throw _0x3752fa;});}return _0x338554;})[_0xa3f8('0x2b')](respondWithResult(_0x3c74b5,0xc9))[_0xa3f8('0x4a')](handleError(_0x3c74b5,null));};exports['update']=function(_0x593614,_0xd0628e){if(_0x593614['body']['id']){delete _0x593614[_0xa3f8('0x4e')]['id'];}return db[_0xa3f8('0x35')][_0xa3f8('0x53')]({'where':{'id':_0x593614['params']['id']}})[_0xa3f8('0x2b')](handleEntityNotFound(_0xd0628e,null))[_0xa3f8('0x2b')](saveUpdates(_0x593614[_0xa3f8('0x4e')],null))[_0xa3f8('0x2b')](respondWithResult(_0xd0628e,null))['catch'](handleError(_0xd0628e,null));};exports[_0xa3f8('0x2a')]=function(_0x47cc0c,_0x392e1e){return db[_0xa3f8('0x35')][_0xa3f8('0x53')]({'where':{'id':_0x47cc0c['params']['id']}})['then'](handleEntityNotFound(_0x392e1e,null))[_0xa3f8('0x2b')](removeEntity(_0x392e1e,null))[_0xa3f8('0x4a')](handleError(_0x392e1e,null));};exports[_0xa3f8('0x58')]=function(_0x6ad40a,_0x48f5a6){var _0x36eac9=0xa;var _0x3478e8=[_0xa3f8('0x59'),_0xa3f8('0x5a'),_0xa3f8('0x5b'),'cross_join'];var _0x5d7877={'SUM':_0xa3f8('0x5c'),'COUNT':_0xa3f8('0x5d'),'COUNT DISTINCT':_0xa3f8('0x5e'),'MAX':_0xa3f8('0x5f'),'MIN':_0xa3f8('0x60'),'AVG':_0xa3f8('0x61'),'GROUP_CONCAT':_0xa3f8('0x62'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x521719={'SEC_TO_TIME':_0xa3f8('0x63'),'DATE':_0xa3f8('0x64'),'HOUR':_0xa3f8('0x65'),'ROUND':_0xa3f8('0x66'),'UNIX_TIMESTAMP':_0xa3f8('0x67')};var _0x27de61=function(_0x356643){return!_[_0xa3f8('0x68')](['IS\x20NULL',_0xa3f8('0x69'),_0xa3f8('0x6a'),_0xa3f8('0x6b')],_0x356643);};var _0x42e3f8=function(_0x27c5aa){if(!_0x27c5aa||!_0x27c5aa[_0xa3f8('0x6c')][_0xa3f8('0x6d')]){return'';}for(var _0x4d0404='(',_0x33ea06=0x0;_0x33ea06<_0x27c5aa[_0xa3f8('0x6c')]['length'];_0x33ea06+=0x1){_0x33ea06>0x0&&(_0x4d0404+='\x20'+_0x27c5aa[_0xa3f8('0x6e')]+'\x20');_0x4d0404+=_0x27c5aa[_0xa3f8('0x6c')][_0x33ea06][_0xa3f8('0x6f')]?_0x42e3f8(_0x27c5aa[_0xa3f8('0x6c')][_0x33ea06][_0xa3f8('0x6f')]):_0x27c5aa[_0xa3f8('0x6c')][_0x33ea06][_0xa3f8('0x70')]+'\x20'+_0x27c5aa['rules'][_0x33ea06]['condition']+(_0x27de61(_0x27c5aa[_0xa3f8('0x6c')][_0x33ea06]['condition'])?'\x20'+_0x27c5aa[_0xa3f8('0x6c')][_0x33ea06][_0xa3f8('0x71')]:'');}return _0x4d0404+')';};var _0x3ff369={'where':{'id':_0x6ad40a[_0xa3f8('0x4c')]['id']}},_0x1dba7e,_0x452e99,_0x35d4d6,_0xeca2dc,_0x14508d;_0x3ff369=_[_0xa3f8('0x44')]({},_0x3ff369,_0x6ad40a[_0xa3f8('0x46')]);return db[_0xa3f8('0x35')][_0xa3f8('0x53')](_0x3ff369)['then'](function(_0x5efdcf){if(_0x5efdcf){_0x1dba7e=_0x5efdcf;return _0x5efdcf[_0xa3f8('0x72')]();}return null;})[_0xa3f8('0x2b')](function(_0x1688ca){if(_0x1688ca){if(!_0x1688ca[_0xa3f8('0x6d')]){throw new db[(_0xa3f8('0x73'))]['ValidationErrorItem'](_0xa3f8('0x74'),0x193);}_0x452e99=_0x1688ca;return db[_0xa3f8('0x75')][_0xa3f8('0x49')]({'raw':!![]});}return null;})[_0xa3f8('0x2b')](function(_0x28d359){if(_0x28d359){_0x35d4d6=_[_0xa3f8('0x76')](_0x28d359,'id');var _0x3d45ae;var _0x3a2362=squel[_0xa3f8('0x77')]();_0x3a2362[_0xa3f8('0x78')](_0x1dba7e[_0xa3f8('0x79')]);for(var _0x5d4fe5=0x0;_0x5d4fe5<_0x452e99[_0xa3f8('0x6d')];_0x5d4fe5+=0x1){_0x3d45ae=_0x452e99[_0x5d4fe5][_0xa3f8('0x7a')]?_0x35d4d6[_0x452e99[_0x5d4fe5]['MetricId']]['metric']:_0x452e99[_0x5d4fe5][_0xa3f8('0x70')];_0x3d45ae=_0x452e99[_0x5d4fe5][_0xa3f8('0x7b')]?_[_0xa3f8('0x7c')](_0x5d7877[_0x452e99[_0x5d4fe5][_0xa3f8('0x7b')]],'%s',_0x3d45ae):_0x3d45ae;_0x3d45ae=_0x452e99[_0x5d4fe5][_0xa3f8('0x7d')]?_[_0xa3f8('0x7c')](_0x521719[_0x452e99[_0x5d4fe5][_0xa3f8('0x7d')]],'%s',_0x3d45ae):_0x3d45ae;if(_0x452e99[_0x5d4fe5][_0xa3f8('0x7e')]){_0x3a2362['group'](_0x3d45ae);}_0x452e99[_0x5d4fe5][_0xa3f8('0x7f')]&&_0x3a2362[_0xa3f8('0x3f')](_0x3d45ae,_0x452e99[_0x5d4fe5][_0xa3f8('0x7f')]==='DESC'?![]:!![]);_0x3a2362[_0xa3f8('0x70')](_0x3d45ae,_0x452e99[_0x5d4fe5][_0xa3f8('0x80')]||_0x3d45ae);}if(_0x1dba7e['joins']){_0x1dba7e[_0xa3f8('0x81')]=JSON[_0xa3f8('0x82')](_0x1dba7e[_0xa3f8('0x81')]);for(var _0x14a5b5=0x0;_0x14a5b5<_0x1dba7e[_0xa3f8('0x81')][_0xa3f8('0x6d')];_0x14a5b5+=0x1){if(_0x1dba7e[_0xa3f8('0x81')][_0x14a5b5][_0xa3f8('0x37')]&&_[_0xa3f8('0x68')](_0x3478e8,_0x1dba7e['joins'][_0x14a5b5][_0xa3f8('0x37')])&&_0x1dba7e['joins'][_0x14a5b5][_0xa3f8('0x83')]&&_0x1dba7e['joins'][_0x14a5b5][_0xa3f8('0x84')]&&_0x1dba7e[_0xa3f8('0x81')][_0x14a5b5][_0xa3f8('0x85')]){_0x3a2362[_0x1dba7e[_0xa3f8('0x81')][_0x14a5b5][_0xa3f8('0x37')]](_0x1dba7e['joins'][_0x14a5b5][_0xa3f8('0x84')],null,util[_0xa3f8('0x7d')]('%s.%s\x20=\x20%s.%s',_0x1dba7e[_0xa3f8('0x79')],_0x1dba7e[_0xa3f8('0x81')][_0x14a5b5][_0xa3f8('0x83')],_0x1dba7e[_0xa3f8('0x81')][_0x14a5b5][_0xa3f8('0x84')],_0x1dba7e[_0xa3f8('0x81')][_0x14a5b5]['foreignKey']));}}}if(_0x1dba7e[_0xa3f8('0x86')]){_0x1dba7e[_0xa3f8('0x86')]=JSON[_0xa3f8('0x82')](_0x1dba7e['conditions']);_0x3a2362[_0xa3f8('0x47')](_0x42e3f8(_0x1dba7e['conditions'][_0xa3f8('0x6f')]));}_0x14508d=_0x3a2362['clone']();_0x3a2362['limit'](_0x36eac9);_0x3a2362[_0xa3f8('0x20')](0x0);logger['debug'](_0xa3f8('0x87'),_0x3a2362['toString']());return dbH[_0xa3f8('0x88')][_0xa3f8('0x3e')](_0x3a2362[_0xa3f8('0x89')](),{'type':dbH[_0xa3f8('0x88')]['QueryTypes'][_0xa3f8('0x8a')]});}})[_0xa3f8('0x2b')](respondWithResult(_0x48f5a6,null))['catch'](handleError(_0x48f5a6,null));};function runReport(_0x3187e0,_0xd0d568,_0x3715ea){var _0x345089=_0xd0d568[_0xa3f8('0x31')];var _0x20ae51=0xa;var _0x190ce8=[_0xa3f8('0x59'),_0xa3f8('0x5a'),_0xa3f8('0x5b'),'cross_join'];var _0x7dc5ec={'SUM':_0xa3f8('0x5c'),'COUNT':_0xa3f8('0x5d'),'COUNT DISTINCT':_0xa3f8('0x5e'),'MAX':_0xa3f8('0x5f'),'MIN':_0xa3f8('0x60'),'AVG':_0xa3f8('0x61'),'GROUP_CONCAT':_0xa3f8('0x62'),'GROUP_CONCAT ASC':_0xa3f8('0x8b'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x2e2d99={'SEC_TO_TIME':_0xa3f8('0x63'),'DATE':_0xa3f8('0x64'),'HOUR':_0xa3f8('0x65'),'ROUND':_0xa3f8('0x66'),'UNIX_TIMESTAMP':_0xa3f8('0x67')};var _0x599484=function(_0x24fe62){return!_[_0xa3f8('0x68')]([_0xa3f8('0x8c'),_0xa3f8('0x69'),'IS\x20EMPTY',_0xa3f8('0x6b')],_0x24fe62);};var _0x427830=function(_0x3c5091){if(!_0x3c5091||!_0x3c5091[_0xa3f8('0x6c')][_0xa3f8('0x6d')]){return'';}for(var _0x2db7dd='(',_0x12fe03=0x0;_0x12fe03<_0x3c5091[_0xa3f8('0x6c')][_0xa3f8('0x6d')];_0x12fe03+=0x1){_0x12fe03>0x0&&(_0x2db7dd+='\x20'+_0x3c5091[_0xa3f8('0x6e')]+'\x20');_0x2db7dd+=_0x3c5091[_0xa3f8('0x6c')][_0x12fe03]['group']?_0x427830(_0x3c5091[_0xa3f8('0x6c')][_0x12fe03]['group']):_0x3c5091[_0xa3f8('0x6c')][_0x12fe03][_0xa3f8('0x70')]+'\x20'+_0x3c5091[_0xa3f8('0x6c')][_0x12fe03][_0xa3f8('0x8d')]+(_0x599484(_0x3c5091[_0xa3f8('0x6c')][_0x12fe03][_0xa3f8('0x8d')])?'\x20'+_0x3c5091[_0xa3f8('0x6c')][_0x12fe03][_0xa3f8('0x71')]:'');}return _0x2db7dd+')';};var _0x4bb7dd={'where':{'id':_0x3187e0['id']}},_0x2c6efe,_0x4f9513,_0x39bd5c,_0x52fcc3,_0x2d2883;_0x4bb7dd=_['merge']({},_0x4bb7dd,_0x3715ea);return db[_0xa3f8('0x35')][_0xa3f8('0x53')](_0x4bb7dd)[_0xa3f8('0x2b')](function(_0xe3cc6a){if(_0xe3cc6a){_0x2c6efe=_0xe3cc6a;return _0xe3cc6a['getFields']();}return null;})[_0xa3f8('0x2b')](function(_0x3d343f){if(_0x3d343f){if(!_0x3d343f[_0xa3f8('0x6d')]){throw new db[(_0xa3f8('0x73'))][(_0xa3f8('0x8e'))](_0xa3f8('0x74'),0x193);}_0x4f9513=_0x3d343f;return db['AnalyticMetric'][_0xa3f8('0x49')]({'raw':!![]});}return null;})[_0xa3f8('0x2b')](function(_0xbe1a54){if(_0xbe1a54){_0x39bd5c=_[_0xa3f8('0x76')](_0xbe1a54,'id');var _0x477b0a;var _0x565a10=squel[_0xa3f8('0x77')]();_0x565a10[_0xa3f8('0x78')](_0x2c6efe['table']);for(var _0x4494a5=0x0;_0x4494a5<_0x4f9513[_0xa3f8('0x6d')];_0x4494a5+=0x1){_0x477b0a=_0x4f9513[_0x4494a5][_0xa3f8('0x7a')]?_0x39bd5c[_0x4f9513[_0x4494a5]['MetricId']][_0xa3f8('0x8f')]:_0x4f9513[_0x4494a5][_0xa3f8('0x70')];_0x477b0a=_0x4f9513[_0x4494a5][_0xa3f8('0x7b')]?_[_0xa3f8('0x7c')](_0x7dc5ec[_0x4f9513[_0x4494a5][_0xa3f8('0x7b')]],'%s',_0x477b0a):_0x477b0a;_0x477b0a=_0x4f9513[_0x4494a5][_0xa3f8('0x7d')]?_[_0xa3f8('0x7c')](_0x2e2d99[_0x4f9513[_0x4494a5]['format']],'%s',_0x477b0a):_0x477b0a;if(_0x4f9513[_0x4494a5][_0xa3f8('0x7e')]){_0x565a10[_0xa3f8('0x6f')](_0x477b0a);}_0x4f9513[_0x4494a5]['orderBy']&&_0x565a10[_0xa3f8('0x3f')](_0x477b0a,_0x4f9513[_0x4494a5][_0xa3f8('0x7f')]===_0xa3f8('0x90')?![]:!![]);_0x565a10[_0xa3f8('0x70')](_0x477b0a,_0x4f9513[_0x4494a5][_0xa3f8('0x80')]||_0x477b0a);}if(_0x2c6efe[_0xa3f8('0x81')]){_0x2c6efe[_0xa3f8('0x81')]=JSON['parse'](_0x2c6efe[_0xa3f8('0x81')]);for(var _0x151bab=0x0;_0x151bab<_0x2c6efe[_0xa3f8('0x81')][_0xa3f8('0x6d')];_0x151bab+=0x1){if(_0x2c6efe[_0xa3f8('0x81')][_0x151bab][_0xa3f8('0x37')]&&_[_0xa3f8('0x68')](_0x190ce8,_0x2c6efe['joins'][_0x151bab][_0xa3f8('0x37')])&&_0x2c6efe[_0xa3f8('0x81')][_0x151bab][_0xa3f8('0x83')]&&_0x2c6efe[_0xa3f8('0x81')][_0x151bab]['foreignTable']&&_0x2c6efe['joins'][_0x151bab][_0xa3f8('0x85')]){_0x565a10[_0x2c6efe['joins'][_0x151bab][_0xa3f8('0x37')]](_0x2c6efe[_0xa3f8('0x81')][_0x151bab][_0xa3f8('0x84')],null,util['format']('%s.%s\x20=\x20%s.%s',_0x2c6efe[_0xa3f8('0x79')],_0x2c6efe[_0xa3f8('0x81')][_0x151bab][_0xa3f8('0x83')],_0x2c6efe[_0xa3f8('0x81')][_0x151bab]['foreignTable'],_0x2c6efe[_0xa3f8('0x81')][_0x151bab]['foreignKey']));}}}if(_0x2c6efe[_0xa3f8('0x86')]){_0x2c6efe[_0xa3f8('0x86')]=JSON[_0xa3f8('0x82')](_0x2c6efe['conditions']);_0x565a10['where'](_0x427830(_0x2c6efe['conditions'][_0xa3f8('0x6f')]));}_0x2d2883=_0x565a10[_0xa3f8('0x91')]();_0x565a10[_0xa3f8('0x22')](_0x20ae51);_0x565a10[_0xa3f8('0x20')](0x0);return;}})[_0xa3f8('0x2b')](function(){if(_0xd0d568[_0xa3f8('0x92')]===_0xa3f8('0x93')){return null;}var _0x18890e=_['merge'](_0xd0d568,{'name':_0xd0d568[_0xa3f8('0x94')]||_0xd0d568[_0xa3f8('0x31')]||_0x2c6efe[_0xa3f8('0x31')],'basename':_0x345089,'savename':util['format'](_0xa3f8('0x95'),_0xd0d568[_0xa3f8('0x31')]||_0x2c6efe['name'],require(_0xa3f8('0x96'))[_0xa3f8('0x97')](0x4),_0xd0d568['output']||_0xa3f8('0x98')),'reportId':_0x2c6efe['id'],'reportType':_0xa3f8('0x99')});return db['AnalyticExtractedReport'][_0xa3f8('0x4d')](_0x18890e,{'raw':!![]});})[_0xa3f8('0x2b')](function(_0x21cc1d){if(_0x2c6efe['table']===_0xa3f8('0x9a')){_0x2d2883[_0xa3f8('0x47')](_0x2c6efe[_0xa3f8('0x79')]+_0xa3f8('0x9b'),_0xd0d568[_0xa3f8('0x9c')],_0xd0d568['endDate']);}else{_0x2d2883['where'](_0x2c6efe[_0xa3f8('0x79')]+_0xa3f8('0x9d'),_0xd0d568[_0xa3f8('0x9c')],_0xd0d568[_0xa3f8('0x9e')]);}if(_0x21cc1d){logger['info'](_0xa3f8('0x9f'),_0x2d2883[_0xa3f8('0x89')]());require(_0xa3f8('0xa0'))[_0xa3f8('0xa1')](path[_0xa3f8('0x59')](__dirname,_0xa3f8('0xa2'),_0x21cc1d[_0xa3f8('0x92')]),[_0x21cc1d['id'],_0x2d2883[_0xa3f8('0x89')](),path['join'](__dirname,_0xa3f8('0xa3'),_0x21cc1d['savename']),_0x345089]);return _0x21cc1d;}else{var _0xe9842=squel['select']();_0xe9842['from']('('+_0x2d2883[_0xa3f8('0x89')]()+')',_0xa3f8('0xa4'));_0xe9842[_0xa3f8('0x70')](_0xa3f8('0xa5'),_0xa3f8('0x23'));_0x2d2883['limit'](_0xd0d568['limit']||_0x20ae51);_0x2d2883[_0xa3f8('0x20')](_0xd0d568[_0xa3f8('0x20')]||0x0);return dbH[_0xa3f8('0x88')][_0xa3f8('0x3e')](_0xe9842[_0xa3f8('0x89')](),{'type':dbH[_0xa3f8('0x88')]['QueryTypes'][_0xa3f8('0x8a')]})[_0xa3f8('0x2b')](function(_0x5a4f4a){if(!_0x5a4f4a['length']){_0x52fcc3=0x0;}else{_0x52fcc3=_0x5a4f4a[0x0][_0xa3f8('0x23')]||0x0;}return dbH[_0xa3f8('0x88')]['query'](_0x2d2883[_0xa3f8('0x89')](),{'type':dbH[_0xa3f8('0x88')][_0xa3f8('0xa6')][_0xa3f8('0x8a')]});})[_0xa3f8('0x2b')](function(_0x52f592){return{'rows':_0x52f592||[],'count':_0x52fcc3};});}});}exports[_0xa3f8('0xa7')]=function(_0x59026b,_0x234636){return runReport(_0x59026b[_0xa3f8('0x4c')],_0x59026b['query'],_0x59026b['options'])[_0xa3f8('0x2b')](respondWithResult(_0x234636,null))[_0xa3f8('0x4a')](handleError(_0x234636,null));};exports[_0xa3f8('0xa8')]=runReport;exports[_0xa3f8('0x3e')]=function(_0x26ec07,_0x2c9db8){var _0x18ab67=0xa;var _0x1f21a2=[_0xa3f8('0x59'),_0xa3f8('0x5a'),_0xa3f8('0x5b'),'cross_join'];var _0x15a11c={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':_0xa3f8('0x5e'),'MAX':_0xa3f8('0x5f'),'MIN':_0xa3f8('0x60'),'AVG':_0xa3f8('0x61'),'GROUP_CONCAT':_0xa3f8('0x62'),'GROUP_CONCAT ASC':_0xa3f8('0x8b'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x481b70={'SEC_TO_TIME':_0xa3f8('0x63'),'DATE':_0xa3f8('0x64'),'HOUR':_0xa3f8('0x65'),'ROUND':_0xa3f8('0x66'),'UNIX_TIMESTAMP':_0xa3f8('0x67')};var _0x1f776a=function(_0x5b1527){return!_['includes']([_0xa3f8('0x8c'),_0xa3f8('0x69'),_0xa3f8('0x6a'),_0xa3f8('0x6b')],_0x5b1527);};var _0x4670cc=function(_0xfde509){if(!_0xfde509||!_0xfde509['rules']['length']){return'';}for(var _0x3d81fe='(',_0x15111a=0x0;_0x15111a<_0xfde509[_0xa3f8('0x6c')]['length'];_0x15111a+=0x1){_0x15111a>0x0&&(_0x3d81fe+='\x20'+_0xfde509[_0xa3f8('0x6e')]+'\x20');_0x3d81fe+=_0xfde509[_0xa3f8('0x6c')][_0x15111a]['group']?_0x4670cc(_0xfde509[_0xa3f8('0x6c')][_0x15111a]['group']):_0xfde509[_0xa3f8('0x6c')][_0x15111a]['field']+'\x20'+_0xfde509['rules'][_0x15111a][_0xa3f8('0x8d')]+(_0x1f776a(_0xfde509[_0xa3f8('0x6c')][_0x15111a][_0xa3f8('0x8d')])?'\x20'+_0xfde509[_0xa3f8('0x6c')][_0x15111a]['value']:'');}return _0x3d81fe+')';};var _0x2e694e={'where':{'id':_0x26ec07[_0xa3f8('0x4c')]['id']}},_0x1669be,_0x4f248f,_0x6ef1ad,_0xae3a31,_0x31d45c;_0x2e694e=_[_0xa3f8('0x44')]({},_0x2e694e,_0x26ec07[_0xa3f8('0x46')]);return db[_0xa3f8('0x35')][_0xa3f8('0x53')](_0x2e694e)[_0xa3f8('0x2b')](function(_0x529021){if(_0x529021){_0x1669be=_0x529021;return _0x529021[_0xa3f8('0x72')]();}return null;})[_0xa3f8('0x2b')](function(_0x35c498){if(_0x35c498){if(!_0x35c498[_0xa3f8('0x6d')]){throw new db[(_0xa3f8('0x73'))][(_0xa3f8('0x8e'))](_0xa3f8('0x74'),0x193);}_0x4f248f=_0x35c498;return db[_0xa3f8('0x75')]['findAll']({'raw':!![]});}return null;})[_0xa3f8('0x2b')](function(_0x286490){if(_0x286490){_0x6ef1ad=_['keyBy'](_0x286490,'id');var _0x16e98d;var _0x3be5c9=squel['select']();_0x3be5c9[_0xa3f8('0x78')](_0x1669be[_0xa3f8('0x79')]);for(var _0x5260e0=0x0;_0x5260e0<_0x4f248f[_0xa3f8('0x6d')];_0x5260e0+=0x1){_0x16e98d=_0x4f248f[_0x5260e0][_0xa3f8('0x7a')]?_0x6ef1ad[_0x4f248f[_0x5260e0]['MetricId']][_0xa3f8('0x8f')]:_0x4f248f[_0x5260e0][_0xa3f8('0x70')];_0x16e98d=_0x4f248f[_0x5260e0]['function']?_['replace'](_0x15a11c[_0x4f248f[_0x5260e0][_0xa3f8('0x7b')]],'%s',_0x16e98d):_0x16e98d;_0x16e98d=_0x4f248f[_0x5260e0][_0xa3f8('0x7d')]?_[_0xa3f8('0x7c')](_0x481b70[_0x4f248f[_0x5260e0]['format']],'%s',_0x16e98d):_0x16e98d;if(_0x4f248f[_0x5260e0]['groupBy']){_0x3be5c9[_0xa3f8('0x6f')](_0x16e98d);}_0x4f248f[_0x5260e0][_0xa3f8('0x7f')]&&_0x3be5c9['order'](_0x16e98d,_0x4f248f[_0x5260e0][_0xa3f8('0x7f')]==='DESC'?![]:!![]);_0x3be5c9[_0xa3f8('0x70')](_0x16e98d,_0x4f248f[_0x5260e0]['alias']||_0x16e98d);}if(_0x1669be[_0xa3f8('0x81')]){_0x1669be['joins']=JSON['parse'](_0x1669be[_0xa3f8('0x81')]);for(var _0x5ac693=0x0;_0x5ac693<_0x1669be[_0xa3f8('0x81')][_0xa3f8('0x6d')];_0x5ac693+=0x1){if(_0x1669be[_0xa3f8('0x81')][_0x5ac693][_0xa3f8('0x37')]&&_[_0xa3f8('0x68')](_0x1f21a2,_0x1669be[_0xa3f8('0x81')][_0x5ac693][_0xa3f8('0x37')])&&_0x1669be[_0xa3f8('0x81')][_0x5ac693][_0xa3f8('0x83')]&&_0x1669be['joins'][_0x5ac693][_0xa3f8('0x84')]&&_0x1669be[_0xa3f8('0x81')][_0x5ac693][_0xa3f8('0x85')]){_0x3be5c9[_0x1669be[_0xa3f8('0x81')][_0x5ac693][_0xa3f8('0x37')]](_0x1669be[_0xa3f8('0x81')][_0x5ac693][_0xa3f8('0x84')],null,util[_0xa3f8('0x7d')](_0xa3f8('0xa9'),_0x1669be[_0xa3f8('0x79')],_0x1669be[_0xa3f8('0x81')][_0x5ac693][_0xa3f8('0x83')],_0x1669be[_0xa3f8('0x81')][_0x5ac693]['foreignTable'],_0x1669be[_0xa3f8('0x81')][_0x5ac693][_0xa3f8('0x85')]));}}}if(_0x1669be[_0xa3f8('0x86')]){_0x1669be[_0xa3f8('0x86')]=JSON[_0xa3f8('0x82')](_0x1669be[_0xa3f8('0x86')]);_0x3be5c9['where'](_0x4670cc(_0x1669be[_0xa3f8('0x86')][_0xa3f8('0x6f')]));}_0x31d45c=_0x3be5c9[_0xa3f8('0x91')]();_0x3be5c9[_0xa3f8('0x22')](_0x18ab67);_0x3be5c9[_0xa3f8('0x20')](0x0);logger[_0xa3f8('0xaa')](_0xa3f8('0x87'),_0x3be5c9[_0xa3f8('0x89')]());return dbH[_0xa3f8('0x88')][_0xa3f8('0x3e')](_0x3be5c9[_0xa3f8('0x89')](),{'type':dbH[_0xa3f8('0x88')][_0xa3f8('0xa6')][_0xa3f8('0x8a')]});}})[_0xa3f8('0x2b')](function(){return{'sql':_0x31d45c[_0xa3f8('0x89')]()};})[_0xa3f8('0x2b')](respondWithResult(_0x2c9db8,null))[_0xa3f8('0x4a')](handleError(_0x2c9db8,null));};
\ No newline at end of file