Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 2761b59..dcacbdb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x60bf=['Limited\x20Query:','toString','sequelize','QueryTypes','AVG(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','debug','output','fullPath','%s-%s.%s','randomstring','default','AnalyticExtractedReport','cdr','startDate','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','SELECT','runReport','MIN(%s)','getFields','Please\x20insert\x20at\x20least\x20one\x20field','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','dbH','sendStatus','status','end','json','count','offset','limit','set','apply','reject','save','update','then','get','UserProfileResource','destroy','error','stack','name','send','index','map','AnalyticDefaultReport','fieldName','key','model','query','keys','filters','intersection','attributes','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','rows','catch','params','rawAttributes','fields','create','user','Reports','find','autoAssociation','DefaultReports','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','preview','join','left_join','right_join','cross_join','SUM(%s)','COUNT(%s)','MAX(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','field','condition','value','Sequelize','ValidationErrorItem','AnalyticMetric','findAll','keyBy','select','from','table','MetricId','metric','function','replace','format','groupBy','group','orderBy','order','DESC','alias','joins','parse','parentKey','foreignTable','%s.%s\x20=\x20%s.%s','foreignKey','conditions','clone'];(function(_0x2dbce7,_0x57cb8d){var _0x3a3ed0=function(_0x28c8c6){while(--_0x28c8c6){_0x2dbce7['push'](_0x2dbce7['shift']());}};_0x3a3ed0(++_0x57cb8d);}(_0x60bf,0x165));var _0xf60b=function(_0x173441,_0x26b0d9){_0x173441=_0x173441-0x0;var _0x2423a8=_0x60bf[_0x173441];return _0x2423a8;};'use strict';var pdf=require(_0xf60b('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xf60b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf60b('0x2'));var rp=require(_0xf60b('0x3'));var moment=require(_0xf60b('0x4'));var BPromise=require(_0xf60b('0x5'));var Mustache=require(_0xf60b('0x6'));var util=require(_0xf60b('0x7'));var path=require(_0xf60b('0x8'));var sox=require('sox');var csv=require(_0xf60b('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf60b('0xa'));var squel=require(_0xf60b('0xb'));var crypto=require('crypto');var jsforce=require(_0xf60b('0xc'));var deskjs=require(_0xf60b('0xd'));var toCsv=require(_0xf60b('0x9'));var querystring=require(_0xf60b('0xe'));var Papa=require(_0xf60b('0xf'));var Redis=require('ioredis');var authService=require(_0xf60b('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xf60b('0x11'));var hardwareService=require(_0xf60b('0x12'));var logger=require(_0xf60b('0x13'))(_0xf60b('0x14'));var utils=require('../../config/utils');var config=require(_0xf60b('0x15'));var db=require('../../mysqldb')['db'];var dbH=require(_0xf60b('0x16'))[_0xf60b('0x17')];function respondWithStatusCode(_0x147a93,_0x34698b){_0x34698b=_0x34698b||0xcc;return function(_0x2a276c){if(_0x2a276c){return _0x147a93[_0xf60b('0x18')](_0x34698b);}return _0x147a93[_0xf60b('0x19')](_0x34698b)[_0xf60b('0x1a')]();};}function respondWithResult(_0x1b7aeb,_0x2af102){_0x2af102=_0x2af102||0xc8;return function(_0x337909){if(_0x337909){return _0x1b7aeb['status'](_0x2af102)[_0xf60b('0x1b')](_0x337909);}};}function respondWithFilteredResult(_0x14dcf7,_0x4a8cef){return function(_0x2e7f22){if(_0x2e7f22){var _0x3d1f09=_0x2e7f22[_0xf60b('0x1c')],_0x4c4933=_0x4a8cef[_0xf60b('0x1d')],_0x560c85=_0x4a8cef[_0xf60b('0x1d')]+_0x4a8cef[_0xf60b('0x1e')],_0x5c8e5a;if(_0x560c85>=_0x3d1f09){_0x560c85=_0x3d1f09;_0x5c8e5a=0xc8;}else{_0x5c8e5a=0xce;}_0x14dcf7[_0xf60b('0x19')](_0x5c8e5a);return _0x14dcf7[_0xf60b('0x1f')]('Content-Range',_0x4c4933+'-'+_0x560c85+'/'+_0x3d1f09)[_0xf60b('0x1b')](_0x2e7f22);}return null;};}function patchUpdates(_0x4fede1){return function(_0x15e890){try{jsonpatch[_0xf60b('0x20')](_0x15e890,_0x4fede1,!![]);}catch(_0x3e5793){return BPromise[_0xf60b('0x21')](_0x3e5793);}return _0x15e890[_0xf60b('0x22')]();};}function saveUpdates(_0x3af5b9,_0x1d30ff){return function(_0x4be0b1){if(_0x4be0b1){return _0x4be0b1[_0xf60b('0x23')](_0x3af5b9)[_0xf60b('0x24')](function(_0x122c04){return _0x122c04;});}return null;};}function removeEntity(_0x17dc7e,_0x1cf454){return function(_0x9bdba5){if(_0x9bdba5){return _0x9bdba5['destroy']()['then'](function(){var _0xa162cd=_0x9bdba5[_0xf60b('0x25')]({'plain':!![]});var _0x34aec7='DefaultReports';return db[_0xf60b('0x26')][_0xf60b('0x27')]({'where':{'type':_0x34aec7,'resourceId':_0xa162cd['id']}})[_0xf60b('0x24')](function(){return _0x9bdba5;});})[_0xf60b('0x24')](function(){_0x17dc7e[_0xf60b('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5b070d,_0x5baef8){return function(_0x1b72e5){if(!_0x1b72e5){_0x5b070d[_0xf60b('0x18')](0x194);}return _0x1b72e5;};}function handleError(_0x1d5ebc,_0x314725){_0x314725=_0x314725||0x1f4;return function(_0x2aec77){logger[_0xf60b('0x28')](_0x2aec77[_0xf60b('0x29')]);if(_0x2aec77[_0xf60b('0x2a')]){delete _0x2aec77[_0xf60b('0x2a')];}_0x1d5ebc[_0xf60b('0x19')](_0x314725)[_0xf60b('0x2b')](_0x2aec77);};}exports[_0xf60b('0x2c')]=function(_0x7285ce,_0x300a53){var _0xeccb29={},_0x71f183={},_0x5e1e8d={'count':0x0,'rows':[]};var _0x504194=_[_0xf60b('0x2d')](db[_0xf60b('0x2e')]['rawAttributes'],function(_0x410bb7){return{'name':_0x410bb7[_0xf60b('0x2f')],'type':_0x410bb7['type'][_0xf60b('0x30')]};});_0x71f183[_0xf60b('0x31')]=_[_0xf60b('0x2d')](_0x504194,_0xf60b('0x2a'));_0x71f183[_0xf60b('0x32')]=_[_0xf60b('0x33')](_0x7285ce[_0xf60b('0x32')]);_0x71f183[_0xf60b('0x34')]=_[_0xf60b('0x35')](_0x71f183[_0xf60b('0x31')],_0x71f183[_0xf60b('0x32')]);_0xeccb29[_0xf60b('0x36')]=_[_0xf60b('0x35')](_0x71f183[_0xf60b('0x31')],qs['fields'](_0x7285ce['query']['fields']));_0xeccb29[_0xf60b('0x36')]=_0xeccb29[_0xf60b('0x36')][_0xf60b('0x37')]?_0xeccb29['attributes']:_0x71f183[_0xf60b('0x31')];if(!_0x7285ce[_0xf60b('0x32')][_0xf60b('0x38')](_0xf60b('0x39'))){_0xeccb29['limit']=qs[_0xf60b('0x1e')](_0x7285ce[_0xf60b('0x32')]['limit']);_0xeccb29[_0xf60b('0x1d')]=qs[_0xf60b('0x1d')](_0x7285ce[_0xf60b('0x32')][_0xf60b('0x1d')]);}_0xeccb29['order']=qs[_0xf60b('0x3a')](_0x7285ce['query'][_0xf60b('0x3a')]);_0xeccb29[_0xf60b('0x3b')]=qs[_0xf60b('0x34')](_[_0xf60b('0x3c')](_0x7285ce[_0xf60b('0x32')],_0x71f183[_0xf60b('0x34')]),_0x504194);if(_0x7285ce['query'][_0xf60b('0x3d')]){_0xeccb29['where']=_[_0xf60b('0x3e')](_0xeccb29[_0xf60b('0x3b')],{'$or':_[_0xf60b('0x2d')](_0x504194,function(_0x24bd31){if(_0x24bd31[_0xf60b('0x3f')]!==_0xf60b('0x40')){var _0x54e9a4={};_0x54e9a4[_0x24bd31[_0xf60b('0x2a')]]={'$like':'%'+_0x7285ce[_0xf60b('0x32')]['filter']+'%'};return _0x54e9a4;}})});}_0xeccb29=_['merge']({},_0xeccb29,_0x7285ce[_0xf60b('0x41')]);var _0x2fda88={'where':_0xeccb29[_0xf60b('0x3b')]};return db[_0xf60b('0x2e')]['count'](_0x2fda88)[_0xf60b('0x24')](function(_0x541384){_0x5e1e8d[_0xf60b('0x1c')]=_0x541384;if(_0x7285ce[_0xf60b('0x32')][_0xf60b('0x42')]){_0xeccb29['include']=[{'all':!![]}];}return db['AnalyticDefaultReport']['findAll'](_0xeccb29);})[_0xf60b('0x24')](function(_0x5d0fba){_0x5e1e8d[_0xf60b('0x43')]=_0x5d0fba;return _0x5e1e8d;})['then'](respondWithFilteredResult(_0x300a53,_0xeccb29))[_0xf60b('0x44')](handleError(_0x300a53,null));};exports['show']=function(_0x43f989,_0x569814){var _0x1e3d42={'raw':!![],'where':{'id':_0x43f989[_0xf60b('0x45')]['id']}},_0x4310da={};_0x4310da[_0xf60b('0x31')]=_[_0xf60b('0x33')](db[_0xf60b('0x2e')][_0xf60b('0x46')]);_0x4310da[_0xf60b('0x32')]=_[_0xf60b('0x33')](_0x43f989[_0xf60b('0x32')]);_0x4310da[_0xf60b('0x34')]=_[_0xf60b('0x35')](_0x4310da['model'],_0x4310da['query']);_0x1e3d42[_0xf60b('0x36')]=_['intersection'](_0x4310da[_0xf60b('0x31')],qs[_0xf60b('0x47')](_0x43f989[_0xf60b('0x32')][_0xf60b('0x47')]));_0x1e3d42['attributes']=_0x1e3d42[_0xf60b('0x36')][_0xf60b('0x37')]?_0x1e3d42[_0xf60b('0x36')]:_0x4310da['model'];if(_0x43f989[_0xf60b('0x32')][_0xf60b('0x42')]){_0x1e3d42['include']=[{'all':!![]}];}_0x1e3d42=_[_0xf60b('0x3e')]({},_0x1e3d42,_0x43f989[_0xf60b('0x41')]);return db['AnalyticDefaultReport']['find'](_0x1e3d42)[_0xf60b('0x24')](handleEntityNotFound(_0x569814,null))[_0xf60b('0x24')](respondWithResult(_0x569814,null))[_0xf60b('0x44')](handleError(_0x569814,null));};exports[_0xf60b('0x48')]=function(_0x348f71,_0x3e8f88){return db[_0xf60b('0x2e')]['create'](_0x348f71['body'],{})['then'](function(_0xaa3012){var _0x19beae=_0x348f71[_0xf60b('0x49')][_0xf60b('0x25')]({'plain':!![]});if(!_0x19beae)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x19beae['role']===_0xf60b('0x49')){var _0x2fa53a=_0xaa3012[_0xf60b('0x25')]({'plain':!![]});var _0x3d5a1e=_0xf60b('0x4a');return db['UserProfileSection'][_0xf60b('0x4b')]({'where':{'name':_0x3d5a1e,'userProfileId':_0x19beae['userProfileId']},'raw':!![]})[_0xf60b('0x24')](function(_0x3f7657){if(_0x3f7657&&_0x3f7657[_0xf60b('0x4c')]===0x0){return db[_0xf60b('0x26')][_0xf60b('0x48')]({'name':_0x2fa53a[_0xf60b('0x2a')],'resourceId':_0x2fa53a['id'],'type':_0xf60b('0x4d'),'sectionId':_0x3f7657['id']},{})['then'](function(){return _0xaa3012;});}else{return _0xaa3012;}})[_0xf60b('0x44')](function(_0x2b60dc){logger[_0xf60b('0x28')](_0xf60b('0x4e'),_0x2b60dc);throw _0x2b60dc;});}return _0xaa3012;})[_0xf60b('0x24')](respondWithResult(_0x3e8f88,0xc9))['catch'](handleError(_0x3e8f88,null));};exports['update']=function(_0xd4e6de,_0x3d40f6){if(_0xd4e6de[_0xf60b('0x4f')]['id']){delete _0xd4e6de[_0xf60b('0x4f')]['id'];}return db['AnalyticDefaultReport']['find']({'where':{'id':_0xd4e6de['params']['id']}})['then'](handleEntityNotFound(_0x3d40f6,null))['then'](saveUpdates(_0xd4e6de['body'],null))[_0xf60b('0x24')](respondWithResult(_0x3d40f6,null))[_0xf60b('0x44')](handleError(_0x3d40f6,null));};exports[_0xf60b('0x27')]=function(_0x30009a,_0x1279e5){return db[_0xf60b('0x2e')][_0xf60b('0x4b')]({'where':{'id':_0x30009a[_0xf60b('0x45')]['id']}})[_0xf60b('0x24')](handleEntityNotFound(_0x1279e5,null))[_0xf60b('0x24')](removeEntity(_0x1279e5,null))[_0xf60b('0x44')](handleError(_0x1279e5,null));};exports[_0xf60b('0x50')]=function(_0x20fee5,_0x587bf0){var _0x16bc0f=0xa;var _0x4aa885=[_0xf60b('0x51'),_0xf60b('0x52'),_0xf60b('0x53'),_0xf60b('0x54')];var _0x74ef73={'SUM':_0xf60b('0x55'),'COUNT':_0xf60b('0x56'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xf60b('0x57'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xf60b('0x58'),'GROUP_CONCAT ASC':_0xf60b('0x59'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x3521e0={'SEC_TO_TIME':_0xf60b('0x5a'),'DATE':_0xf60b('0x5b'),'HOUR':_0xf60b('0x5c'),'ROUND':_0xf60b('0x5d'),'UNIX_TIMESTAMP':_0xf60b('0x5e')};var _0x108d06=function(_0x376ed2){return!_[_0xf60b('0x5f')]([_0xf60b('0x60'),_0xf60b('0x61'),_0xf60b('0x62'),_0xf60b('0x63')],_0x376ed2);};var _0x181653=function(_0x114034){if(!_0x114034||!_0x114034['rules']['length']){return'';}for(var _0xbfe5f4='(',_0x5c405b=0x0;_0x5c405b<_0x114034[_0xf60b('0x64')]['length'];_0x5c405b+=0x1){_0x5c405b>0x0&&(_0xbfe5f4+='\x20'+_0x114034[_0xf60b('0x65')]+'\x20');_0xbfe5f4+=_0x114034['rules'][_0x5c405b]['group']?_0x181653(_0x114034[_0xf60b('0x64')][_0x5c405b]['group']):_0x114034[_0xf60b('0x64')][_0x5c405b][_0xf60b('0x66')]+'\x20'+_0x114034['rules'][_0x5c405b][_0xf60b('0x67')]+(_0x108d06(_0x114034['rules'][_0x5c405b][_0xf60b('0x67')])?'\x20'+_0x114034[_0xf60b('0x64')][_0x5c405b][_0xf60b('0x68')]:'');}return _0xbfe5f4+')';};var _0x182569={'where':{'id':_0x20fee5['params']['id']}},_0x570e0c,_0x419b6f,_0x128fef,_0x39d2a7,_0x13b3c3;_0x182569=_[_0xf60b('0x3e')]({},_0x182569,_0x20fee5[_0xf60b('0x41')]);return db[_0xf60b('0x2e')][_0xf60b('0x4b')](_0x182569)[_0xf60b('0x24')](function(_0x506a34){if(_0x506a34){_0x570e0c=_0x506a34;return _0x506a34['getFields']();}return null;})[_0xf60b('0x24')](function(_0x44a98c){if(_0x44a98c){if(!_0x44a98c[_0xf60b('0x37')]){throw new db[(_0xf60b('0x69'))][(_0xf60b('0x6a'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x419b6f=_0x44a98c;return db[_0xf60b('0x6b')][_0xf60b('0x6c')]({'raw':!![]});}return null;})[_0xf60b('0x24')](function(_0x355fd8){if(_0x355fd8){_0x128fef=_[_0xf60b('0x6d')](_0x355fd8,'id');var _0x18ca08;var _0x55e418=squel[_0xf60b('0x6e')]();_0x55e418[_0xf60b('0x6f')](_0x570e0c[_0xf60b('0x70')]);for(var _0x3b861a=0x0;_0x3b861a<_0x419b6f[_0xf60b('0x37')];_0x3b861a+=0x1){_0x18ca08=_0x419b6f[_0x3b861a][_0xf60b('0x71')]?_0x128fef[_0x419b6f[_0x3b861a][_0xf60b('0x71')]][_0xf60b('0x72')]:_0x419b6f[_0x3b861a][_0xf60b('0x66')];_0x18ca08=_0x419b6f[_0x3b861a][_0xf60b('0x73')]?_[_0xf60b('0x74')](_0x74ef73[_0x419b6f[_0x3b861a][_0xf60b('0x73')]],'%s',_0x18ca08):_0x18ca08;_0x18ca08=_0x419b6f[_0x3b861a][_0xf60b('0x75')]?_[_0xf60b('0x74')](_0x3521e0[_0x419b6f[_0x3b861a][_0xf60b('0x75')]],'%s',_0x18ca08):_0x18ca08;if(_0x419b6f[_0x3b861a][_0xf60b('0x76')]){_0x55e418[_0xf60b('0x77')](_0x18ca08);}_0x419b6f[_0x3b861a][_0xf60b('0x78')]&&_0x55e418[_0xf60b('0x79')](_0x18ca08,_0x419b6f[_0x3b861a][_0xf60b('0x78')]===_0xf60b('0x7a')?![]:!![]);_0x55e418[_0xf60b('0x66')](_0x18ca08,_0x419b6f[_0x3b861a][_0xf60b('0x7b')]||_0x18ca08);}if(_0x570e0c[_0xf60b('0x7c')]){_0x570e0c[_0xf60b('0x7c')]=JSON[_0xf60b('0x7d')](_0x570e0c[_0xf60b('0x7c')]);for(var _0x4a6dcd=0x0;_0x4a6dcd<_0x570e0c[_0xf60b('0x7c')][_0xf60b('0x37')];_0x4a6dcd+=0x1){if(_0x570e0c['joins'][_0x4a6dcd][_0xf60b('0x3f')]&&_['includes'](_0x4aa885,_0x570e0c[_0xf60b('0x7c')][_0x4a6dcd][_0xf60b('0x3f')])&&_0x570e0c['joins'][_0x4a6dcd][_0xf60b('0x7e')]&&_0x570e0c[_0xf60b('0x7c')][_0x4a6dcd][_0xf60b('0x7f')]&&_0x570e0c[_0xf60b('0x7c')][_0x4a6dcd]['foreignKey']){_0x55e418[_0x570e0c[_0xf60b('0x7c')][_0x4a6dcd][_0xf60b('0x3f')]](_0x570e0c[_0xf60b('0x7c')][_0x4a6dcd][_0xf60b('0x7f')],null,util['format'](_0xf60b('0x80'),_0x570e0c[_0xf60b('0x70')],_0x570e0c['joins'][_0x4a6dcd][_0xf60b('0x7e')],_0x570e0c['joins'][_0x4a6dcd][_0xf60b('0x7f')],_0x570e0c[_0xf60b('0x7c')][_0x4a6dcd][_0xf60b('0x81')]));}}}if(_0x570e0c[_0xf60b('0x82')]){_0x570e0c['conditions']=JSON[_0xf60b('0x7d')](_0x570e0c[_0xf60b('0x82')]);_0x55e418[_0xf60b('0x3b')](_0x181653(_0x570e0c['conditions'][_0xf60b('0x77')]));}_0x13b3c3=_0x55e418[_0xf60b('0x83')]();_0x55e418['limit'](_0x16bc0f);_0x55e418[_0xf60b('0x1d')](0x0);logger['debug'](_0xf60b('0x84'),_0x55e418[_0xf60b('0x85')]());return db[_0xf60b('0x86')][_0xf60b('0x32')](_0x55e418['toString'](),{'type':db[_0xf60b('0x86')][_0xf60b('0x87')]['SELECT']});}})[_0xf60b('0x24')](respondWithResult(_0x587bf0,null))[_0xf60b('0x44')](handleError(_0x587bf0,null));};function runReport(_0x3c9d65,_0x4385cf,_0x1d8815){var _0xfdf827=_0x4385cf[_0xf60b('0x2a')];var _0x13365f=0xa;var _0x1c994d=[_0xf60b('0x51'),_0xf60b('0x52'),_0xf60b('0x53'),'cross_join'];var _0x570dd5={'SUM':_0xf60b('0x55'),'COUNT':_0xf60b('0x56'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xf60b('0x57'),'MIN':'MIN(%s)','AVG':_0xf60b('0x88'),'GROUP_CONCAT':_0xf60b('0x58'),'GROUP_CONCAT ASC':_0xf60b('0x59'),'GROUP_CONCAT DESC':_0xf60b('0x89')};var _0x3614d5={'SEC_TO_TIME':_0xf60b('0x5a'),'DATE':_0xf60b('0x5b'),'HOUR':_0xf60b('0x5c'),'ROUND':_0xf60b('0x5d'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x40ff39=function(_0x326b0d){return!_[_0xf60b('0x5f')]([_0xf60b('0x60'),'IS\x20NOT\x20NULL','IS\x20EMPTY',_0xf60b('0x63')],_0x326b0d);};var _0x106538=function(_0x53412b){if(!_0x53412b||!_0x53412b[_0xf60b('0x64')][_0xf60b('0x37')]){return'';}for(var _0x1c5ebb='(',_0xfe61e7=0x0;_0xfe61e7<_0x53412b[_0xf60b('0x64')][_0xf60b('0x37')];_0xfe61e7+=0x1){_0xfe61e7>0x0&&(_0x1c5ebb+='\x20'+_0x53412b[_0xf60b('0x65')]+'\x20');_0x1c5ebb+=_0x53412b[_0xf60b('0x64')][_0xfe61e7]['group']?_0x106538(_0x53412b[_0xf60b('0x64')][_0xfe61e7][_0xf60b('0x77')]):_0x53412b[_0xf60b('0x64')][_0xfe61e7][_0xf60b('0x66')]+'\x20'+_0x53412b[_0xf60b('0x64')][_0xfe61e7]['condition']+(_0x40ff39(_0x53412b[_0xf60b('0x64')][_0xfe61e7][_0xf60b('0x67')])?'\x20'+_0x53412b['rules'][_0xfe61e7]['value']:'');}return _0x1c5ebb+')';};var _0x2b4cfa={'where':{'id':_0x3c9d65['id']}},_0x412253,_0x1de59e,_0x21f00b,_0x13bb75,_0x7c30c1;_0x2b4cfa=_[_0xf60b('0x3e')]({},_0x2b4cfa,_0x1d8815);return db['AnalyticDefaultReport']['find'](_0x2b4cfa)[_0xf60b('0x24')](function(_0x115a5c){if(_0x115a5c){_0x412253=_0x115a5c;return _0x115a5c['getFields']();}return null;})[_0xf60b('0x24')](function(_0x1a9e90){if(_0x1a9e90){if(!_0x1a9e90[_0xf60b('0x37')]){throw new db[(_0xf60b('0x69'))][(_0xf60b('0x6a'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x1de59e=_0x1a9e90;return db[_0xf60b('0x6b')][_0xf60b('0x6c')]({'raw':!![]});}return null;})[_0xf60b('0x24')](function(_0x5883b7){if(_0x5883b7){_0x21f00b=_[_0xf60b('0x6d')](_0x5883b7,'id');var _0x4d825f;var _0x4dc816=squel[_0xf60b('0x6e')]();_0x4dc816[_0xf60b('0x6f')](_0x412253[_0xf60b('0x70')]);for(var _0x3faecf=0x0;_0x3faecf<_0x1de59e[_0xf60b('0x37')];_0x3faecf+=0x1){_0x4d825f=_0x1de59e[_0x3faecf]['MetricId']?_0x21f00b[_0x1de59e[_0x3faecf][_0xf60b('0x71')]][_0xf60b('0x72')]:_0x1de59e[_0x3faecf][_0xf60b('0x66')];_0x4d825f=_0x1de59e[_0x3faecf][_0xf60b('0x73')]?_[_0xf60b('0x74')](_0x570dd5[_0x1de59e[_0x3faecf][_0xf60b('0x73')]],'%s',_0x4d825f):_0x4d825f;_0x4d825f=_0x1de59e[_0x3faecf][_0xf60b('0x75')]?_[_0xf60b('0x74')](_0x3614d5[_0x1de59e[_0x3faecf]['format']],'%s',_0x4d825f):_0x4d825f;if(_0x1de59e[_0x3faecf][_0xf60b('0x76')]){_0x4dc816[_0xf60b('0x77')](_0x4d825f);}_0x1de59e[_0x3faecf][_0xf60b('0x78')]&&_0x4dc816[_0xf60b('0x79')](_0x4d825f,_0x1de59e[_0x3faecf][_0xf60b('0x78')]==='DESC'?![]:!![]);_0x4dc816[_0xf60b('0x66')](_0x4d825f,_0x1de59e[_0x3faecf][_0xf60b('0x7b')]||_0x4d825f);}if(_0x412253['joins']){_0x412253[_0xf60b('0x7c')]=JSON[_0xf60b('0x7d')](_0x412253[_0xf60b('0x7c')]);for(var _0x400f31=0x0;_0x400f31<_0x412253[_0xf60b('0x7c')]['length'];_0x400f31+=0x1){if(_0x412253['joins'][_0x400f31]['type']&&_[_0xf60b('0x5f')](_0x1c994d,_0x412253['joins'][_0x400f31][_0xf60b('0x3f')])&&_0x412253['joins'][_0x400f31][_0xf60b('0x7e')]&&_0x412253[_0xf60b('0x7c')][_0x400f31]['foreignTable']&&_0x412253[_0xf60b('0x7c')][_0x400f31][_0xf60b('0x81')]){_0x4dc816[_0x412253[_0xf60b('0x7c')][_0x400f31][_0xf60b('0x3f')]](_0x412253[_0xf60b('0x7c')][_0x400f31][_0xf60b('0x7f')],null,util['format'](_0xf60b('0x80'),_0x412253[_0xf60b('0x70')],_0x412253['joins'][_0x400f31]['parentKey'],_0x412253[_0xf60b('0x7c')][_0x400f31][_0xf60b('0x7f')],_0x412253['joins'][_0x400f31]['foreignKey']));}}}if(_0x412253[_0xf60b('0x82')]){_0x412253['conditions']=JSON['parse'](_0x412253[_0xf60b('0x82')]);_0x4dc816['where'](_0x106538(_0x412253[_0xf60b('0x82')][_0xf60b('0x77')]));}_0x7c30c1=_0x4dc816[_0xf60b('0x83')]();_0x4dc816[_0xf60b('0x1e')](_0x13365f);_0x4dc816[_0xf60b('0x1d')](0x0);logger[_0xf60b('0x8a')](_0xf60b('0x84'),_0x4dc816[_0xf60b('0x85')]());return db[_0xf60b('0x86')][_0xf60b('0x32')](_0x4dc816['toString'](),{'type':db[_0xf60b('0x86')][_0xf60b('0x87')]['SELECT']});}})[_0xf60b('0x24')](function(_0x264c8c){if(!_0x264c8c['length']){throw new db[(_0xf60b('0x69'))][(_0xf60b('0x6a'))]('No\x20available\x20data',0xcc);}if(_0x4385cf[_0xf60b('0x8b')]==='web'){return null;}var _0x558ced=_[_0xf60b('0x3e')](_0x4385cf,{'name':_0x4385cf[_0xf60b('0x8c')]||_0x4385cf[_0xf60b('0x2a')]||_0x412253[_0xf60b('0x2a')],'basename':_0xfdf827,'savename':util['format'](_0xf60b('0x8d'),_0x4385cf[_0xf60b('0x2a')]||_0x412253[_0xf60b('0x2a')],require(_0xf60b('0x8e'))['generate'](0x4),_0x4385cf[_0xf60b('0x8b')]||'csv'),'reportId':_0x412253['id'],'reportType':_0xf60b('0x8f')});return db[_0xf60b('0x90')][_0xf60b('0x48')](_0x558ced,{'raw':!![]});})[_0xf60b('0x24')](function(_0x5dc9a5){if(_0x412253[_0xf60b('0x70')]===_0xf60b('0x91')){_0x7c30c1[_0xf60b('0x3b')](_0x412253[_0xf60b('0x70')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x4385cf[_0xf60b('0x92')],_0x4385cf[_0xf60b('0x93')]);}else{_0x7c30c1[_0xf60b('0x3b')](_0x412253[_0xf60b('0x70')]+_0xf60b('0x94'),_0x4385cf[_0xf60b('0x92')],_0x4385cf[_0xf60b('0x93')]);}if(_0x5dc9a5){logger[_0xf60b('0x95')](_0xf60b('0x96'),_0x7c30c1[_0xf60b('0x85')]());require(_0xf60b('0x97'))[_0xf60b('0x98')](path[_0xf60b('0x51')](__dirname,_0xf60b('0x99'),_0x5dc9a5[_0xf60b('0x8b')]),[_0x5dc9a5['id'],_0x7c30c1[_0xf60b('0x85')](),path[_0xf60b('0x51')](__dirname,_0xf60b('0x9a'),_0x5dc9a5[_0xf60b('0x9b')]),_0xfdf827]);return _0x5dc9a5;}else{var _0x382bcd=squel[_0xf60b('0x6e')]();_0x382bcd[_0xf60b('0x6f')]('('+_0x7c30c1[_0xf60b('0x85')]()+')',_0xf60b('0x9c'));_0x382bcd[_0xf60b('0x66')](_0xf60b('0x9d'),_0xf60b('0x1c'));_0x7c30c1['limit'](_0x4385cf[_0xf60b('0x1e')]||_0x13365f);_0x7c30c1[_0xf60b('0x1d')](_0x4385cf['offset']||0x0);return dbH[_0xf60b('0x86')]['query'](_0x382bcd[_0xf60b('0x85')](),{'type':dbH['sequelize'][_0xf60b('0x87')][_0xf60b('0x9e')]})[_0xf60b('0x24')](function(_0x3d1d34){if(!_0x3d1d34[_0xf60b('0x37')]){_0x13bb75=0x0;}else{_0x13bb75=_0x3d1d34[0x0]['count']||0x0;}return dbH[_0xf60b('0x86')][_0xf60b('0x32')](_0x7c30c1[_0xf60b('0x85')](),{'type':dbH['sequelize']['QueryTypes'][_0xf60b('0x9e')]});})['then'](function(_0xfb7262){return{'rows':_0xfb7262||[],'count':_0x13bb75};});}});}exports['run']=function(_0x1fd7e6,_0x207833){return runReport(_0x1fd7e6[_0xf60b('0x45')],_0x1fd7e6[_0xf60b('0x32')],_0x1fd7e6['options'])[_0xf60b('0x24')](respondWithResult(_0x207833,null))[_0xf60b('0x44')](handleError(_0x207833,null));};exports[_0xf60b('0x9f')]=runReport;exports[_0xf60b('0x32')]=function(_0x1f64d9,_0x23d9a2){var _0x55c87e=0xa;var _0x5815c4=[_0xf60b('0x51'),_0xf60b('0x52'),_0xf60b('0x53'),'cross_join'];var _0x12cc5c={'SUM':_0xf60b('0x55'),'COUNT':'COUNT(%s)','COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':'MAX(%s)','MIN':_0xf60b('0xa0'),'AVG':_0xf60b('0x88'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xf60b('0x59'),'GROUP_CONCAT DESC':_0xf60b('0x89')};var _0x30f6dc={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xf60b('0x5b'),'HOUR':_0xf60b('0x5c'),'ROUND':_0xf60b('0x5d'),'UNIX_TIMESTAMP':_0xf60b('0x5e')};var _0x156e7e=function(_0x3e7a29){return!_[_0xf60b('0x5f')]([_0xf60b('0x60'),_0xf60b('0x61'),_0xf60b('0x62'),_0xf60b('0x63')],_0x3e7a29);};var _0x10b457=function(_0x1cbaa5){if(!_0x1cbaa5||!_0x1cbaa5[_0xf60b('0x64')][_0xf60b('0x37')]){return'';}for(var _0x3fc2a5='(',_0x27b7e8=0x0;_0x27b7e8<_0x1cbaa5[_0xf60b('0x64')][_0xf60b('0x37')];_0x27b7e8+=0x1){_0x27b7e8>0x0&&(_0x3fc2a5+='\x20'+_0x1cbaa5[_0xf60b('0x65')]+'\x20');_0x3fc2a5+=_0x1cbaa5['rules'][_0x27b7e8][_0xf60b('0x77')]?_0x10b457(_0x1cbaa5['rules'][_0x27b7e8][_0xf60b('0x77')]):_0x1cbaa5['rules'][_0x27b7e8][_0xf60b('0x66')]+'\x20'+_0x1cbaa5['rules'][_0x27b7e8]['condition']+(_0x156e7e(_0x1cbaa5[_0xf60b('0x64')][_0x27b7e8][_0xf60b('0x67')])?'\x20'+_0x1cbaa5['rules'][_0x27b7e8][_0xf60b('0x68')]:'');}return _0x3fc2a5+')';};var _0x34419c={'where':{'id':_0x1f64d9[_0xf60b('0x45')]['id']}},_0x10f75e,_0xcf1d5c,_0x44b042,_0x53ae4f,_0x2987cb;_0x34419c=_[_0xf60b('0x3e')]({},_0x34419c,_0x1f64d9['options']);return db[_0xf60b('0x2e')][_0xf60b('0x4b')](_0x34419c)[_0xf60b('0x24')](function(_0x1c6fdc){if(_0x1c6fdc){_0x10f75e=_0x1c6fdc;return _0x1c6fdc[_0xf60b('0xa1')]();}return null;})[_0xf60b('0x24')](function(_0x3aadc6){if(_0x3aadc6){if(!_0x3aadc6['length']){throw new db[(_0xf60b('0x69'))][(_0xf60b('0x6a'))](_0xf60b('0xa2'),0x193);}_0xcf1d5c=_0x3aadc6;return db[_0xf60b('0x6b')][_0xf60b('0x6c')]({'raw':!![]});}return null;})[_0xf60b('0x24')](function(_0x2091f4){if(_0x2091f4){_0x44b042=_['keyBy'](_0x2091f4,'id');var _0x13f6bf;var _0x44d9e6=squel[_0xf60b('0x6e')]();_0x44d9e6['from'](_0x10f75e[_0xf60b('0x70')]);for(var _0x20841d=0x0;_0x20841d<_0xcf1d5c[_0xf60b('0x37')];_0x20841d+=0x1){_0x13f6bf=_0xcf1d5c[_0x20841d][_0xf60b('0x71')]?_0x44b042[_0xcf1d5c[_0x20841d][_0xf60b('0x71')]]['metric']:_0xcf1d5c[_0x20841d]['field'];_0x13f6bf=_0xcf1d5c[_0x20841d][_0xf60b('0x73')]?_[_0xf60b('0x74')](_0x12cc5c[_0xcf1d5c[_0x20841d][_0xf60b('0x73')]],'%s',_0x13f6bf):_0x13f6bf;_0x13f6bf=_0xcf1d5c[_0x20841d][_0xf60b('0x75')]?_['replace'](_0x30f6dc[_0xcf1d5c[_0x20841d][_0xf60b('0x75')]],'%s',_0x13f6bf):_0x13f6bf;if(_0xcf1d5c[_0x20841d][_0xf60b('0x76')]){_0x44d9e6[_0xf60b('0x77')](_0x13f6bf);}_0xcf1d5c[_0x20841d][_0xf60b('0x78')]&&_0x44d9e6[_0xf60b('0x79')](_0x13f6bf,_0xcf1d5c[_0x20841d][_0xf60b('0x78')]===_0xf60b('0x7a')?![]:!![]);_0x44d9e6['field'](_0x13f6bf,_0xcf1d5c[_0x20841d][_0xf60b('0x7b')]||_0x13f6bf);}if(_0x10f75e['joins']){_0x10f75e[_0xf60b('0x7c')]=JSON[_0xf60b('0x7d')](_0x10f75e[_0xf60b('0x7c')]);for(var _0x9737b4=0x0;_0x9737b4<_0x10f75e[_0xf60b('0x7c')][_0xf60b('0x37')];_0x9737b4+=0x1){if(_0x10f75e['joins'][_0x9737b4][_0xf60b('0x3f')]&&_[_0xf60b('0x5f')](_0x5815c4,_0x10f75e['joins'][_0x9737b4][_0xf60b('0x3f')])&&_0x10f75e[_0xf60b('0x7c')][_0x9737b4][_0xf60b('0x7e')]&&_0x10f75e['joins'][_0x9737b4][_0xf60b('0x7f')]&&_0x10f75e['joins'][_0x9737b4]['foreignKey']){_0x44d9e6[_0x10f75e[_0xf60b('0x7c')][_0x9737b4]['type']](_0x10f75e[_0xf60b('0x7c')][_0x9737b4][_0xf60b('0x7f')],null,util[_0xf60b('0x75')]('%s.%s\x20=\x20%s.%s',_0x10f75e[_0xf60b('0x70')],_0x10f75e[_0xf60b('0x7c')][_0x9737b4][_0xf60b('0x7e')],_0x10f75e['joins'][_0x9737b4][_0xf60b('0x7f')],_0x10f75e[_0xf60b('0x7c')][_0x9737b4][_0xf60b('0x81')]));}}}if(_0x10f75e[_0xf60b('0x82')]){_0x10f75e[_0xf60b('0x82')]=JSON[_0xf60b('0x7d')](_0x10f75e[_0xf60b('0x82')]);_0x44d9e6['where'](_0x10b457(_0x10f75e[_0xf60b('0x82')][_0xf60b('0x77')]));}_0x2987cb=_0x44d9e6['clone']();_0x44d9e6[_0xf60b('0x1e')](_0x55c87e);_0x44d9e6[_0xf60b('0x1d')](0x0);logger[_0xf60b('0x8a')](_0xf60b('0x84'),_0x44d9e6[_0xf60b('0x85')]());return db[_0xf60b('0x86')][_0xf60b('0x32')](_0x44d9e6[_0xf60b('0x85')](),{'type':db[_0xf60b('0x86')][_0xf60b('0x87')][_0xf60b('0x9e')]});}})['then'](function(){return{'sql':_0x2987cb['toString']()};})['then'](respondWithResult(_0x23d9a2,null))[_0xf60b('0x44')](handleError(_0x23d9a2,null));};
\ No newline at end of file
+var _0xf013=['sort','pick','filter','where','VIRTUAL','merge','includeAll','include','findAll','rows','catch','show','params','find','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','preview','join','left_join','right_join','cross_join','SUM(%s)','COUNT(%s)','MAX(%s)','AVG(%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)','ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20EMPTY','rules','operator','group','field','condition','value','options','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','select','from','table','MetricId','metric','function','format','replace','groupBy','orderBy','DESC','alias','joins','parse','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','clone','Limited\x20Query:','toString','sequelize','SELECT','COUNT(DISTINCT\x20%s)','IS\x20NULL','keyBy','debug','QueryTypes','No\x20available\x20data','output','fullPath','%s-%s.%s','randomstring','generate','default','AnalyticExtractedReport','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../files/reports','countTable','run','runReport','MIN(%s)','IS\x20NOT\x20NULL','IS\x20NOT\x20EMPTY','AnalyticMetric','html-pdf','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','DefaultReports','UserProfileResource','error','stack','name','send','index','map','AnalyticDefaultReport','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','order'];(function(_0x1c8c97,_0x3b92d2){var _0x373d52=function(_0xb3828){while(--_0xb3828){_0x1c8c97['push'](_0x1c8c97['shift']());}};_0x373d52(++_0x3b92d2);}(_0xf013,0x118));var _0x3f01=function(_0x2a23c9,_0x513bcb){_0x2a23c9=_0x2a23c9-0x0;var _0x435c74=_0xf013[_0x2a23c9];return _0x435c74;};'use strict';var pdf=require(_0x3f01('0x0'));var emlformat=require(_0x3f01('0x1'));var rimraf=require(_0x3f01('0x2'));var zipdir=require(_0x3f01('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x3f01('0x4'));var moment=require('moment');var BPromise=require(_0x3f01('0x5'));var Mustache=require(_0x3f01('0x6'));var util=require(_0x3f01('0x7'));var path=require(_0x3f01('0x8'));var sox=require(_0x3f01('0x9'));var csv=require(_0x3f01('0xa'));var ejs=require(_0x3f01('0xb'));var fs=require('fs');var _=require(_0x3f01('0xc'));var squel=require(_0x3f01('0xd'));var crypto=require(_0x3f01('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x3f01('0xf'));var toCsv=require(_0x3f01('0xa'));var querystring=require('querystring');var Papa=require(_0x3f01('0x10'));var Redis=require(_0x3f01('0x11'));var authService=require(_0x3f01('0x12'));var qs=require(_0x3f01('0x13'));var as=require(_0x3f01('0x14'));var hardwareService=require(_0x3f01('0x15'));var logger=require(_0x3f01('0x16'))(_0x3f01('0x17'));var utils=require(_0x3f01('0x18'));var config=require(_0x3f01('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x3f01('0x1a'))['db'];var dbH=require(_0x3f01('0x1a'))['dbH'];function respondWithStatusCode(_0x2b0661,_0x1b191b){_0x1b191b=_0x1b191b||0xcc;return function(_0x180df9){if(_0x180df9){return _0x2b0661[_0x3f01('0x1b')](_0x1b191b);}return _0x2b0661[_0x3f01('0x1c')](_0x1b191b)[_0x3f01('0x1d')]();};}function respondWithResult(_0x32effe,_0x4092d2){_0x4092d2=_0x4092d2||0xc8;return function(_0x58a286){if(_0x58a286){return _0x32effe[_0x3f01('0x1c')](_0x4092d2)['json'](_0x58a286);}};}function respondWithFilteredResult(_0x4c391b,_0x4aaf6c){return function(_0x16b835){if(_0x16b835){var _0x28bcef=_0x16b835[_0x3f01('0x1e')],_0xf526ac=_0x4aaf6c['offset'],_0x507d65=_0x4aaf6c[_0x3f01('0x1f')]+_0x4aaf6c[_0x3f01('0x20')],_0x4ba5df;if(_0x507d65>=_0x28bcef){_0x507d65=_0x28bcef;_0x4ba5df=0xc8;}else{_0x4ba5df=0xce;}_0x4c391b[_0x3f01('0x1c')](_0x4ba5df);return _0x4c391b[_0x3f01('0x21')](_0x3f01('0x22'),_0xf526ac+'-'+_0x507d65+'/'+_0x28bcef)['json'](_0x16b835);}return null;};}function patchUpdates(_0x200860){return function(_0x11db66){try{jsonpatch[_0x3f01('0x23')](_0x11db66,_0x200860,!![]);}catch(_0x3295ee){return BPromise[_0x3f01('0x24')](_0x3295ee);}return _0x11db66[_0x3f01('0x25')]();};}function saveUpdates(_0x2aeed7,_0x1a8573){return function(_0x48c7de){if(_0x48c7de){return _0x48c7de[_0x3f01('0x26')](_0x2aeed7)[_0x3f01('0x27')](function(_0x4f0fd5){return _0x4f0fd5;});}return null;};}function removeEntity(_0x31650b,_0x5096d4){return function(_0x1d10f3){if(_0x1d10f3){return _0x1d10f3[_0x3f01('0x28')]()['then'](function(){var _0x1266bb=_0x1d10f3['get']({'plain':!![]});var _0x1acff3=_0x3f01('0x29');return db[_0x3f01('0x2a')]['destroy']({'where':{'type':_0x1acff3,'resourceId':_0x1266bb['id']}})['then'](function(){return _0x1d10f3;});})[_0x3f01('0x27')](function(){_0x31650b['status'](0xcc)[_0x3f01('0x1d')]();});}};}function handleEntityNotFound(_0x10fd81,_0x4b3b9c){return function(_0x56f4e5){if(!_0x56f4e5){_0x10fd81['sendStatus'](0x194);}return _0x56f4e5;};}function handleError(_0x2da0b1,_0x108838){_0x108838=_0x108838||0x1f4;return function(_0x2ba5fd){logger[_0x3f01('0x2b')](_0x2ba5fd[_0x3f01('0x2c')]);if(_0x2ba5fd['name']){delete _0x2ba5fd[_0x3f01('0x2d')];}_0x2da0b1[_0x3f01('0x1c')](_0x108838)[_0x3f01('0x2e')](_0x2ba5fd);};}exports[_0x3f01('0x2f')]=function(_0x3c96dc,_0x1f0abc){var _0x5b2292={},_0x50d5ea={},_0x5a83b4={'count':0x0,'rows':[]};var _0x564766=_[_0x3f01('0x30')](db[_0x3f01('0x31')][_0x3f01('0x32')],function(_0x503181){return{'name':_0x503181[_0x3f01('0x33')],'type':_0x503181[_0x3f01('0x34')][_0x3f01('0x35')]};});_0x50d5ea[_0x3f01('0x36')]=_[_0x3f01('0x30')](_0x564766,_0x3f01('0x2d'));_0x50d5ea[_0x3f01('0x37')]=_[_0x3f01('0x38')](_0x3c96dc[_0x3f01('0x37')]);_0x50d5ea[_0x3f01('0x39')]=_['intersection'](_0x50d5ea[_0x3f01('0x36')],_0x50d5ea[_0x3f01('0x37')]);_0x5b2292[_0x3f01('0x3a')]=_[_0x3f01('0x3b')](_0x50d5ea[_0x3f01('0x36')],qs[_0x3f01('0x3c')](_0x3c96dc[_0x3f01('0x37')]['fields']));_0x5b2292[_0x3f01('0x3a')]=_0x5b2292['attributes'][_0x3f01('0x3d')]?_0x5b2292[_0x3f01('0x3a')]:_0x50d5ea[_0x3f01('0x36')];if(!_0x3c96dc[_0x3f01('0x37')][_0x3f01('0x3e')]('nolimit')){_0x5b2292[_0x3f01('0x20')]=qs[_0x3f01('0x20')](_0x3c96dc['query'][_0x3f01('0x20')]);_0x5b2292[_0x3f01('0x1f')]=qs[_0x3f01('0x1f')](_0x3c96dc['query'][_0x3f01('0x1f')]);}_0x5b2292[_0x3f01('0x3f')]=qs[_0x3f01('0x40')](_0x3c96dc[_0x3f01('0x37')][_0x3f01('0x40')]);_0x5b2292['where']=qs['filters'](_[_0x3f01('0x41')](_0x3c96dc[_0x3f01('0x37')],_0x50d5ea[_0x3f01('0x39')]),_0x564766);if(_0x3c96dc[_0x3f01('0x37')][_0x3f01('0x42')]){_0x5b2292[_0x3f01('0x43')]=_['merge'](_0x5b2292[_0x3f01('0x43')],{'$or':_[_0x3f01('0x30')](_0x564766,function(_0x4adb81){if(_0x4adb81[_0x3f01('0x34')]!==_0x3f01('0x44')){var _0x469c01={};_0x469c01[_0x4adb81['name']]={'$like':'%'+_0x3c96dc[_0x3f01('0x37')][_0x3f01('0x42')]+'%'};return _0x469c01;}})});}_0x5b2292=_[_0x3f01('0x45')]({},_0x5b2292,_0x3c96dc['options']);var _0x3b85fb={'where':_0x5b2292['where']};return db[_0x3f01('0x31')][_0x3f01('0x1e')](_0x3b85fb)[_0x3f01('0x27')](function(_0x1ed451){_0x5a83b4[_0x3f01('0x1e')]=_0x1ed451;if(_0x3c96dc[_0x3f01('0x37')][_0x3f01('0x46')]){_0x5b2292[_0x3f01('0x47')]=[{'all':!![]}];}return db[_0x3f01('0x31')][_0x3f01('0x48')](_0x5b2292);})[_0x3f01('0x27')](function(_0x2b02f7){_0x5a83b4[_0x3f01('0x49')]=_0x2b02f7;return _0x5a83b4;})[_0x3f01('0x27')](respondWithFilteredResult(_0x1f0abc,_0x5b2292))[_0x3f01('0x4a')](handleError(_0x1f0abc,null));};exports[_0x3f01('0x4b')]=function(_0xae55c2,_0x1070bb){var _0x486319={'raw':!![],'where':{'id':_0xae55c2[_0x3f01('0x4c')]['id']}},_0x1ab9e3={};_0x1ab9e3[_0x3f01('0x36')]=_['keys'](db['AnalyticDefaultReport']['rawAttributes']);_0x1ab9e3['query']=_['keys'](_0xae55c2[_0x3f01('0x37')]);_0x1ab9e3[_0x3f01('0x39')]=_[_0x3f01('0x3b')](_0x1ab9e3[_0x3f01('0x36')],_0x1ab9e3['query']);_0x486319[_0x3f01('0x3a')]=_[_0x3f01('0x3b')](_0x1ab9e3[_0x3f01('0x36')],qs['fields'](_0xae55c2[_0x3f01('0x37')][_0x3f01('0x3c')]));_0x486319[_0x3f01('0x3a')]=_0x486319[_0x3f01('0x3a')]['length']?_0x486319[_0x3f01('0x3a')]:_0x1ab9e3[_0x3f01('0x36')];if(_0xae55c2[_0x3f01('0x37')]['includeAll']){_0x486319[_0x3f01('0x47')]=[{'all':!![]}];}_0x486319=_[_0x3f01('0x45')]({},_0x486319,_0xae55c2['options']);return db[_0x3f01('0x31')][_0x3f01('0x4d')](_0x486319)['then'](handleEntityNotFound(_0x1070bb,null))[_0x3f01('0x27')](respondWithResult(_0x1070bb,null))[_0x3f01('0x4a')](handleError(_0x1070bb,null));};exports['create']=function(_0x58c9c6,_0x5f5cc1){return db[_0x3f01('0x31')][_0x3f01('0x4e')](_0x58c9c6['body'],{})['then'](function(_0x4a1a8a){var _0x5616af=_0x58c9c6[_0x3f01('0x4f')][_0x3f01('0x50')]({'plain':!![]});if(!_0x5616af)throw new Error(_0x3f01('0x51'));if(_0x5616af[_0x3f01('0x52')]===_0x3f01('0x4f')){var _0x3e6e3c=_0x4a1a8a[_0x3f01('0x50')]({'plain':!![]});var _0x4f7cff=_0x3f01('0x53');return db[_0x3f01('0x54')][_0x3f01('0x4d')]({'where':{'name':_0x4f7cff,'userProfileId':_0x5616af[_0x3f01('0x55')]},'raw':!![]})['then'](function(_0x577d70){if(_0x577d70&&_0x577d70[_0x3f01('0x56')]===0x0){return db[_0x3f01('0x2a')][_0x3f01('0x4e')]({'name':_0x3e6e3c['name'],'resourceId':_0x3e6e3c['id'],'type':_0x3f01('0x29'),'sectionId':_0x577d70['id']},{})[_0x3f01('0x27')](function(){return _0x4a1a8a;});}else{return _0x4a1a8a;}})['catch'](function(_0x550145){logger['error'](_0x3f01('0x57'),_0x550145);throw _0x550145;});}return _0x4a1a8a;})[_0x3f01('0x27')](respondWithResult(_0x5f5cc1,0xc9))['catch'](handleError(_0x5f5cc1,null));};exports[_0x3f01('0x26')]=function(_0x389dea,_0x5c5422){if(_0x389dea[_0x3f01('0x58')]['id']){delete _0x389dea['body']['id'];}return db[_0x3f01('0x31')][_0x3f01('0x4d')]({'where':{'id':_0x389dea['params']['id']}})[_0x3f01('0x27')](handleEntityNotFound(_0x5c5422,null))[_0x3f01('0x27')](saveUpdates(_0x389dea['body'],null))['then'](respondWithResult(_0x5c5422,null))[_0x3f01('0x4a')](handleError(_0x5c5422,null));};exports[_0x3f01('0x28')]=function(_0x32aace,_0x4e049b){return db[_0x3f01('0x31')][_0x3f01('0x4d')]({'where':{'id':_0x32aace[_0x3f01('0x4c')]['id']}})['then'](handleEntityNotFound(_0x4e049b,null))[_0x3f01('0x27')](removeEntity(_0x4e049b,null))[_0x3f01('0x4a')](handleError(_0x4e049b,null));};exports[_0x3f01('0x59')]=function(_0x27dcb6,_0x55382d){var _0x1ab512=0xa;var _0x15901a=[_0x3f01('0x5a'),_0x3f01('0x5b'),_0x3f01('0x5c'),_0x3f01('0x5d')];var _0x691882={'SUM':_0x3f01('0x5e'),'COUNT':_0x3f01('0x5f'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x3f01('0x60'),'MIN':'MIN(%s)','AVG':_0x3f01('0x61'),'GROUP_CONCAT':_0x3f01('0x62'),'GROUP_CONCAT ASC':_0x3f01('0x63'),'GROUP_CONCAT DESC':_0x3f01('0x64')};var _0x2b67e4={'SEC_TO_TIME':_0x3f01('0x65'),'DATE':_0x3f01('0x66'),'HOUR':_0x3f01('0x67'),'ROUND':_0x3f01('0x68'),'UNIX_TIMESTAMP':_0x3f01('0x69')};var _0x1655d1=function(_0x2fc6b5){return!_[_0x3f01('0x6a')](['IS\x20NULL','IS\x20NOT\x20NULL',_0x3f01('0x6b'),'IS\x20NOT\x20EMPTY'],_0x2fc6b5);};var _0x2e2e52=function(_0x637dc6){if(!_0x637dc6||!_0x637dc6[_0x3f01('0x6c')][_0x3f01('0x3d')]){return'';}for(var _0x1f8707='(',_0x5d70f4=0x0;_0x5d70f4<_0x637dc6[_0x3f01('0x6c')]['length'];_0x5d70f4+=0x1){_0x5d70f4>0x0&&(_0x1f8707+='\x20'+_0x637dc6[_0x3f01('0x6d')]+'\x20');_0x1f8707+=_0x637dc6['rules'][_0x5d70f4]['group']?_0x2e2e52(_0x637dc6['rules'][_0x5d70f4][_0x3f01('0x6e')]):_0x637dc6[_0x3f01('0x6c')][_0x5d70f4][_0x3f01('0x6f')]+'\x20'+_0x637dc6['rules'][_0x5d70f4][_0x3f01('0x70')]+(_0x1655d1(_0x637dc6[_0x3f01('0x6c')][_0x5d70f4][_0x3f01('0x70')])?'\x20'+_0x637dc6[_0x3f01('0x6c')][_0x5d70f4][_0x3f01('0x71')]:'');}return _0x1f8707+')';};var _0x495bad={'where':{'id':_0x27dcb6[_0x3f01('0x4c')]['id']}},_0x6f0a59,_0x20b31c,_0x3a5e39,_0x2d9e4d,_0x33ff5a;_0x495bad=_[_0x3f01('0x45')]({},_0x495bad,_0x27dcb6[_0x3f01('0x72')]);return db[_0x3f01('0x31')][_0x3f01('0x4d')](_0x495bad)[_0x3f01('0x27')](function(_0x4304a0){if(_0x4304a0){_0x6f0a59=_0x4304a0;return _0x4304a0[_0x3f01('0x73')]();}return null;})[_0x3f01('0x27')](function(_0x26a0bb){if(_0x26a0bb){if(!_0x26a0bb[_0x3f01('0x3d')]){throw new db[(_0x3f01('0x74'))][(_0x3f01('0x75'))](_0x3f01('0x76'),0x193);}_0x20b31c=_0x26a0bb;return db['AnalyticMetric'][_0x3f01('0x48')]({'raw':!![]});}return null;})['then'](function(_0x854e6d){if(_0x854e6d){_0x3a5e39=_['keyBy'](_0x854e6d,'id');var _0x43838f;var _0x4f1e9b=squel[_0x3f01('0x77')]();_0x4f1e9b[_0x3f01('0x78')](_0x6f0a59[_0x3f01('0x79')]);for(var _0x46f2f0=0x0;_0x46f2f0<_0x20b31c['length'];_0x46f2f0+=0x1){_0x43838f=_0x20b31c[_0x46f2f0][_0x3f01('0x7a')]?_0x3a5e39[_0x20b31c[_0x46f2f0][_0x3f01('0x7a')]][_0x3f01('0x7b')]:_0x20b31c[_0x46f2f0][_0x3f01('0x6f')];_0x43838f=_0x20b31c[_0x46f2f0][_0x3f01('0x7c')]?_['replace'](_0x691882[_0x20b31c[_0x46f2f0]['function']],'%s',_0x43838f):_0x43838f;_0x43838f=_0x20b31c[_0x46f2f0][_0x3f01('0x7d')]?_[_0x3f01('0x7e')](_0x2b67e4[_0x20b31c[_0x46f2f0]['format']],'%s',_0x43838f):_0x43838f;if(_0x20b31c[_0x46f2f0][_0x3f01('0x7f')]){_0x4f1e9b[_0x3f01('0x6e')](_0x43838f);}_0x20b31c[_0x46f2f0][_0x3f01('0x80')]&&_0x4f1e9b[_0x3f01('0x3f')](_0x43838f,_0x20b31c[_0x46f2f0][_0x3f01('0x80')]===_0x3f01('0x81')?![]:!![]);_0x4f1e9b['field'](_0x43838f,_0x20b31c[_0x46f2f0][_0x3f01('0x82')]||_0x43838f);}if(_0x6f0a59['joins']){_0x6f0a59[_0x3f01('0x83')]=JSON[_0x3f01('0x84')](_0x6f0a59[_0x3f01('0x83')]);for(var _0x31734d=0x0;_0x31734d<_0x6f0a59[_0x3f01('0x83')][_0x3f01('0x3d')];_0x31734d+=0x1){if(_0x6f0a59[_0x3f01('0x83')][_0x31734d][_0x3f01('0x34')]&&_[_0x3f01('0x6a')](_0x15901a,_0x6f0a59[_0x3f01('0x83')][_0x31734d][_0x3f01('0x34')])&&_0x6f0a59[_0x3f01('0x83')][_0x31734d][_0x3f01('0x85')]&&_0x6f0a59['joins'][_0x31734d][_0x3f01('0x86')]&&_0x6f0a59['joins'][_0x31734d][_0x3f01('0x87')]){_0x4f1e9b[_0x6f0a59[_0x3f01('0x83')][_0x31734d][_0x3f01('0x34')]](_0x6f0a59[_0x3f01('0x83')][_0x31734d][_0x3f01('0x86')],null,util[_0x3f01('0x7d')](_0x3f01('0x88'),_0x6f0a59[_0x3f01('0x79')],_0x6f0a59['joins'][_0x31734d][_0x3f01('0x85')],_0x6f0a59[_0x3f01('0x83')][_0x31734d][_0x3f01('0x86')],_0x6f0a59[_0x3f01('0x83')][_0x31734d][_0x3f01('0x87')]));}}}if(_0x6f0a59[_0x3f01('0x89')]){_0x6f0a59[_0x3f01('0x89')]=JSON[_0x3f01('0x84')](_0x6f0a59[_0x3f01('0x89')]);_0x4f1e9b[_0x3f01('0x43')](_0x2e2e52(_0x6f0a59[_0x3f01('0x89')][_0x3f01('0x6e')]));}_0x33ff5a=_0x4f1e9b[_0x3f01('0x8a')]();_0x4f1e9b[_0x3f01('0x20')](_0x1ab512);_0x4f1e9b[_0x3f01('0x1f')](0x0);logger['debug'](_0x3f01('0x8b'),_0x4f1e9b[_0x3f01('0x8c')]());return db[_0x3f01('0x8d')][_0x3f01('0x37')](_0x4f1e9b['toString'](),{'type':db[_0x3f01('0x8d')]['QueryTypes'][_0x3f01('0x8e')]});}})['then'](respondWithResult(_0x55382d,null))['catch'](handleError(_0x55382d,null));};function runReport(_0x3d1fa6,_0x2cdcf8,_0x39ad82){var _0x347336=_0x2cdcf8[_0x3f01('0x2d')];var _0xc872e8=0xa;var _0x101802=['join','left_join',_0x3f01('0x5c'),_0x3f01('0x5d')];var _0x184835={'SUM':_0x3f01('0x5e'),'COUNT':_0x3f01('0x5f'),'COUNT DISTINCT':_0x3f01('0x8f'),'MAX':'MAX(%s)','MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x3f01('0x64')};var _0x552ee3={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x3f01('0x66'),'HOUR':_0x3f01('0x67'),'ROUND':_0x3f01('0x68'),'UNIX_TIMESTAMP':_0x3f01('0x69')};var _0x4dcd94=function(_0x3a63dd){return!_['includes']([_0x3f01('0x90'),'IS\x20NOT\x20NULL',_0x3f01('0x6b'),'IS\x20NOT\x20EMPTY'],_0x3a63dd);};var _0x145de2=function(_0x2a2e2b){if(!_0x2a2e2b||!_0x2a2e2b[_0x3f01('0x6c')][_0x3f01('0x3d')]){return'';}for(var _0x36af04='(',_0x5c905a=0x0;_0x5c905a<_0x2a2e2b[_0x3f01('0x6c')][_0x3f01('0x3d')];_0x5c905a+=0x1){_0x5c905a>0x0&&(_0x36af04+='\x20'+_0x2a2e2b['operator']+'\x20');_0x36af04+=_0x2a2e2b[_0x3f01('0x6c')][_0x5c905a]['group']?_0x145de2(_0x2a2e2b[_0x3f01('0x6c')][_0x5c905a][_0x3f01('0x6e')]):_0x2a2e2b[_0x3f01('0x6c')][_0x5c905a][_0x3f01('0x6f')]+'\x20'+_0x2a2e2b[_0x3f01('0x6c')][_0x5c905a][_0x3f01('0x70')]+(_0x4dcd94(_0x2a2e2b[_0x3f01('0x6c')][_0x5c905a][_0x3f01('0x70')])?'\x20'+_0x2a2e2b['rules'][_0x5c905a]['value']:'');}return _0x36af04+')';};var _0x534334={'where':{'id':_0x3d1fa6['id']}},_0x3f7c47,_0x72a8f1,_0x9440d5,_0x2b1b23,_0x5db369;_0x534334=_['merge']({},_0x534334,_0x39ad82);return db[_0x3f01('0x31')][_0x3f01('0x4d')](_0x534334)[_0x3f01('0x27')](function(_0x33654b){if(_0x33654b){_0x3f7c47=_0x33654b;return _0x33654b[_0x3f01('0x73')]();}return null;})[_0x3f01('0x27')](function(_0x4a6455){if(_0x4a6455){if(!_0x4a6455['length']){throw new db[(_0x3f01('0x74'))][(_0x3f01('0x75'))](_0x3f01('0x76'),0x193);}_0x72a8f1=_0x4a6455;return db['AnalyticMetric'][_0x3f01('0x48')]({'raw':!![]});}return null;})['then'](function(_0x2a49cd){if(_0x2a49cd){_0x9440d5=_[_0x3f01('0x91')](_0x2a49cd,'id');var _0x1a4982;var _0x49990a=squel['select']();_0x49990a['from'](_0x3f7c47[_0x3f01('0x79')]);for(var _0x2bfb45=0x0;_0x2bfb45<_0x72a8f1[_0x3f01('0x3d')];_0x2bfb45+=0x1){_0x1a4982=_0x72a8f1[_0x2bfb45][_0x3f01('0x7a')]?_0x9440d5[_0x72a8f1[_0x2bfb45][_0x3f01('0x7a')]][_0x3f01('0x7b')]:_0x72a8f1[_0x2bfb45][_0x3f01('0x6f')];_0x1a4982=_0x72a8f1[_0x2bfb45]['function']?_[_0x3f01('0x7e')](_0x184835[_0x72a8f1[_0x2bfb45]['function']],'%s',_0x1a4982):_0x1a4982;_0x1a4982=_0x72a8f1[_0x2bfb45][_0x3f01('0x7d')]?_[_0x3f01('0x7e')](_0x552ee3[_0x72a8f1[_0x2bfb45][_0x3f01('0x7d')]],'%s',_0x1a4982):_0x1a4982;if(_0x72a8f1[_0x2bfb45][_0x3f01('0x7f')]){_0x49990a[_0x3f01('0x6e')](_0x1a4982);}_0x72a8f1[_0x2bfb45]['orderBy']&&_0x49990a[_0x3f01('0x3f')](_0x1a4982,_0x72a8f1[_0x2bfb45][_0x3f01('0x80')]==='DESC'?![]:!![]);_0x49990a[_0x3f01('0x6f')](_0x1a4982,_0x72a8f1[_0x2bfb45][_0x3f01('0x82')]||_0x1a4982);}if(_0x3f7c47['joins']){_0x3f7c47['joins']=JSON['parse'](_0x3f7c47[_0x3f01('0x83')]);for(var _0x31bc5f=0x0;_0x31bc5f<_0x3f7c47[_0x3f01('0x83')][_0x3f01('0x3d')];_0x31bc5f+=0x1){if(_0x3f7c47['joins'][_0x31bc5f][_0x3f01('0x34')]&&_['includes'](_0x101802,_0x3f7c47['joins'][_0x31bc5f]['type'])&&_0x3f7c47['joins'][_0x31bc5f][_0x3f01('0x85')]&&_0x3f7c47['joins'][_0x31bc5f][_0x3f01('0x86')]&&_0x3f7c47[_0x3f01('0x83')][_0x31bc5f][_0x3f01('0x87')]){_0x49990a[_0x3f7c47[_0x3f01('0x83')][_0x31bc5f][_0x3f01('0x34')]](_0x3f7c47[_0x3f01('0x83')][_0x31bc5f][_0x3f01('0x86')],null,util[_0x3f01('0x7d')](_0x3f01('0x88'),_0x3f7c47[_0x3f01('0x79')],_0x3f7c47[_0x3f01('0x83')][_0x31bc5f][_0x3f01('0x85')],_0x3f7c47[_0x3f01('0x83')][_0x31bc5f]['foreignTable'],_0x3f7c47[_0x3f01('0x83')][_0x31bc5f][_0x3f01('0x87')]));}}}if(_0x3f7c47[_0x3f01('0x89')]){_0x3f7c47[_0x3f01('0x89')]=JSON[_0x3f01('0x84')](_0x3f7c47[_0x3f01('0x89')]);_0x49990a[_0x3f01('0x43')](_0x145de2(_0x3f7c47[_0x3f01('0x89')][_0x3f01('0x6e')]));}_0x5db369=_0x49990a['clone']();_0x49990a[_0x3f01('0x20')](_0xc872e8);_0x49990a['offset'](0x0);logger[_0x3f01('0x92')]('Limited\x20Query:',_0x49990a['toString']());return db[_0x3f01('0x8d')]['query'](_0x49990a[_0x3f01('0x8c')](),{'type':db[_0x3f01('0x8d')][_0x3f01('0x93')][_0x3f01('0x8e')]});}})[_0x3f01('0x27')](function(_0x23fc78){if(!_0x23fc78[_0x3f01('0x3d')]){throw new db[(_0x3f01('0x74'))]['ValidationErrorItem'](_0x3f01('0x94'),0xcc);}if(_0x2cdcf8[_0x3f01('0x95')]==='web'){return null;}var _0x3bb10b=_['merge'](_0x2cdcf8,{'name':_0x2cdcf8[_0x3f01('0x96')]||_0x2cdcf8[_0x3f01('0x2d')]||_0x3f7c47['name'],'basename':_0x347336,'savename':util[_0x3f01('0x7d')](_0x3f01('0x97'),_0x2cdcf8[_0x3f01('0x2d')]||_0x3f7c47[_0x3f01('0x2d')],require(_0x3f01('0x98'))[_0x3f01('0x99')](0x4),_0x2cdcf8[_0x3f01('0x95')]||'csv'),'reportId':_0x3f7c47['id'],'reportType':_0x3f01('0x9a')});return db[_0x3f01('0x9b')][_0x3f01('0x4e')](_0x3bb10b,{'raw':!![]});})[_0x3f01('0x27')](function(_0x35bb3a){if(_0x3f7c47[_0x3f01('0x79')]==='cdr'){_0x5db369['where'](_0x3f7c47[_0x3f01('0x79')]+_0x3f01('0x9c'),_0x2cdcf8[_0x3f01('0x9d')],_0x2cdcf8[_0x3f01('0x9e')]);}else{_0x5db369[_0x3f01('0x43')](_0x3f7c47[_0x3f01('0x79')]+_0x3f01('0x9f'),_0x2cdcf8[_0x3f01('0x9d')],_0x2cdcf8[_0x3f01('0x9e')]);}if(_0x35bb3a){logger[_0x3f01('0xa0')](_0x3f01('0xa1'),_0x5db369[_0x3f01('0x8c')]());require(_0x3f01('0xa2'))[_0x3f01('0xa3')](path[_0x3f01('0x5a')](__dirname,'../../components/export/',_0x35bb3a[_0x3f01('0x95')]),[_0x35bb3a['id'],_0x5db369[_0x3f01('0x8c')](),path[_0x3f01('0x5a')](__dirname,_0x3f01('0xa4'),_0x35bb3a['savename']),_0x347336]);return _0x35bb3a;}else{var _0x2de096=squel['select']();_0x2de096[_0x3f01('0x78')]('('+_0x5db369[_0x3f01('0x8c')]()+')',_0x3f01('0xa5'));_0x2de096[_0x3f01('0x6f')]('COUNT(*)',_0x3f01('0x1e'));_0x5db369['limit'](_0x2cdcf8['limit']||_0xc872e8);_0x5db369[_0x3f01('0x1f')](_0x2cdcf8[_0x3f01('0x1f')]||0x0);return dbH[_0x3f01('0x8d')]['query'](_0x2de096[_0x3f01('0x8c')](),{'type':dbH[_0x3f01('0x8d')][_0x3f01('0x93')][_0x3f01('0x8e')]})[_0x3f01('0x27')](function(_0x442715){if(!_0x442715['length']){_0x2b1b23=0x0;}else{_0x2b1b23=_0x442715[0x0]['count']||0x0;}return dbH['sequelize'][_0x3f01('0x37')](_0x5db369[_0x3f01('0x8c')](),{'type':dbH['sequelize']['QueryTypes'][_0x3f01('0x8e')]});})[_0x3f01('0x27')](function(_0x3ec710){return{'rows':_0x3ec710||[],'count':_0x2b1b23};});}});}exports[_0x3f01('0xa6')]=function(_0x5a39a4,_0x22d16a){return runReport(_0x5a39a4[_0x3f01('0x4c')],_0x5a39a4[_0x3f01('0x37')],_0x5a39a4[_0x3f01('0x72')])[_0x3f01('0x27')](respondWithResult(_0x22d16a,null))[_0x3f01('0x4a')](handleError(_0x22d16a,null));};exports[_0x3f01('0xa7')]=runReport;exports[_0x3f01('0x37')]=function(_0x355a42,_0xf4d7b3){var _0x4916ca=0xa;var _0x8626b0=[_0x3f01('0x5a'),_0x3f01('0x5b'),_0x3f01('0x5c'),_0x3f01('0x5d')];var _0x23f07e={'SUM':_0x3f01('0x5e'),'COUNT':_0x3f01('0x5f'),'COUNT DISTINCT':_0x3f01('0x8f'),'MAX':_0x3f01('0x60'),'MIN':_0x3f01('0xa8'),'AVG':_0x3f01('0x61'),'GROUP_CONCAT':_0x3f01('0x62'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0xd72b44={'SEC_TO_TIME':_0x3f01('0x65'),'DATE':'DATE(%s)','HOUR':'HOUR(%s)','ROUND':_0x3f01('0x68'),'UNIX_TIMESTAMP':_0x3f01('0x69')};var _0x5756a8=function(_0x4f5c46){return!_['includes'](['IS\x20NULL',_0x3f01('0xa9'),'IS\x20EMPTY',_0x3f01('0xaa')],_0x4f5c46);};var _0x35d222=function(_0x53672a){if(!_0x53672a||!_0x53672a[_0x3f01('0x6c')][_0x3f01('0x3d')]){return'';}for(var _0x3bbcc5='(',_0x248610=0x0;_0x248610<_0x53672a['rules'][_0x3f01('0x3d')];_0x248610+=0x1){_0x248610>0x0&&(_0x3bbcc5+='\x20'+_0x53672a[_0x3f01('0x6d')]+'\x20');_0x3bbcc5+=_0x53672a[_0x3f01('0x6c')][_0x248610][_0x3f01('0x6e')]?_0x35d222(_0x53672a[_0x3f01('0x6c')][_0x248610][_0x3f01('0x6e')]):_0x53672a[_0x3f01('0x6c')][_0x248610]['field']+'\x20'+_0x53672a[_0x3f01('0x6c')][_0x248610][_0x3f01('0x70')]+(_0x5756a8(_0x53672a['rules'][_0x248610]['condition'])?'\x20'+_0x53672a[_0x3f01('0x6c')][_0x248610][_0x3f01('0x71')]:'');}return _0x3bbcc5+')';};var _0x281353={'where':{'id':_0x355a42['params']['id']}},_0xac2900,_0x544b71,_0x1fa62b,_0x4ce7fb,_0x280cb5;_0x281353=_[_0x3f01('0x45')]({},_0x281353,_0x355a42[_0x3f01('0x72')]);return db['AnalyticDefaultReport'][_0x3f01('0x4d')](_0x281353)[_0x3f01('0x27')](function(_0x24d9cd){if(_0x24d9cd){_0xac2900=_0x24d9cd;return _0x24d9cd[_0x3f01('0x73')]();}return null;})[_0x3f01('0x27')](function(_0x414c94){if(_0x414c94){if(!_0x414c94['length']){throw new db['Sequelize']['ValidationErrorItem'](_0x3f01('0x76'),0x193);}_0x544b71=_0x414c94;return db[_0x3f01('0xab')][_0x3f01('0x48')]({'raw':!![]});}return null;})[_0x3f01('0x27')](function(_0x47e069){if(_0x47e069){_0x1fa62b=_[_0x3f01('0x91')](_0x47e069,'id');var _0x4314e5;var _0x510391=squel[_0x3f01('0x77')]();_0x510391[_0x3f01('0x78')](_0xac2900[_0x3f01('0x79')]);for(var _0x4ea16d=0x0;_0x4ea16d<_0x544b71[_0x3f01('0x3d')];_0x4ea16d+=0x1){_0x4314e5=_0x544b71[_0x4ea16d][_0x3f01('0x7a')]?_0x1fa62b[_0x544b71[_0x4ea16d][_0x3f01('0x7a')]][_0x3f01('0x7b')]:_0x544b71[_0x4ea16d][_0x3f01('0x6f')];_0x4314e5=_0x544b71[_0x4ea16d]['function']?_[_0x3f01('0x7e')](_0x23f07e[_0x544b71[_0x4ea16d][_0x3f01('0x7c')]],'%s',_0x4314e5):_0x4314e5;_0x4314e5=_0x544b71[_0x4ea16d][_0x3f01('0x7d')]?_['replace'](_0xd72b44[_0x544b71[_0x4ea16d][_0x3f01('0x7d')]],'%s',_0x4314e5):_0x4314e5;if(_0x544b71[_0x4ea16d]['groupBy']){_0x510391[_0x3f01('0x6e')](_0x4314e5);}_0x544b71[_0x4ea16d][_0x3f01('0x80')]&&_0x510391[_0x3f01('0x3f')](_0x4314e5,_0x544b71[_0x4ea16d][_0x3f01('0x80')]===_0x3f01('0x81')?![]:!![]);_0x510391['field'](_0x4314e5,_0x544b71[_0x4ea16d]['alias']||_0x4314e5);}if(_0xac2900[_0x3f01('0x83')]){_0xac2900[_0x3f01('0x83')]=JSON['parse'](_0xac2900[_0x3f01('0x83')]);for(var _0x48da61=0x0;_0x48da61<_0xac2900[_0x3f01('0x83')][_0x3f01('0x3d')];_0x48da61+=0x1){if(_0xac2900['joins'][_0x48da61]['type']&&_[_0x3f01('0x6a')](_0x8626b0,_0xac2900[_0x3f01('0x83')][_0x48da61][_0x3f01('0x34')])&&_0xac2900[_0x3f01('0x83')][_0x48da61]['parentKey']&&_0xac2900[_0x3f01('0x83')][_0x48da61][_0x3f01('0x86')]&&_0xac2900[_0x3f01('0x83')][_0x48da61][_0x3f01('0x87')]){_0x510391[_0xac2900[_0x3f01('0x83')][_0x48da61]['type']](_0xac2900[_0x3f01('0x83')][_0x48da61][_0x3f01('0x86')],null,util[_0x3f01('0x7d')](_0x3f01('0x88'),_0xac2900[_0x3f01('0x79')],_0xac2900[_0x3f01('0x83')][_0x48da61][_0x3f01('0x85')],_0xac2900[_0x3f01('0x83')][_0x48da61][_0x3f01('0x86')],_0xac2900[_0x3f01('0x83')][_0x48da61][_0x3f01('0x87')]));}}}if(_0xac2900[_0x3f01('0x89')]){_0xac2900[_0x3f01('0x89')]=JSON['parse'](_0xac2900['conditions']);_0x510391['where'](_0x35d222(_0xac2900[_0x3f01('0x89')][_0x3f01('0x6e')]));}_0x280cb5=_0x510391[_0x3f01('0x8a')]();_0x510391[_0x3f01('0x20')](_0x4916ca);_0x510391[_0x3f01('0x1f')](0x0);logger[_0x3f01('0x92')](_0x3f01('0x8b'),_0x510391[_0x3f01('0x8c')]());return db[_0x3f01('0x8d')][_0x3f01('0x37')](_0x510391['toString'](),{'type':db[_0x3f01('0x8d')][_0x3f01('0x93')][_0x3f01('0x8e')]});}})[_0x3f01('0x27')](function(){return{'sql':_0x280cb5[_0x3f01('0x8c')]()};})[_0x3f01('0x27')](respondWithResult(_0xf4d7b3,null))[_0x3f01('0x4a')](handleError(_0xf4d7b3,null));};
\ No newline at end of file