Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 130c1fc..dcacbdb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb0bf=['VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','role','user','Reports','UserProfileSection','userProfileId','error','preview','join','left_join','right_join','SUM(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','IS\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','getFields','Sequelize','keyBy','select','table','MetricId','metric','function','format','replace','orderBy','DESC','alias','joins','parse','includes','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','parentKey','conditions','debug','Limited\x20Query:','toString','sequelize','QueryTypes','SELECT','cross_join','AVG(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','DATE(%s)','HOUR(%s)','IS\x20NOT\x20NULL','value','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','from','groupBy','clone','No\x20available\x20data','output','web','fullPath','%s-%s.%s','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','fork','../../components/export/','../../files/reports','COUNT(*)','run','COUNT(%s)','GROUP_CONCAT(%s)','html-pdf','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','sox','ejs','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../config/license/hardware','api','../../config/environment','../../mysqldb','dbH','sendStatus','end','status','json','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','get','DefaultReports','UserProfileResource','name','send','map','AnalyticDefaultReport','type','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter'];(function(_0x25bea7,_0x49ab45){var _0x175952=function(_0x56a0b5){while(--_0x56a0b5){_0x25bea7['push'](_0x25bea7['shift']());}};_0x175952(++_0x49ab45);}(_0xb0bf,0x66));var _0xfb0b=function(_0x27d72e,_0xb3d410){_0x27d72e=_0x27d72e-0x0;var _0x1cd188=_0xb0bf[_0x27d72e];return _0x1cd188;};'use strict';var pdf=require(_0xfb0b('0x0'));var emlformat=require(_0xfb0b('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xfb0b('0x2'));var rp=require(_0xfb0b('0x3'));var moment=require('moment');var BPromise=require(_0xfb0b('0x4'));var Mustache=require(_0xfb0b('0x5'));var util=require(_0xfb0b('0x6'));var path=require('path');var sox=require(_0xfb0b('0x7'));var csv=require('to-csv');var ejs=require(_0xfb0b('0x8'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xfb0b('0x9'));var toCsv=require(_0xfb0b('0xa'));var querystring=require(_0xfb0b('0xb'));var Papa=require(_0xfb0b('0xc'));var Redis=require('ioredis');var authService=require(_0xfb0b('0xd'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xfb0b('0xe'));var logger=require('../../config/logger')(_0xfb0b('0xf'));var utils=require('../../config/utils');var config=require(_0xfb0b('0x10'));var db=require('../../mysqldb')['db'];var dbH=require(_0xfb0b('0x11'))[_0xfb0b('0x12')];function respondWithStatusCode(_0x72bf0f,_0x59c626){_0x59c626=_0x59c626||0xcc;return function(_0x2c46fb){if(_0x2c46fb){return _0x72bf0f[_0xfb0b('0x13')](_0x59c626);}return _0x72bf0f['status'](_0x59c626)[_0xfb0b('0x14')]();};}function respondWithResult(_0x15c0c6,_0x515355){_0x515355=_0x515355||0xc8;return function(_0x4e80d9){if(_0x4e80d9){return _0x15c0c6[_0xfb0b('0x15')](_0x515355)[_0xfb0b('0x16')](_0x4e80d9);}};}function respondWithFilteredResult(_0x16b9c1,_0x11b283){return function(_0x3041a8){if(_0x3041a8){var _0x510cac=_0x3041a8[_0xfb0b('0x17')],_0x16d960=_0x11b283[_0xfb0b('0x18')],_0x337771=_0x11b283[_0xfb0b('0x18')]+_0x11b283['limit'],_0x4cf223;if(_0x337771>=_0x510cac){_0x337771=_0x510cac;_0x4cf223=0xc8;}else{_0x4cf223=0xce;}_0x16b9c1[_0xfb0b('0x15')](_0x4cf223);return _0x16b9c1[_0xfb0b('0x19')](_0xfb0b('0x1a'),_0x16d960+'-'+_0x337771+'/'+_0x510cac)[_0xfb0b('0x16')](_0x3041a8);}return null;};}function patchUpdates(_0x24e2ea){return function(_0x1de463){try{jsonpatch[_0xfb0b('0x1b')](_0x1de463,_0x24e2ea,!![]);}catch(_0x91a9ed){return BPromise[_0xfb0b('0x1c')](_0x91a9ed);}return _0x1de463[_0xfb0b('0x1d')]();};}function saveUpdates(_0x1c03e3,_0x103ea2){return function(_0x5bdb88){if(_0x5bdb88){return _0x5bdb88[_0xfb0b('0x1e')](_0x1c03e3)[_0xfb0b('0x1f')](function(_0x2c18c8){return _0x2c18c8;});}return null;};}function removeEntity(_0x4198a0,_0x20edc4){return function(_0x353e92){if(_0x353e92){return _0x353e92[_0xfb0b('0x20')]()['then'](function(){var _0x21a854=_0x353e92[_0xfb0b('0x21')]({'plain':!![]});var _0x32c85f=_0xfb0b('0x22');return db[_0xfb0b('0x23')]['destroy']({'where':{'type':_0x32c85f,'resourceId':_0x21a854['id']}})[_0xfb0b('0x1f')](function(){return _0x353e92;});})[_0xfb0b('0x1f')](function(){_0x4198a0[_0xfb0b('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1fe628,_0x20395d){return function(_0x2ba069){if(!_0x2ba069){_0x1fe628[_0xfb0b('0x13')](0x194);}return _0x2ba069;};}function handleError(_0x5d6649,_0x4b7557){_0x4b7557=_0x4b7557||0x1f4;return function(_0x3b9d5b){logger['error'](_0x3b9d5b['stack']);if(_0x3b9d5b[_0xfb0b('0x24')]){delete _0x3b9d5b[_0xfb0b('0x24')];}_0x5d6649[_0xfb0b('0x15')](_0x4b7557)[_0xfb0b('0x25')](_0x3b9d5b);};}exports['index']=function(_0x3f79e2,_0x5090fb){var _0x26a94a={},_0x246bd2={},_0x2eb110={'count':0x0,'rows':[]};var _0x1ad861=_[_0xfb0b('0x26')](db[_0xfb0b('0x27')]['rawAttributes'],function(_0x1e9892){return{'name':_0x1e9892['fieldName'],'type':_0x1e9892[_0xfb0b('0x28')]['key']};});_0x246bd2[_0xfb0b('0x29')]=_['map'](_0x1ad861,_0xfb0b('0x24'));_0x246bd2[_0xfb0b('0x2a')]=_[_0xfb0b('0x2b')](_0x3f79e2[_0xfb0b('0x2a')]);_0x246bd2[_0xfb0b('0x2c')]=_[_0xfb0b('0x2d')](_0x246bd2[_0xfb0b('0x29')],_0x246bd2['query']);_0x26a94a['attributes']=_[_0xfb0b('0x2d')](_0x246bd2['model'],qs[_0xfb0b('0x2e')](_0x3f79e2[_0xfb0b('0x2a')][_0xfb0b('0x2e')]));_0x26a94a[_0xfb0b('0x2f')]=_0x26a94a[_0xfb0b('0x2f')][_0xfb0b('0x30')]?_0x26a94a['attributes']:_0x246bd2[_0xfb0b('0x29')];if(!_0x3f79e2[_0xfb0b('0x2a')][_0xfb0b('0x31')](_0xfb0b('0x32'))){_0x26a94a[_0xfb0b('0x33')]=qs[_0xfb0b('0x33')](_0x3f79e2['query'][_0xfb0b('0x33')]);_0x26a94a[_0xfb0b('0x18')]=qs['offset'](_0x3f79e2[_0xfb0b('0x2a')][_0xfb0b('0x18')]);}_0x26a94a[_0xfb0b('0x34')]=qs[_0xfb0b('0x35')](_0x3f79e2['query'][_0xfb0b('0x35')]);_0x26a94a[_0xfb0b('0x36')]=qs[_0xfb0b('0x2c')](_[_0xfb0b('0x37')](_0x3f79e2[_0xfb0b('0x2a')],_0x246bd2['filters']));if(_0x3f79e2['query'][_0xfb0b('0x38')]){_0x26a94a[_0xfb0b('0x36')]=_['merge'](_0x26a94a[_0xfb0b('0x36')],{'$or':_[_0xfb0b('0x26')](_0x1ad861,function(_0x1d11a2){if(_0x1d11a2[_0xfb0b('0x28')]!==_0xfb0b('0x39')){var _0x38d22c={};_0x38d22c[_0x1d11a2['name']]={'$like':'%'+_0x3f79e2[_0xfb0b('0x2a')]['filter']+'%'};return _0x38d22c;}})});}_0x26a94a=_[_0xfb0b('0x3a')]({},_0x26a94a,_0x3f79e2[_0xfb0b('0x3b')]);var _0xdc6976={'where':_0x26a94a['where']};return db[_0xfb0b('0x27')]['count'](_0xdc6976)[_0xfb0b('0x1f')](function(_0x4db413){_0x2eb110[_0xfb0b('0x17')]=_0x4db413;if(_0x3f79e2[_0xfb0b('0x2a')][_0xfb0b('0x3c')]){_0x26a94a[_0xfb0b('0x3d')]=[{'all':!![]}];}return db[_0xfb0b('0x27')][_0xfb0b('0x3e')](_0x26a94a);})[_0xfb0b('0x1f')](function(_0x5cb22b){_0x2eb110[_0xfb0b('0x3f')]=_0x5cb22b;return _0x2eb110;})[_0xfb0b('0x1f')](respondWithFilteredResult(_0x5090fb,_0x26a94a))[_0xfb0b('0x40')](handleError(_0x5090fb,null));};exports[_0xfb0b('0x41')]=function(_0x568496,_0x5edd8e){var _0x56e86b={'raw':!![],'where':{'id':_0x568496[_0xfb0b('0x42')]['id']}},_0x5da014={};_0x5da014['model']=_[_0xfb0b('0x2b')](db['AnalyticDefaultReport']['rawAttributes']);_0x5da014[_0xfb0b('0x2a')]=_['keys'](_0x568496['query']);_0x5da014['filters']=_['intersection'](_0x5da014[_0xfb0b('0x29')],_0x5da014[_0xfb0b('0x2a')]);_0x56e86b[_0xfb0b('0x2f')]=_[_0xfb0b('0x2d')](_0x5da014[_0xfb0b('0x29')],qs[_0xfb0b('0x2e')](_0x568496[_0xfb0b('0x2a')][_0xfb0b('0x2e')]));_0x56e86b['attributes']=_0x56e86b['attributes'][_0xfb0b('0x30')]?_0x56e86b[_0xfb0b('0x2f')]:_0x5da014[_0xfb0b('0x29')];if(_0x568496[_0xfb0b('0x2a')][_0xfb0b('0x3c')]){_0x56e86b['include']=[{'all':!![]}];}_0x56e86b=_[_0xfb0b('0x3a')]({},_0x56e86b,_0x568496[_0xfb0b('0x3b')]);return db[_0xfb0b('0x27')][_0xfb0b('0x43')](_0x56e86b)['then'](handleEntityNotFound(_0x5edd8e,null))['then'](respondWithResult(_0x5edd8e,null))[_0xfb0b('0x40')](handleError(_0x5edd8e,null));};exports[_0xfb0b('0x44')]=function(_0x4fb8ae,_0xdc138c){return db[_0xfb0b('0x27')][_0xfb0b('0x44')](_0x4fb8ae[_0xfb0b('0x45')],{})['then'](function(_0x109c85){var _0x44e82d=_0x4fb8ae['user'][_0xfb0b('0x21')]({'plain':!![]});if(!_0x44e82d)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x44e82d[_0xfb0b('0x46')]===_0xfb0b('0x47')){var _0x35d28e=_0x109c85[_0xfb0b('0x21')]({'plain':!![]});var _0x5228cf=_0xfb0b('0x48');return db[_0xfb0b('0x49')][_0xfb0b('0x43')]({'where':{'name':_0x5228cf,'userProfileId':_0x44e82d[_0xfb0b('0x4a')]},'raw':!![]})[_0xfb0b('0x1f')](function(_0x5d0470){if(_0x5d0470&&_0x5d0470['autoAssociation']===0x0){return db[_0xfb0b('0x23')][_0xfb0b('0x44')]({'name':_0x35d28e[_0xfb0b('0x24')],'resourceId':_0x35d28e['id'],'type':_0xfb0b('0x22'),'sectionId':_0x5d0470['id']},{})['then'](function(){return _0x109c85;});}else{return _0x109c85;}})[_0xfb0b('0x40')](function(_0x4f03d9){logger[_0xfb0b('0x4b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4f03d9);throw _0x4f03d9;});}return _0x109c85;})[_0xfb0b('0x1f')](respondWithResult(_0xdc138c,0xc9))[_0xfb0b('0x40')](handleError(_0xdc138c,null));};exports[_0xfb0b('0x1e')]=function(_0x3334fa,_0x3e4aa4){if(_0x3334fa['body']['id']){delete _0x3334fa[_0xfb0b('0x45')]['id'];}return db[_0xfb0b('0x27')][_0xfb0b('0x43')]({'where':{'id':_0x3334fa[_0xfb0b('0x42')]['id']}})[_0xfb0b('0x1f')](handleEntityNotFound(_0x3e4aa4,null))[_0xfb0b('0x1f')](saveUpdates(_0x3334fa[_0xfb0b('0x45')],null))['then'](respondWithResult(_0x3e4aa4,null))[_0xfb0b('0x40')](handleError(_0x3e4aa4,null));};exports['destroy']=function(_0xcd0772,_0x198107){return db['AnalyticDefaultReport']['find']({'where':{'id':_0xcd0772[_0xfb0b('0x42')]['id']}})[_0xfb0b('0x1f')](handleEntityNotFound(_0x198107,null))[_0xfb0b('0x1f')](removeEntity(_0x198107,null))[_0xfb0b('0x40')](handleError(_0x198107,null));};exports[_0xfb0b('0x4c')]=function(_0x3db135,_0x57eba3){var _0x21e5b9=0xa;var _0x18dbee=[_0xfb0b('0x4d'),_0xfb0b('0x4e'),_0xfb0b('0x4f'),'cross_join'];var _0xce0e9e={'SUM':_0xfb0b('0x50'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xfb0b('0x51'),'MAX':_0xfb0b('0x52'),'MIN':_0xfb0b('0x53'),'AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xfb0b('0x54')};var _0x3687a5={'SEC_TO_TIME':_0xfb0b('0x55'),'DATE':'DATE(%s)','HOUR':'HOUR(%s)','ROUND':_0xfb0b('0x56'),'UNIX_TIMESTAMP':_0xfb0b('0x57')};var _0x1a0bd7=function(_0x166c62){return!_['includes']([_0xfb0b('0x58'),'IS\x20NOT\x20NULL',_0xfb0b('0x59'),_0xfb0b('0x5a')],_0x166c62);};var _0x5d0dc9=function(_0x4d9819){if(!_0x4d9819||!_0x4d9819[_0xfb0b('0x5b')][_0xfb0b('0x30')]){return'';}for(var _0x404529='(',_0x31a93d=0x0;_0x31a93d<_0x4d9819[_0xfb0b('0x5b')][_0xfb0b('0x30')];_0x31a93d+=0x1){_0x31a93d>0x0&&(_0x404529+='\x20'+_0x4d9819[_0xfb0b('0x5c')]+'\x20');_0x404529+=_0x4d9819[_0xfb0b('0x5b')][_0x31a93d][_0xfb0b('0x5d')]?_0x5d0dc9(_0x4d9819['rules'][_0x31a93d][_0xfb0b('0x5d')]):_0x4d9819['rules'][_0x31a93d][_0xfb0b('0x5e')]+'\x20'+_0x4d9819['rules'][_0x31a93d]['condition']+(_0x1a0bd7(_0x4d9819['rules'][_0x31a93d][_0xfb0b('0x5f')])?'\x20'+_0x4d9819[_0xfb0b('0x5b')][_0x31a93d]['value']:'');}return _0x404529+')';};var _0xaef6d8={'where':{'id':_0x3db135[_0xfb0b('0x42')]['id']}},_0x19adbe,_0x4b5c23,_0x5de806,_0x403fc7,_0xbead04;_0xaef6d8=_[_0xfb0b('0x3a')]({},_0xaef6d8,_0x3db135['options']);return db[_0xfb0b('0x27')]['find'](_0xaef6d8)[_0xfb0b('0x1f')](function(_0x37d190){if(_0x37d190){_0x19adbe=_0x37d190;return _0x37d190[_0xfb0b('0x60')]();}return null;})[_0xfb0b('0x1f')](function(_0x21b631){if(_0x21b631){if(!_0x21b631['length']){throw new db[(_0xfb0b('0x61'))]['ValidationErrorItem']('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x4b5c23=_0x21b631;return db['AnalyticMetric'][_0xfb0b('0x3e')]({'raw':!![]});}return null;})[_0xfb0b('0x1f')](function(_0x32eae5){if(_0x32eae5){_0x5de806=_[_0xfb0b('0x62')](_0x32eae5,'id');var _0x5ca7cb;var _0x23877a=squel[_0xfb0b('0x63')]();_0x23877a['from'](_0x19adbe[_0xfb0b('0x64')]);for(var _0x2e3cfc=0x0;_0x2e3cfc<_0x4b5c23['length'];_0x2e3cfc+=0x1){_0x5ca7cb=_0x4b5c23[_0x2e3cfc][_0xfb0b('0x65')]?_0x5de806[_0x4b5c23[_0x2e3cfc][_0xfb0b('0x65')]][_0xfb0b('0x66')]:_0x4b5c23[_0x2e3cfc][_0xfb0b('0x5e')];_0x5ca7cb=_0x4b5c23[_0x2e3cfc][_0xfb0b('0x67')]?_['replace'](_0xce0e9e[_0x4b5c23[_0x2e3cfc][_0xfb0b('0x67')]],'%s',_0x5ca7cb):_0x5ca7cb;_0x5ca7cb=_0x4b5c23[_0x2e3cfc][_0xfb0b('0x68')]?_[_0xfb0b('0x69')](_0x3687a5[_0x4b5c23[_0x2e3cfc][_0xfb0b('0x68')]],'%s',_0x5ca7cb):_0x5ca7cb;if(_0x4b5c23[_0x2e3cfc]['groupBy']){_0x23877a['group'](_0x5ca7cb);}_0x4b5c23[_0x2e3cfc]['orderBy']&&_0x23877a['order'](_0x5ca7cb,_0x4b5c23[_0x2e3cfc][_0xfb0b('0x6a')]===_0xfb0b('0x6b')?![]:!![]);_0x23877a[_0xfb0b('0x5e')](_0x5ca7cb,_0x4b5c23[_0x2e3cfc][_0xfb0b('0x6c')]||_0x5ca7cb);}if(_0x19adbe[_0xfb0b('0x6d')]){_0x19adbe['joins']=JSON[_0xfb0b('0x6e')](_0x19adbe['joins']);for(var _0x50ade7=0x0;_0x50ade7<_0x19adbe[_0xfb0b('0x6d')][_0xfb0b('0x30')];_0x50ade7+=0x1){if(_0x19adbe[_0xfb0b('0x6d')][_0x50ade7][_0xfb0b('0x28')]&&_[_0xfb0b('0x6f')](_0x18dbee,_0x19adbe['joins'][_0x50ade7][_0xfb0b('0x28')])&&_0x19adbe['joins'][_0x50ade7]['parentKey']&&_0x19adbe[_0xfb0b('0x6d')][_0x50ade7][_0xfb0b('0x70')]&&_0x19adbe[_0xfb0b('0x6d')][_0x50ade7][_0xfb0b('0x71')]){_0x23877a[_0x19adbe['joins'][_0x50ade7][_0xfb0b('0x28')]](_0x19adbe[_0xfb0b('0x6d')][_0x50ade7][_0xfb0b('0x70')],null,util['format'](_0xfb0b('0x72'),_0x19adbe['table'],_0x19adbe[_0xfb0b('0x6d')][_0x50ade7][_0xfb0b('0x73')],_0x19adbe[_0xfb0b('0x6d')][_0x50ade7]['foreignTable'],_0x19adbe['joins'][_0x50ade7][_0xfb0b('0x71')]));}}}if(_0x19adbe[_0xfb0b('0x74')]){_0x19adbe[_0xfb0b('0x74')]=JSON['parse'](_0x19adbe['conditions']);_0x23877a[_0xfb0b('0x36')](_0x5d0dc9(_0x19adbe['conditions'][_0xfb0b('0x5d')]));}_0xbead04=_0x23877a['clone']();_0x23877a[_0xfb0b('0x33')](_0x21e5b9);_0x23877a['offset'](0x0);logger[_0xfb0b('0x75')](_0xfb0b('0x76'),_0x23877a[_0xfb0b('0x77')]());return db['sequelize'][_0xfb0b('0x2a')](_0x23877a[_0xfb0b('0x77')](),{'type':db[_0xfb0b('0x78')][_0xfb0b('0x79')][_0xfb0b('0x7a')]});}})[_0xfb0b('0x1f')](respondWithResult(_0x57eba3,null))[_0xfb0b('0x40')](handleError(_0x57eba3,null));};function runReport(_0x266705,_0x10046a,_0x5b4c0a){var _0x10bcaa=_0x10046a['name'];var _0x5a6f90=0xa;var _0x1e1dc1=[_0xfb0b('0x4d'),_0xfb0b('0x4e'),_0xfb0b('0x4f'),_0xfb0b('0x7b')];var _0x42222e={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':_0xfb0b('0x51'),'MAX':_0xfb0b('0x52'),'MIN':'MIN(%s)','AVG':_0xfb0b('0x7c'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xfb0b('0x7d'),'GROUP_CONCAT DESC':_0xfb0b('0x54')};var _0x2c87ec={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xfb0b('0x7e'),'HOUR':_0xfb0b('0x7f'),'ROUND':_0xfb0b('0x56'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x1433db=function(_0x4a784f){return!_['includes']([_0xfb0b('0x58'),_0xfb0b('0x80'),_0xfb0b('0x59'),_0xfb0b('0x5a')],_0x4a784f);};var _0x32233a=function(_0x3ff3d1){if(!_0x3ff3d1||!_0x3ff3d1[_0xfb0b('0x5b')]['length']){return'';}for(var _0x101f16='(',_0x40ee72=0x0;_0x40ee72<_0x3ff3d1['rules'][_0xfb0b('0x30')];_0x40ee72+=0x1){_0x40ee72>0x0&&(_0x101f16+='\x20'+_0x3ff3d1['operator']+'\x20');_0x101f16+=_0x3ff3d1[_0xfb0b('0x5b')][_0x40ee72][_0xfb0b('0x5d')]?_0x32233a(_0x3ff3d1[_0xfb0b('0x5b')][_0x40ee72][_0xfb0b('0x5d')]):_0x3ff3d1[_0xfb0b('0x5b')][_0x40ee72]['field']+'\x20'+_0x3ff3d1['rules'][_0x40ee72]['condition']+(_0x1433db(_0x3ff3d1[_0xfb0b('0x5b')][_0x40ee72][_0xfb0b('0x5f')])?'\x20'+_0x3ff3d1[_0xfb0b('0x5b')][_0x40ee72][_0xfb0b('0x81')]:'');}return _0x101f16+')';};var _0x37faac={'where':{'id':_0x266705['id']}},_0x4a2ffc,_0x156801,_0x3ae6c0,_0x4c9b5b,_0x1f5ef1;_0x37faac=_[_0xfb0b('0x3a')]({},_0x37faac,_0x5b4c0a);return db[_0xfb0b('0x27')][_0xfb0b('0x43')](_0x37faac)[_0xfb0b('0x1f')](function(_0x3485ef){if(_0x3485ef){_0x4a2ffc=_0x3485ef;return _0x3485ef[_0xfb0b('0x60')]();}return null;})[_0xfb0b('0x1f')](function(_0x1f269f){if(_0x1f269f){if(!_0x1f269f[_0xfb0b('0x30')]){throw new db[(_0xfb0b('0x61'))][(_0xfb0b('0x82'))](_0xfb0b('0x83'),0x193);}_0x156801=_0x1f269f;return db[_0xfb0b('0x84')][_0xfb0b('0x3e')]({'raw':!![]});}return null;})[_0xfb0b('0x1f')](function(_0x6ab275){if(_0x6ab275){_0x3ae6c0=_[_0xfb0b('0x62')](_0x6ab275,'id');var _0x3ea7b7;var _0x1d9c95=squel[_0xfb0b('0x63')]();_0x1d9c95[_0xfb0b('0x85')](_0x4a2ffc[_0xfb0b('0x64')]);for(var _0x1acbb4=0x0;_0x1acbb4<_0x156801['length'];_0x1acbb4+=0x1){_0x3ea7b7=_0x156801[_0x1acbb4][_0xfb0b('0x65')]?_0x3ae6c0[_0x156801[_0x1acbb4][_0xfb0b('0x65')]]['metric']:_0x156801[_0x1acbb4][_0xfb0b('0x5e')];_0x3ea7b7=_0x156801[_0x1acbb4][_0xfb0b('0x67')]?_[_0xfb0b('0x69')](_0x42222e[_0x156801[_0x1acbb4][_0xfb0b('0x67')]],'%s',_0x3ea7b7):_0x3ea7b7;_0x3ea7b7=_0x156801[_0x1acbb4]['format']?_[_0xfb0b('0x69')](_0x2c87ec[_0x156801[_0x1acbb4][_0xfb0b('0x68')]],'%s',_0x3ea7b7):_0x3ea7b7;if(_0x156801[_0x1acbb4][_0xfb0b('0x86')]){_0x1d9c95[_0xfb0b('0x5d')](_0x3ea7b7);}_0x156801[_0x1acbb4][_0xfb0b('0x6a')]&&_0x1d9c95[_0xfb0b('0x34')](_0x3ea7b7,_0x156801[_0x1acbb4][_0xfb0b('0x6a')]===_0xfb0b('0x6b')?![]:!![]);_0x1d9c95[_0xfb0b('0x5e')](_0x3ea7b7,_0x156801[_0x1acbb4]['alias']||_0x3ea7b7);}if(_0x4a2ffc[_0xfb0b('0x6d')]){_0x4a2ffc[_0xfb0b('0x6d')]=JSON[_0xfb0b('0x6e')](_0x4a2ffc[_0xfb0b('0x6d')]);for(var _0x1dd73b=0x0;_0x1dd73b<_0x4a2ffc[_0xfb0b('0x6d')][_0xfb0b('0x30')];_0x1dd73b+=0x1){if(_0x4a2ffc[_0xfb0b('0x6d')][_0x1dd73b][_0xfb0b('0x28')]&&_[_0xfb0b('0x6f')](_0x1e1dc1,_0x4a2ffc[_0xfb0b('0x6d')][_0x1dd73b][_0xfb0b('0x28')])&&_0x4a2ffc[_0xfb0b('0x6d')][_0x1dd73b]['parentKey']&&_0x4a2ffc['joins'][_0x1dd73b][_0xfb0b('0x70')]&&_0x4a2ffc['joins'][_0x1dd73b]['foreignKey']){_0x1d9c95[_0x4a2ffc['joins'][_0x1dd73b]['type']](_0x4a2ffc[_0xfb0b('0x6d')][_0x1dd73b]['foreignTable'],null,util[_0xfb0b('0x68')](_0xfb0b('0x72'),_0x4a2ffc['table'],_0x4a2ffc[_0xfb0b('0x6d')][_0x1dd73b][_0xfb0b('0x73')],_0x4a2ffc[_0xfb0b('0x6d')][_0x1dd73b][_0xfb0b('0x70')],_0x4a2ffc[_0xfb0b('0x6d')][_0x1dd73b][_0xfb0b('0x71')]));}}}if(_0x4a2ffc[_0xfb0b('0x74')]){_0x4a2ffc[_0xfb0b('0x74')]=JSON[_0xfb0b('0x6e')](_0x4a2ffc[_0xfb0b('0x74')]);_0x1d9c95[_0xfb0b('0x36')](_0x32233a(_0x4a2ffc['conditions'][_0xfb0b('0x5d')]));}_0x1f5ef1=_0x1d9c95[_0xfb0b('0x87')]();_0x1d9c95[_0xfb0b('0x33')](_0x5a6f90);_0x1d9c95['offset'](0x0);logger[_0xfb0b('0x75')]('Limited\x20Query:',_0x1d9c95[_0xfb0b('0x77')]());return db[_0xfb0b('0x78')][_0xfb0b('0x2a')](_0x1d9c95[_0xfb0b('0x77')](),{'type':db[_0xfb0b('0x78')][_0xfb0b('0x79')]['SELECT']});}})['then'](function(_0x4e88ff){if(!_0x4e88ff[_0xfb0b('0x30')]){throw new db['Sequelize'][(_0xfb0b('0x82'))](_0xfb0b('0x88'),0xcc);}if(_0x10046a[_0xfb0b('0x89')]===_0xfb0b('0x8a')){return null;}var _0x515b5b=_[_0xfb0b('0x3a')](_0x10046a,{'name':_0x10046a[_0xfb0b('0x8b')]||_0x10046a[_0xfb0b('0x24')]||_0x4a2ffc[_0xfb0b('0x24')],'basename':_0x10bcaa,'savename':util[_0xfb0b('0x68')](_0xfb0b('0x8c'),_0x10046a[_0xfb0b('0x24')]||_0x4a2ffc[_0xfb0b('0x24')],require('randomstring')[_0xfb0b('0x8d')](0x4),_0x10046a[_0xfb0b('0x89')]||_0xfb0b('0x8e')),'reportId':_0x4a2ffc['id'],'reportType':_0xfb0b('0x8f')});return db[_0xfb0b('0x90')][_0xfb0b('0x44')](_0x515b5b,{'raw':!![]});})[_0xfb0b('0x1f')](function(_0x35d187){if(_0x4a2ffc[_0xfb0b('0x64')]===_0xfb0b('0x91')){_0x1f5ef1['where'](_0x4a2ffc['table']+_0xfb0b('0x92'),_0x10046a[_0xfb0b('0x93')],_0x10046a[_0xfb0b('0x94')]);}else{_0x1f5ef1[_0xfb0b('0x36')](_0x4a2ffc[_0xfb0b('0x64')]+_0xfb0b('0x95'),_0x10046a['startDate'],_0x10046a['endDate']);}if(_0x35d187){logger[_0xfb0b('0x96')](_0xfb0b('0x97'),_0x1f5ef1['toString']());require('child_process')[_0xfb0b('0x98')](path[_0xfb0b('0x4d')](__dirname,_0xfb0b('0x99'),_0x35d187['output']),[_0x35d187['id'],_0x1f5ef1['toString'](),path[_0xfb0b('0x4d')](__dirname,_0xfb0b('0x9a'),_0x35d187['savename']),_0x10bcaa]);return _0x35d187;}else{var _0x3002d9=squel[_0xfb0b('0x63')]();_0x3002d9[_0xfb0b('0x85')]('('+_0x1f5ef1['toString']()+')','countTable');_0x3002d9[_0xfb0b('0x5e')](_0xfb0b('0x9b'),_0xfb0b('0x17'));_0x1f5ef1[_0xfb0b('0x33')](_0x10046a[_0xfb0b('0x33')]||_0x5a6f90);_0x1f5ef1[_0xfb0b('0x18')](_0x10046a[_0xfb0b('0x18')]||0x0);return dbH[_0xfb0b('0x78')]['query'](_0x3002d9['toString'](),{'type':dbH[_0xfb0b('0x78')][_0xfb0b('0x79')][_0xfb0b('0x7a')]})['then'](function(_0x506e02){if(!_0x506e02[_0xfb0b('0x30')]){_0x4c9b5b=0x0;}else{_0x4c9b5b=_0x506e02[0x0][_0xfb0b('0x17')]||0x0;}return dbH[_0xfb0b('0x78')][_0xfb0b('0x2a')](_0x1f5ef1['toString'](),{'type':dbH[_0xfb0b('0x78')][_0xfb0b('0x79')][_0xfb0b('0x7a')]});})['then'](function(_0x1fdf5e){return{'rows':_0x1fdf5e||[],'count':_0x4c9b5b};});}});}exports[_0xfb0b('0x9c')]=function(_0x9d371d,_0x476bbc){return runReport(_0x9d371d[_0xfb0b('0x42')],_0x9d371d[_0xfb0b('0x2a')],_0x9d371d[_0xfb0b('0x3b')])[_0xfb0b('0x1f')](respondWithResult(_0x476bbc,null))['catch'](handleError(_0x476bbc,null));};exports['runReport']=runReport;exports['query']=function(_0x55be33,_0x45db9c){var _0x579160=0xa;var _0x331d0c=[_0xfb0b('0x4d'),_0xfb0b('0x4e'),'right_join',_0xfb0b('0x7b')];var _0x5ecc5c={'SUM':_0xfb0b('0x50'),'COUNT':_0xfb0b('0x9d'),'COUNT DISTINCT':_0xfb0b('0x51'),'MAX':'MAX(%s)','MIN':_0xfb0b('0x53'),'AVG':_0xfb0b('0x7c'),'GROUP_CONCAT':_0xfb0b('0x9e'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xfb0b('0x54')};var _0x16474c={'SEC_TO_TIME':_0xfb0b('0x55'),'DATE':_0xfb0b('0x7e'),'HOUR':_0xfb0b('0x7f'),'ROUND':_0xfb0b('0x56'),'UNIX_TIMESTAMP':_0xfb0b('0x57')};var _0x5b449b=function(_0x4c711f){return!_[_0xfb0b('0x6f')](['IS\x20NULL',_0xfb0b('0x80'),'IS\x20EMPTY',_0xfb0b('0x5a')],_0x4c711f);};var _0x52ed50=function(_0x1313b8){if(!_0x1313b8||!_0x1313b8[_0xfb0b('0x5b')][_0xfb0b('0x30')]){return'';}for(var _0x2fca18='(',_0x1a9392=0x0;_0x1a9392<_0x1313b8[_0xfb0b('0x5b')][_0xfb0b('0x30')];_0x1a9392+=0x1){_0x1a9392>0x0&&(_0x2fca18+='\x20'+_0x1313b8[_0xfb0b('0x5c')]+'\x20');_0x2fca18+=_0x1313b8[_0xfb0b('0x5b')][_0x1a9392]['group']?_0x52ed50(_0x1313b8[_0xfb0b('0x5b')][_0x1a9392]['group']):_0x1313b8['rules'][_0x1a9392][_0xfb0b('0x5e')]+'\x20'+_0x1313b8['rules'][_0x1a9392][_0xfb0b('0x5f')]+(_0x5b449b(_0x1313b8[_0xfb0b('0x5b')][_0x1a9392][_0xfb0b('0x5f')])?'\x20'+_0x1313b8[_0xfb0b('0x5b')][_0x1a9392][_0xfb0b('0x81')]:'');}return _0x2fca18+')';};var _0x552961={'where':{'id':_0x55be33['params']['id']}},_0x3cc797,_0x58ce04,_0x392983,_0x1dd947,_0x32b5d4;_0x552961=_[_0xfb0b('0x3a')]({},_0x552961,_0x55be33[_0xfb0b('0x3b')]);return db[_0xfb0b('0x27')]['find'](_0x552961)[_0xfb0b('0x1f')](function(_0x23efd3){if(_0x23efd3){_0x3cc797=_0x23efd3;return _0x23efd3[_0xfb0b('0x60')]();}return null;})['then'](function(_0x1f7094){if(_0x1f7094){if(!_0x1f7094[_0xfb0b('0x30')]){throw new db['Sequelize'][(_0xfb0b('0x82'))](_0xfb0b('0x83'),0x193);}_0x58ce04=_0x1f7094;return db[_0xfb0b('0x84')][_0xfb0b('0x3e')]({'raw':!![]});}return null;})['then'](function(_0x4c81f7){if(_0x4c81f7){_0x392983=_[_0xfb0b('0x62')](_0x4c81f7,'id');var _0x3eac11;var _0x370879=squel[_0xfb0b('0x63')]();_0x370879[_0xfb0b('0x85')](_0x3cc797[_0xfb0b('0x64')]);for(var _0x5d05e9=0x0;_0x5d05e9<_0x58ce04[_0xfb0b('0x30')];_0x5d05e9+=0x1){_0x3eac11=_0x58ce04[_0x5d05e9]['MetricId']?_0x392983[_0x58ce04[_0x5d05e9]['MetricId']]['metric']:_0x58ce04[_0x5d05e9]['field'];_0x3eac11=_0x58ce04[_0x5d05e9][_0xfb0b('0x67')]?_[_0xfb0b('0x69')](_0x5ecc5c[_0x58ce04[_0x5d05e9]['function']],'%s',_0x3eac11):_0x3eac11;_0x3eac11=_0x58ce04[_0x5d05e9][_0xfb0b('0x68')]?_[_0xfb0b('0x69')](_0x16474c[_0x58ce04[_0x5d05e9][_0xfb0b('0x68')]],'%s',_0x3eac11):_0x3eac11;if(_0x58ce04[_0x5d05e9][_0xfb0b('0x86')]){_0x370879[_0xfb0b('0x5d')](_0x3eac11);}_0x58ce04[_0x5d05e9][_0xfb0b('0x6a')]&&_0x370879[_0xfb0b('0x34')](_0x3eac11,_0x58ce04[_0x5d05e9]['orderBy']===_0xfb0b('0x6b')?![]:!![]);_0x370879[_0xfb0b('0x5e')](_0x3eac11,_0x58ce04[_0x5d05e9][_0xfb0b('0x6c')]||_0x3eac11);}if(_0x3cc797[_0xfb0b('0x6d')]){_0x3cc797['joins']=JSON[_0xfb0b('0x6e')](_0x3cc797[_0xfb0b('0x6d')]);for(var _0x163e62=0x0;_0x163e62<_0x3cc797[_0xfb0b('0x6d')]['length'];_0x163e62+=0x1){if(_0x3cc797[_0xfb0b('0x6d')][_0x163e62][_0xfb0b('0x28')]&&_[_0xfb0b('0x6f')](_0x331d0c,_0x3cc797['joins'][_0x163e62][_0xfb0b('0x28')])&&_0x3cc797[_0xfb0b('0x6d')][_0x163e62][_0xfb0b('0x73')]&&_0x3cc797[_0xfb0b('0x6d')][_0x163e62][_0xfb0b('0x70')]&&_0x3cc797['joins'][_0x163e62][_0xfb0b('0x71')]){_0x370879[_0x3cc797['joins'][_0x163e62]['type']](_0x3cc797[_0xfb0b('0x6d')][_0x163e62]['foreignTable'],null,util[_0xfb0b('0x68')](_0xfb0b('0x72'),_0x3cc797[_0xfb0b('0x64')],_0x3cc797[_0xfb0b('0x6d')][_0x163e62][_0xfb0b('0x73')],_0x3cc797[_0xfb0b('0x6d')][_0x163e62][_0xfb0b('0x70')],_0x3cc797[_0xfb0b('0x6d')][_0x163e62]['foreignKey']));}}}if(_0x3cc797[_0xfb0b('0x74')]){_0x3cc797[_0xfb0b('0x74')]=JSON[_0xfb0b('0x6e')](_0x3cc797[_0xfb0b('0x74')]);_0x370879[_0xfb0b('0x36')](_0x52ed50(_0x3cc797[_0xfb0b('0x74')]['group']));}_0x32b5d4=_0x370879['clone']();_0x370879[_0xfb0b('0x33')](_0x579160);_0x370879['offset'](0x0);logger[_0xfb0b('0x75')]('Limited\x20Query:',_0x370879[_0xfb0b('0x77')]());return db[_0xfb0b('0x78')]['query'](_0x370879[_0xfb0b('0x77')](),{'type':db[_0xfb0b('0x78')][_0xfb0b('0x79')][_0xfb0b('0x7a')]});}})[_0xfb0b('0x1f')](function(){return{'sql':_0x32b5d4[_0xfb0b('0x77')]()};})[_0xfb0b('0x1f')](respondWithResult(_0x45db9c,null))[_0xfb0b('0x40')](handleError(_0x45db9c,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