Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 130c1fc..80ec0d5 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 _0x326f=['order','orderBy','DESC','joins','foreignTable','foreignKey','parentKey','conditions','Limited\x20Query:','toString','sequelize','SELECT','SUM(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','AVG(%s)','UNIX_TIMESTAMP(%s)','operator','AnalyticMetric','select','from','function','parse','%s.%s\x20=\x20%s.%s','output','web','fullPath','%s-%s.%s','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','Run\x20Query:','child_process','fork','join','../../files/reports','savename','countTable','COUNT(*)','QueryTypes','SEC_TO_TIME(%s)','debug','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','dbH','sendStatus','status','json','offset','undefined','count','apply','update','then','get','DefaultReports','UserProfileResource','destroy','end','error','name','send','index','map','AnalyticDefaultReport','fieldName','type','model','query','filters','intersection','attributes','fields','hasOwnProperty','limit','sort','where','pick','filter','merge','options','includeAll','include','findAll','catch','show','params','rawAttributes','keys','length','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','preview','left_join','right_join','cross_join','COUNT(%s)','MIN(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','DATE(%s)','HOUR(%s)','ROUND(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','group','field','condition','value','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','keyBy','table','MetricId','metric','format','replace','groupBy'];(function(_0x4b369d,_0x265eb8){var _0x571a98=function(_0x56341a){while(--_0x56341a){_0x4b369d['push'](_0x4b369d['shift']());}};_0x571a98(++_0x265eb8);}(_0x326f,0xd1));var _0xf326=function(_0x5a83ad,_0x36b446){_0x5a83ad=_0x5a83ad-0x0;var _0x1ce418=_0x326f[_0x5a83ad];return _0x1ce418;};'use strict';var emlformat=require(_0xf326('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xf326('0x1'));var rp=require(_0xf326('0x2'));var moment=require(_0xf326('0x3'));var BPromise=require(_0xf326('0x4'));var Mustache=require(_0xf326('0x5'));var util=require(_0xf326('0x6'));var path=require(_0xf326('0x7'));var sox=require(_0xf326('0x8'));var csv=require(_0xf326('0x9'));var ejs=require(_0xf326('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf326('0xb'));var squel=require(_0xf326('0xc'));var crypto=require(_0xf326('0xd'));var jsforce=require(_0xf326('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf326('0xf'));var Redis=require(_0xf326('0x10'));var authService=require(_0xf326('0x11'));var qs=require(_0xf326('0x12'));var as=require(_0xf326('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf326('0x14'))('api');var utils=require(_0xf326('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf326('0x16'));var db=require('../../mysqldb')['db'];var dbH=require(_0xf326('0x17'))[_0xf326('0x18')];function respondWithStatusCode(_0x4b3966,_0x342fe5){_0x342fe5=_0x342fe5||0xcc;return function(_0x472632){if(_0x472632){return _0x4b3966[_0xf326('0x19')](_0x342fe5);}return _0x4b3966[_0xf326('0x1a')](_0x342fe5)['end']();};}function respondWithResult(_0x45c1b6,_0x5204ee){_0x5204ee=_0x5204ee||0xc8;return function(_0x54bd1a){if(_0x54bd1a){return _0x45c1b6[_0xf326('0x1a')](_0x5204ee)[_0xf326('0x1b')](_0x54bd1a);}};}function respondWithFilteredResult(_0x1f2e5a,_0xa63d1a){return function(_0x292f4b){if(_0x292f4b){var _0x287a2a=typeof _0xa63d1a[_0xf326('0x1c')]===_0xf326('0x1d')&&typeof _0xa63d1a['limit']===_0xf326('0x1d');var _0x453100=_0x292f4b[_0xf326('0x1e')];var _0x31ffb9=_0x287a2a?0x0:_0xa63d1a[_0xf326('0x1c')];var _0x311af0=_0x287a2a?_0x292f4b['count']:_0xa63d1a['offset']+_0xa63d1a['limit'];var _0x16e605;if(_0x311af0>=_0x453100){_0x311af0=_0x453100;_0x16e605=0xc8;}else{_0x16e605=0xce;}_0x1f2e5a[_0xf326('0x1a')](_0x16e605);return _0x1f2e5a['set']('Content-Range',_0x31ffb9+'-'+_0x311af0+'/'+_0x453100)[_0xf326('0x1b')](_0x292f4b);}return null;};}function patchUpdates(_0x4dfa76){return function(_0x5b6d3c){try{jsonpatch[_0xf326('0x1f')](_0x5b6d3c,_0x4dfa76,!![]);}catch(_0x18ead3){return BPromise['reject'](_0x18ead3);}return _0x5b6d3c['save']();};}function saveUpdates(_0x19b8ba,_0xb1efcf){return function(_0x5f21a2){if(_0x5f21a2){return _0x5f21a2[_0xf326('0x20')](_0x19b8ba)[_0xf326('0x21')](function(_0x43c53e){return _0x43c53e;});}return null;};}function removeEntity(_0x295752,_0x17c157){return function(_0x2049ec){if(_0x2049ec){return _0x2049ec['destroy']()['then'](function(){var _0x4f31f6=_0x2049ec[_0xf326('0x22')]({'plain':!![]});var _0x1a2c4e=_0xf326('0x23');return db[_0xf326('0x24')][_0xf326('0x25')]({'where':{'type':_0x1a2c4e,'resourceId':_0x4f31f6['id']}})[_0xf326('0x21')](function(){return _0x2049ec;});})['then'](function(){_0x295752[_0xf326('0x1a')](0xcc)[_0xf326('0x26')]();});}};}function handleEntityNotFound(_0x212d5d,_0x581531){return function(_0x1617d2){if(!_0x1617d2){_0x212d5d['sendStatus'](0x194);}return _0x1617d2;};}function handleError(_0x4a9abf,_0x6a8e89){_0x6a8e89=_0x6a8e89||0x1f4;return function(_0x1ae23a){logger[_0xf326('0x27')](_0x1ae23a['stack']);if(_0x1ae23a[_0xf326('0x28')]){delete _0x1ae23a[_0xf326('0x28')];}_0x4a9abf['status'](_0x6a8e89)[_0xf326('0x29')](_0x1ae23a);};}exports[_0xf326('0x2a')]=function(_0xd77aba,_0x18d110){var _0xa80156={},_0x269be9={},_0x161143={'count':0x0,'rows':[]};var _0x39a1e2=_[_0xf326('0x2b')](db[_0xf326('0x2c')]['rawAttributes'],function(_0x1035ed){return{'name':_0x1035ed[_0xf326('0x2d')],'type':_0x1035ed[_0xf326('0x2e')]['key']};});_0x269be9[_0xf326('0x2f')]=_[_0xf326('0x2b')](_0x39a1e2,_0xf326('0x28'));_0x269be9['query']=_['keys'](_0xd77aba[_0xf326('0x30')]);_0x269be9[_0xf326('0x31')]=_[_0xf326('0x32')](_0x269be9[_0xf326('0x2f')],_0x269be9[_0xf326('0x30')]);_0xa80156[_0xf326('0x33')]=_[_0xf326('0x32')](_0x269be9[_0xf326('0x2f')],qs['fields'](_0xd77aba[_0xf326('0x30')][_0xf326('0x34')]));_0xa80156['attributes']=_0xa80156[_0xf326('0x33')]['length']?_0xa80156[_0xf326('0x33')]:_0x269be9['model'];if(!_0xd77aba['query'][_0xf326('0x35')]('nolimit')){_0xa80156[_0xf326('0x36')]=qs['limit'](_0xd77aba[_0xf326('0x30')][_0xf326('0x36')]);_0xa80156[_0xf326('0x1c')]=qs['offset'](_0xd77aba[_0xf326('0x30')][_0xf326('0x1c')]);}_0xa80156['order']=qs[_0xf326('0x37')](_0xd77aba[_0xf326('0x30')][_0xf326('0x37')]);_0xa80156[_0xf326('0x38')]=qs['filters'](_[_0xf326('0x39')](_0xd77aba[_0xf326('0x30')],_0x269be9[_0xf326('0x31')]),_0x39a1e2);if(_0xd77aba[_0xf326('0x30')][_0xf326('0x3a')]){_0xa80156['where']=_[_0xf326('0x3b')](_0xa80156[_0xf326('0x38')],{'$or':_['map'](_0x39a1e2,function(_0x4dd361){if(_0x4dd361[_0xf326('0x2e')]!=='VIRTUAL'){var _0x55dfa8={};_0x55dfa8[_0x4dd361[_0xf326('0x28')]]={'$like':'%'+_0xd77aba['query'][_0xf326('0x3a')]+'%'};return _0x55dfa8;}})});}_0xa80156=_[_0xf326('0x3b')]({},_0xa80156,_0xd77aba[_0xf326('0x3c')]);var _0x39611e={'where':_0xa80156['where']};return db[_0xf326('0x2c')][_0xf326('0x1e')](_0x39611e)[_0xf326('0x21')](function(_0x365627){_0x161143[_0xf326('0x1e')]=_0x365627;if(_0xd77aba[_0xf326('0x30')][_0xf326('0x3d')]){_0xa80156[_0xf326('0x3e')]=[{'all':!![]}];}return db[_0xf326('0x2c')][_0xf326('0x3f')](_0xa80156);})[_0xf326('0x21')](function(_0x2bab13){_0x161143['rows']=_0x2bab13;return _0x161143;})[_0xf326('0x21')](respondWithFilteredResult(_0x18d110,_0xa80156))[_0xf326('0x40')](handleError(_0x18d110,null));};exports[_0xf326('0x41')]=function(_0x270288,_0x1dd262){var _0x1a2d0d={'raw':!![],'where':{'id':_0x270288[_0xf326('0x42')]['id']}},_0x4f4c51={};_0x4f4c51[_0xf326('0x2f')]=_['keys'](db[_0xf326('0x2c')][_0xf326('0x43')]);_0x4f4c51[_0xf326('0x30')]=_[_0xf326('0x44')](_0x270288[_0xf326('0x30')]);_0x4f4c51['filters']=_['intersection'](_0x4f4c51[_0xf326('0x2f')],_0x4f4c51[_0xf326('0x30')]);_0x1a2d0d['attributes']=_['intersection'](_0x4f4c51[_0xf326('0x2f')],qs[_0xf326('0x34')](_0x270288[_0xf326('0x30')]['fields']));_0x1a2d0d[_0xf326('0x33')]=_0x1a2d0d[_0xf326('0x33')][_0xf326('0x45')]?_0x1a2d0d[_0xf326('0x33')]:_0x4f4c51[_0xf326('0x2f')];if(_0x270288[_0xf326('0x30')][_0xf326('0x3d')]){_0x1a2d0d[_0xf326('0x3e')]=[{'all':!![]}];}_0x1a2d0d=_[_0xf326('0x3b')]({},_0x1a2d0d,_0x270288[_0xf326('0x3c')]);return db[_0xf326('0x2c')][_0xf326('0x46')](_0x1a2d0d)[_0xf326('0x21')](handleEntityNotFound(_0x1dd262,null))[_0xf326('0x21')](respondWithResult(_0x1dd262,null))[_0xf326('0x40')](handleError(_0x1dd262,null));};exports['create']=function(_0x199f8b,_0x1b0e03){return db[_0xf326('0x2c')][_0xf326('0x47')](_0x199f8b['body'],{})[_0xf326('0x21')](function(_0x2f5511){var _0xca88e=_0x199f8b[_0xf326('0x48')]['get']({'plain':!![]});if(!_0xca88e)throw new Error(_0xf326('0x49'));if(_0xca88e[_0xf326('0x4a')]===_0xf326('0x48')){var _0x451ac7=_0x2f5511[_0xf326('0x22')]({'plain':!![]});var _0x4970fb='Reports';return db[_0xf326('0x4b')][_0xf326('0x46')]({'where':{'name':_0x4970fb,'userProfileId':_0xca88e[_0xf326('0x4c')]},'raw':!![]})['then'](function(_0x102fba){if(_0x102fba&&_0x102fba[_0xf326('0x4d')]===0x0){return db[_0xf326('0x24')]['create']({'name':_0x451ac7['name'],'resourceId':_0x451ac7['id'],'type':_0xf326('0x23'),'sectionId':_0x102fba['id']},{})['then'](function(){return _0x2f5511;});}else{return _0x2f5511;}})[_0xf326('0x40')](function(_0x554277){logger[_0xf326('0x27')](_0xf326('0x4e'),_0x554277);throw _0x554277;});}return _0x2f5511;})[_0xf326('0x21')](respondWithResult(_0x1b0e03,0xc9))[_0xf326('0x40')](handleError(_0x1b0e03,null));};exports[_0xf326('0x20')]=function(_0x35d3c8,_0x7f7ece){if(_0x35d3c8['body']['id']){delete _0x35d3c8[_0xf326('0x4f')]['id'];}return db[_0xf326('0x2c')][_0xf326('0x46')]({'where':{'id':_0x35d3c8['params']['id']}})[_0xf326('0x21')](handleEntityNotFound(_0x7f7ece,null))[_0xf326('0x21')](saveUpdates(_0x35d3c8[_0xf326('0x4f')],null))[_0xf326('0x21')](respondWithResult(_0x7f7ece,null))[_0xf326('0x40')](handleError(_0x7f7ece,null));};exports['destroy']=function(_0x161fb3,_0x21eac7){return db[_0xf326('0x2c')][_0xf326('0x46')]({'where':{'id':_0x161fb3['params']['id']}})[_0xf326('0x21')](handleEntityNotFound(_0x21eac7,null))[_0xf326('0x21')](removeEntity(_0x21eac7,null))[_0xf326('0x40')](handleError(_0x21eac7,null));};exports[_0xf326('0x50')]=function(_0x4d3b9e,_0x5be2b1){var _0x18b46e=0xa;var _0x44d2ed=['join',_0xf326('0x51'),_0xf326('0x52'),_0xf326('0x53')];var _0x1258d1={'SUM':'SUM(%s)','COUNT':_0xf326('0x54'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':'MAX(%s)','MIN':_0xf326('0x55'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xf326('0x56'),'GROUP_CONCAT ASC':_0xf326('0x57'),'GROUP_CONCAT DESC':_0xf326('0x58')};var _0x4eef49={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xf326('0x59'),'HOUR':_0xf326('0x5a'),'ROUND':_0xf326('0x5b'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x2759d7=function(_0x487020){return!_[_0xf326('0x5c')]([_0xf326('0x5d'),_0xf326('0x5e'),_0xf326('0x5f'),_0xf326('0x60')],_0x487020);};var _0x18dbfc=function(_0x23a9e8){if(!_0x23a9e8||!_0x23a9e8[_0xf326('0x61')][_0xf326('0x45')]){return'';}for(var _0x33f9dd='(',_0x33ffb8=0x0;_0x33ffb8<_0x23a9e8[_0xf326('0x61')][_0xf326('0x45')];_0x33ffb8+=0x1){_0x33ffb8>0x0&&(_0x33f9dd+='\x20'+_0x23a9e8['operator']+'\x20');_0x33f9dd+=_0x23a9e8[_0xf326('0x61')][_0x33ffb8]['group']?_0x18dbfc(_0x23a9e8[_0xf326('0x61')][_0x33ffb8][_0xf326('0x62')]):_0x23a9e8['rules'][_0x33ffb8][_0xf326('0x63')]+'\x20'+_0x23a9e8['rules'][_0x33ffb8][_0xf326('0x64')]+(_0x2759d7(_0x23a9e8[_0xf326('0x61')][_0x33ffb8][_0xf326('0x64')])?'\x20'+_0x23a9e8[_0xf326('0x61')][_0x33ffb8][_0xf326('0x65')]:'');}return _0x33f9dd+')';};var _0x51ff5e={'where':{'id':_0x4d3b9e[_0xf326('0x42')]['id']}},_0x4ec099,_0x1209ca,_0x32fe3a,_0x15a538,_0x21b3cc;_0x51ff5e=_['merge']({},_0x51ff5e,_0x4d3b9e[_0xf326('0x3c')]);return db[_0xf326('0x2c')]['find'](_0x51ff5e)['then'](function(_0x5b25ca){if(_0x5b25ca){_0x4ec099=_0x5b25ca;return _0x5b25ca[_0xf326('0x66')]();}return null;})[_0xf326('0x21')](function(_0x4150fa){if(_0x4150fa){if(!_0x4150fa[_0xf326('0x45')]){throw new db[(_0xf326('0x67'))][(_0xf326('0x68'))](_0xf326('0x69'),0x193);}_0x1209ca=_0x4150fa;return db['AnalyticMetric'][_0xf326('0x3f')]({'raw':!![]});}return null;})[_0xf326('0x21')](function(_0x3c3379){if(_0x3c3379){_0x32fe3a=_[_0xf326('0x6a')](_0x3c3379,'id');var _0x58de1e;var _0x3717fe=squel['select']();_0x3717fe['from'](_0x4ec099[_0xf326('0x6b')]);for(var _0x540fa0=0x0;_0x540fa0<_0x1209ca[_0xf326('0x45')];_0x540fa0+=0x1){_0x58de1e=_0x1209ca[_0x540fa0][_0xf326('0x6c')]?_0x32fe3a[_0x1209ca[_0x540fa0][_0xf326('0x6c')]][_0xf326('0x6d')]:_0x1209ca[_0x540fa0][_0xf326('0x63')];_0x58de1e=_0x1209ca[_0x540fa0]['function']?_['replace'](_0x1258d1[_0x1209ca[_0x540fa0]['function']],'%s',_0x58de1e):_0x58de1e;_0x58de1e=_0x1209ca[_0x540fa0][_0xf326('0x6e')]?_[_0xf326('0x6f')](_0x4eef49[_0x1209ca[_0x540fa0][_0xf326('0x6e')]],'%s',_0x58de1e):_0x58de1e;if(_0x1209ca[_0x540fa0][_0xf326('0x70')]){_0x3717fe[_0xf326('0x62')](_0x58de1e);}_0x1209ca[_0x540fa0]['orderBy']&&_0x3717fe[_0xf326('0x71')](_0x58de1e,_0x1209ca[_0x540fa0][_0xf326('0x72')]===_0xf326('0x73')?![]:!![]);_0x3717fe['field'](_0x58de1e,_0x1209ca[_0x540fa0]['alias']||_0x58de1e);}if(_0x4ec099[_0xf326('0x74')]){_0x4ec099[_0xf326('0x74')]=JSON['parse'](_0x4ec099['joins']);for(var _0x2497fd=0x0;_0x2497fd<_0x4ec099['joins'][_0xf326('0x45')];_0x2497fd+=0x1){if(_0x4ec099['joins'][_0x2497fd]['type']&&_['includes'](_0x44d2ed,_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x2e')])&&_0x4ec099[_0xf326('0x74')][_0x2497fd]['parentKey']&&_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x75')]&&_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x76')]){_0x3717fe[_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x2e')]](_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x75')],null,util[_0xf326('0x6e')]('%s.%s\x20=\x20%s.%s',_0x4ec099[_0xf326('0x6b')],_0x4ec099['joins'][_0x2497fd][_0xf326('0x77')],_0x4ec099[_0xf326('0x74')][_0x2497fd][_0xf326('0x75')],_0x4ec099['joins'][_0x2497fd][_0xf326('0x76')]));}}}if(_0x4ec099[_0xf326('0x78')]){_0x4ec099[_0xf326('0x78')]=JSON['parse'](_0x4ec099[_0xf326('0x78')]);_0x3717fe[_0xf326('0x38')](_0x18dbfc(_0x4ec099[_0xf326('0x78')][_0xf326('0x62')]));}_0x21b3cc=_0x3717fe['clone']();_0x3717fe[_0xf326('0x36')](_0x18b46e);_0x3717fe['offset'](0x0);logger['debug'](_0xf326('0x79'),_0x3717fe[_0xf326('0x7a')]());return dbH['sequelize']['query'](_0x3717fe['toString'](),{'type':dbH[_0xf326('0x7b')]['QueryTypes'][_0xf326('0x7c')]});}})[_0xf326('0x21')](respondWithResult(_0x5be2b1,null))[_0xf326('0x40')](handleError(_0x5be2b1,null));};function runReport(_0x2ec314,_0xf76a89,_0x25b56c){var _0x5d23f0=_0xf76a89[_0xf326('0x28')];var _0x323926=0xa;var _0x5f1724=['join',_0xf326('0x51'),'right_join',_0xf326('0x53')];var _0x147d51={'SUM':_0xf326('0x7d'),'COUNT':_0xf326('0x54'),'COUNT DISTINCT':_0xf326('0x7e'),'MAX':_0xf326('0x7f'),'MIN':_0xf326('0x55'),'AVG':_0xf326('0x80'),'GROUP_CONCAT':_0xf326('0x56'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xf326('0x58')};var _0x26bbb1={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xf326('0x59'),'HOUR':'HOUR(%s)','ROUND':_0xf326('0x5b'),'UNIX_TIMESTAMP':_0xf326('0x81')};var _0x14e8c0=function(_0x5814ad){return!_[_0xf326('0x5c')]([_0xf326('0x5d'),_0xf326('0x5e'),_0xf326('0x5f'),_0xf326('0x60')],_0x5814ad);};var _0x1e50aa=function(_0x148779){if(!_0x148779||!_0x148779[_0xf326('0x61')][_0xf326('0x45')]){return'';}for(var _0x38b696='(',_0x384b46=0x0;_0x384b46<_0x148779[_0xf326('0x61')][_0xf326('0x45')];_0x384b46+=0x1){_0x384b46>0x0&&(_0x38b696+='\x20'+_0x148779[_0xf326('0x82')]+'\x20');_0x38b696+=_0x148779[_0xf326('0x61')][_0x384b46]['group']?_0x1e50aa(_0x148779[_0xf326('0x61')][_0x384b46][_0xf326('0x62')]):_0x148779['rules'][_0x384b46][_0xf326('0x63')]+'\x20'+_0x148779[_0xf326('0x61')][_0x384b46]['condition']+(_0x14e8c0(_0x148779[_0xf326('0x61')][_0x384b46][_0xf326('0x64')])?'\x20'+_0x148779[_0xf326('0x61')][_0x384b46][_0xf326('0x65')]:'');}return _0x38b696+')';};var _0x2ab607={'where':{'id':_0x2ec314['id']}},_0x35c228,_0x1bb7cc,_0x5794d0,_0x15d61e,_0x107c00;_0x2ab607=_[_0xf326('0x3b')]({},_0x2ab607,_0x25b56c);return db[_0xf326('0x2c')][_0xf326('0x46')](_0x2ab607)[_0xf326('0x21')](function(_0x204002){if(_0x204002){_0x35c228=_0x204002;return _0x204002[_0xf326('0x66')]();}return null;})['then'](function(_0xa8e05b){if(_0xa8e05b){if(!_0xa8e05b[_0xf326('0x45')]){throw new db['Sequelize'][(_0xf326('0x68'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x1bb7cc=_0xa8e05b;return db[_0xf326('0x83')][_0xf326('0x3f')]({'raw':!![]});}return null;})[_0xf326('0x21')](function(_0x2a0f36){if(_0x2a0f36){_0x5794d0=_[_0xf326('0x6a')](_0x2a0f36,'id');var _0x3097cf;var _0xf66b70=squel[_0xf326('0x84')]();_0xf66b70[_0xf326('0x85')](_0x35c228[_0xf326('0x6b')]);for(var _0x3f073c=0x0;_0x3f073c<_0x1bb7cc[_0xf326('0x45')];_0x3f073c+=0x1){_0x3097cf=_0x1bb7cc[_0x3f073c][_0xf326('0x6c')]?_0x5794d0[_0x1bb7cc[_0x3f073c][_0xf326('0x6c')]]['metric']:_0x1bb7cc[_0x3f073c][_0xf326('0x63')];_0x3097cf=_0x1bb7cc[_0x3f073c][_0xf326('0x86')]?_[_0xf326('0x6f')](_0x147d51[_0x1bb7cc[_0x3f073c][_0xf326('0x86')]],'%s',_0x3097cf):_0x3097cf;_0x3097cf=_0x1bb7cc[_0x3f073c][_0xf326('0x6e')]?_['replace'](_0x26bbb1[_0x1bb7cc[_0x3f073c][_0xf326('0x6e')]],'%s',_0x3097cf):_0x3097cf;if(_0x1bb7cc[_0x3f073c][_0xf326('0x70')]){_0xf66b70[_0xf326('0x62')](_0x3097cf);}_0x1bb7cc[_0x3f073c][_0xf326('0x72')]&&_0xf66b70[_0xf326('0x71')](_0x3097cf,_0x1bb7cc[_0x3f073c]['orderBy']==='DESC'?![]:!![]);_0xf66b70[_0xf326('0x63')](_0x3097cf,_0x1bb7cc[_0x3f073c]['alias']||_0x3097cf);}if(_0x35c228[_0xf326('0x74')]){_0x35c228[_0xf326('0x74')]=JSON[_0xf326('0x87')](_0x35c228['joins']);for(var _0x54b023=0x0;_0x54b023<_0x35c228[_0xf326('0x74')][_0xf326('0x45')];_0x54b023+=0x1){if(_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x2e')]&&_[_0xf326('0x5c')](_0x5f1724,_0x35c228['joins'][_0x54b023][_0xf326('0x2e')])&&_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x77')]&&_0x35c228['joins'][_0x54b023]['foreignTable']&&_0x35c228['joins'][_0x54b023][_0xf326('0x76')]){_0xf66b70[_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x2e')]](_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x75')],null,util[_0xf326('0x6e')](_0xf326('0x88'),_0x35c228['table'],_0x35c228['joins'][_0x54b023][_0xf326('0x77')],_0x35c228[_0xf326('0x74')][_0x54b023][_0xf326('0x75')],_0x35c228['joins'][_0x54b023][_0xf326('0x76')]));}}}if(_0x35c228[_0xf326('0x78')]){_0x35c228[_0xf326('0x78')]=JSON['parse'](_0x35c228[_0xf326('0x78')]);_0xf66b70[_0xf326('0x38')](_0x1e50aa(_0x35c228[_0xf326('0x78')][_0xf326('0x62')]));}_0x107c00=_0xf66b70['clone']();_0xf66b70['limit'](_0x323926);_0xf66b70['offset'](0x0);return;}})[_0xf326('0x21')](function(){if(_0xf76a89[_0xf326('0x89')]===_0xf326('0x8a')){return null;}var _0x5f0b45=_[_0xf326('0x3b')](_0xf76a89,{'name':_0xf76a89[_0xf326('0x8b')]||_0xf76a89[_0xf326('0x28')]||_0x35c228['name'],'basename':_0x5d23f0,'savename':util[_0xf326('0x6e')](_0xf326('0x8c'),_0xf76a89[_0xf326('0x28')]||_0x35c228[_0xf326('0x28')],require('randomstring')[_0xf326('0x8d')](0x4),_0xf76a89['output']||_0xf326('0x8e')),'reportId':_0x35c228['id'],'reportType':_0xf326('0x8f')});return db[_0xf326('0x90')][_0xf326('0x47')](_0x5f0b45,{'raw':!![]});})['then'](function(_0x2e2f70){if(_0x35c228['table']===_0xf326('0x91')){_0x107c00[_0xf326('0x38')](_0x35c228[_0xf326('0x6b')]+_0xf326('0x92'),_0xf76a89[_0xf326('0x93')],_0xf76a89['endDate']);}else{_0x107c00['where'](_0x35c228[_0xf326('0x6b')]+_0xf326('0x94'),_0xf76a89[_0xf326('0x93')],_0xf76a89[_0xf326('0x95')]);}if(_0x2e2f70){logger['info'](_0xf326('0x96'),_0x107c00['toString']());require(_0xf326('0x97'))[_0xf326('0x98')](path[_0xf326('0x99')](__dirname,'../../components/export/',_0x2e2f70[_0xf326('0x89')]),[_0x2e2f70['id'],_0x107c00[_0xf326('0x7a')](),path[_0xf326('0x99')](__dirname,_0xf326('0x9a'),_0x2e2f70[_0xf326('0x9b')]),_0x5d23f0]);return _0x2e2f70;}else{var _0x4dc4bc=squel[_0xf326('0x84')]();_0x4dc4bc[_0xf326('0x85')]('('+_0x107c00['toString']()+')',_0xf326('0x9c'));_0x4dc4bc[_0xf326('0x63')](_0xf326('0x9d'),_0xf326('0x1e'));_0x107c00['limit'](_0xf76a89['limit']||_0x323926);_0x107c00[_0xf326('0x1c')](_0xf76a89[_0xf326('0x1c')]||0x0);return dbH['sequelize'][_0xf326('0x30')](_0x4dc4bc['toString'](),{'type':dbH['sequelize'][_0xf326('0x9e')][_0xf326('0x7c')]})[_0xf326('0x21')](function(_0x37cd6f){if(!_0x37cd6f[_0xf326('0x45')]){_0x15d61e=0x0;}else{_0x15d61e=_0x37cd6f[0x0][_0xf326('0x1e')]||0x0;}return dbH[_0xf326('0x7b')][_0xf326('0x30')](_0x107c00[_0xf326('0x7a')](),{'type':dbH['sequelize'][_0xf326('0x9e')][_0xf326('0x7c')]});})[_0xf326('0x21')](function(_0x1c7f81){return{'rows':_0x1c7f81||[],'count':_0x15d61e};});}});}exports['run']=function(_0x3e6a5d,_0x20020c){return runReport(_0x3e6a5d[_0xf326('0x42')],_0x3e6a5d[_0xf326('0x30')],_0x3e6a5d[_0xf326('0x3c')])['then'](respondWithResult(_0x20020c,null))[_0xf326('0x40')](handleError(_0x20020c,null));};exports['runReport']=runReport;exports[_0xf326('0x30')]=function(_0x14d255,_0xffd165){var _0x2bc501=0xa;var _0x4bd216=[_0xf326('0x99'),_0xf326('0x51'),_0xf326('0x52'),'cross_join'];var _0x23451e={'SUM':_0xf326('0x7d'),'COUNT':_0xf326('0x54'),'COUNT DISTINCT':_0xf326('0x7e'),'MAX':'MAX(%s)','MIN':_0xf326('0x55'),'AVG':_0xf326('0x80'),'GROUP_CONCAT':_0xf326('0x56'),'GROUP_CONCAT ASC':_0xf326('0x57'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x310223={'SEC_TO_TIME':_0xf326('0x9f'),'DATE':_0xf326('0x59'),'HOUR':'HOUR(%s)','ROUND':_0xf326('0x5b'),'UNIX_TIMESTAMP':_0xf326('0x81')};var _0x539d23=function(_0x171c53){return!_[_0xf326('0x5c')]([_0xf326('0x5d'),_0xf326('0x5e'),_0xf326('0x5f'),_0xf326('0x60')],_0x171c53);};var _0x4c7fc0=function(_0x4ffde1){if(!_0x4ffde1||!_0x4ffde1[_0xf326('0x61')][_0xf326('0x45')]){return'';}for(var _0x4307d9='(',_0x2fa05b=0x0;_0x2fa05b<_0x4ffde1[_0xf326('0x61')][_0xf326('0x45')];_0x2fa05b+=0x1){_0x2fa05b>0x0&&(_0x4307d9+='\x20'+_0x4ffde1['operator']+'\x20');_0x4307d9+=_0x4ffde1[_0xf326('0x61')][_0x2fa05b][_0xf326('0x62')]?_0x4c7fc0(_0x4ffde1[_0xf326('0x61')][_0x2fa05b][_0xf326('0x62')]):_0x4ffde1[_0xf326('0x61')][_0x2fa05b][_0xf326('0x63')]+'\x20'+_0x4ffde1[_0xf326('0x61')][_0x2fa05b][_0xf326('0x64')]+(_0x539d23(_0x4ffde1[_0xf326('0x61')][_0x2fa05b]['condition'])?'\x20'+_0x4ffde1[_0xf326('0x61')][_0x2fa05b]['value']:'');}return _0x4307d9+')';};var _0x590dc0={'where':{'id':_0x14d255[_0xf326('0x42')]['id']}},_0x32fc6e,_0x549a1f,_0x1f37f9,_0x3e0918,_0x3398fd;_0x590dc0=_[_0xf326('0x3b')]({},_0x590dc0,_0x14d255[_0xf326('0x3c')]);return db[_0xf326('0x2c')][_0xf326('0x46')](_0x590dc0)[_0xf326('0x21')](function(_0x314442){if(_0x314442){_0x32fc6e=_0x314442;return _0x314442[_0xf326('0x66')]();}return null;})[_0xf326('0x21')](function(_0x4c1fcd){if(_0x4c1fcd){if(!_0x4c1fcd[_0xf326('0x45')]){throw new db[(_0xf326('0x67'))][(_0xf326('0x68'))](_0xf326('0x69'),0x193);}_0x549a1f=_0x4c1fcd;return db[_0xf326('0x83')][_0xf326('0x3f')]({'raw':!![]});}return null;})[_0xf326('0x21')](function(_0x5429a2){if(_0x5429a2){_0x1f37f9=_[_0xf326('0x6a')](_0x5429a2,'id');var _0x15f799;var _0x320ab3=squel[_0xf326('0x84')]();_0x320ab3[_0xf326('0x85')](_0x32fc6e[_0xf326('0x6b')]);for(var _0x2094bf=0x0;_0x2094bf<_0x549a1f['length'];_0x2094bf+=0x1){_0x15f799=_0x549a1f[_0x2094bf][_0xf326('0x6c')]?_0x1f37f9[_0x549a1f[_0x2094bf][_0xf326('0x6c')]][_0xf326('0x6d')]:_0x549a1f[_0x2094bf][_0xf326('0x63')];_0x15f799=_0x549a1f[_0x2094bf][_0xf326('0x86')]?_[_0xf326('0x6f')](_0x23451e[_0x549a1f[_0x2094bf][_0xf326('0x86')]],'%s',_0x15f799):_0x15f799;_0x15f799=_0x549a1f[_0x2094bf][_0xf326('0x6e')]?_[_0xf326('0x6f')](_0x310223[_0x549a1f[_0x2094bf][_0xf326('0x6e')]],'%s',_0x15f799):_0x15f799;if(_0x549a1f[_0x2094bf][_0xf326('0x70')]){_0x320ab3[_0xf326('0x62')](_0x15f799);}_0x549a1f[_0x2094bf]['orderBy']&&_0x320ab3[_0xf326('0x71')](_0x15f799,_0x549a1f[_0x2094bf][_0xf326('0x72')]===_0xf326('0x73')?![]:!![]);_0x320ab3['field'](_0x15f799,_0x549a1f[_0x2094bf]['alias']||_0x15f799);}if(_0x32fc6e[_0xf326('0x74')]){_0x32fc6e[_0xf326('0x74')]=JSON[_0xf326('0x87')](_0x32fc6e[_0xf326('0x74')]);for(var _0x5384a5=0x0;_0x5384a5<_0x32fc6e[_0xf326('0x74')][_0xf326('0x45')];_0x5384a5+=0x1){if(_0x32fc6e[_0xf326('0x74')][_0x5384a5]['type']&&_['includes'](_0x4bd216,_0x32fc6e['joins'][_0x5384a5][_0xf326('0x2e')])&&_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x77')]&&_0x32fc6e['joins'][_0x5384a5][_0xf326('0x75')]&&_0x32fc6e['joins'][_0x5384a5][_0xf326('0x76')]){_0x320ab3[_0x32fc6e['joins'][_0x5384a5][_0xf326('0x2e')]](_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x75')],null,util[_0xf326('0x6e')](_0xf326('0x88'),_0x32fc6e[_0xf326('0x6b')],_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x77')],_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x75')],_0x32fc6e[_0xf326('0x74')][_0x5384a5][_0xf326('0x76')]));}}}if(_0x32fc6e[_0xf326('0x78')]){_0x32fc6e[_0xf326('0x78')]=JSON['parse'](_0x32fc6e[_0xf326('0x78')]);_0x320ab3[_0xf326('0x38')](_0x4c7fc0(_0x32fc6e[_0xf326('0x78')]['group']));}_0x3398fd=_0x320ab3['clone']();_0x320ab3['limit'](_0x2bc501);_0x320ab3[_0xf326('0x1c')](0x0);logger[_0xf326('0xa0')](_0xf326('0x79'),_0x320ab3[_0xf326('0x7a')]());return dbH[_0xf326('0x7b')][_0xf326('0x30')](_0x320ab3['toString'](),{'type':dbH[_0xf326('0x7b')][_0xf326('0x9e')][_0xf326('0x7c')]});}})[_0xf326('0x21')](function(){return{'sql':_0x3398fd[_0xf326('0x7a')]()};})['then'](respondWithResult(_0xffd165,null))[_0xf326('0x40')](handleError(_0xffd165,null));};
\ No newline at end of file