Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 0e0c9e1..29aefdd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x09ca=['query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','where','pick','filter','merge','VIRTUAL','includeAll','include','rows','show','params','rawAttributes','length','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','UserProfileSection','find','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','preview','join','left_join','right_join','cross_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%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\x20NULL','IS\x20NOT\x20NULL','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','value','options','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','findAll','keyBy','select','table','MetricId','metric','function','replace','format','groupBy','orderBy','DESC','alias','joins','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','parse','debug','sequelize','QueryTypes','SELECT','IS\x20EMPTY','AnalyticMetric','from','clone','output','web','generate','default','AnalyticExtractedReport','cdr','startDate','endDate','info','Run\x20Query:','toString','child_process','fork','../../files/reports','savename','countTable','run','runReport','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','dbH','sendStatus','status','json','count','offset','limit','set','apply','reject','save','destroy','then','DefaultReports','UserProfileResource','end','name','send','index','map','AnalyticDefaultReport','fieldName','type','key','model'];(function(_0x5eed04,_0x3fe96c){var _0x1fa16e=function(_0x4959c3){while(--_0x4959c3){_0x5eed04['push'](_0x5eed04['shift']());}};_0x1fa16e(++_0x3fe96c);}(_0x09ca,0x119));var _0xa09c=function(_0x5916a4,_0x446908){_0x5916a4=_0x5916a4-0x0;var _0x3fc12e=_0x09ca[_0x5916a4];return _0x3fc12e;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xa09c('0x0'));var rimraf=require(_0xa09c('0x1'));var zipdir=require(_0xa09c('0x2'));var jsonpatch=require(_0xa09c('0x3'));var rp=require(_0xa09c('0x4'));var moment=require(_0xa09c('0x5'));var BPromise=require(_0xa09c('0x6'));var Mustache=require(_0xa09c('0x7'));var util=require(_0xa09c('0x8'));var path=require(_0xa09c('0x9'));var sox=require(_0xa09c('0xa'));var csv=require(_0xa09c('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xa09c('0xc'));var crypto=require(_0xa09c('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xa09c('0xe'));var toCsv=require(_0xa09c('0xb'));var querystring=require(_0xa09c('0xf'));var Papa=require(_0xa09c('0x10'));var Redis=require(_0xa09c('0x11'));var authService=require(_0xa09c('0x12'));var qs=require(_0xa09c('0x13'));var as=require(_0xa09c('0x14'));var hardwareService=require(_0xa09c('0x15'));var logger=require(_0xa09c('0x16'))(_0xa09c('0x17'));var utils=require('../../config/utils');var config=require(_0xa09c('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xa09c('0x19'))['db'];var dbH=require(_0xa09c('0x19'))[_0xa09c('0x1a')];function respondWithStatusCode(_0x23a2c3,_0x56e1e3){_0x56e1e3=_0x56e1e3||0xcc;return function(_0x4b5905){if(_0x4b5905){return _0x23a2c3[_0xa09c('0x1b')](_0x56e1e3);}return _0x23a2c3[_0xa09c('0x1c')](_0x56e1e3)['end']();};}function respondWithResult(_0x59cd81,_0x4c52dc){_0x4c52dc=_0x4c52dc||0xc8;return function(_0x4f9107){if(_0x4f9107){return _0x59cd81[_0xa09c('0x1c')](_0x4c52dc)[_0xa09c('0x1d')](_0x4f9107);}};}function respondWithFilteredResult(_0x6e8c8f,_0x473dc0){return function(_0x54cf15){if(_0x54cf15){var _0x3e27a7=_0x54cf15[_0xa09c('0x1e')],_0x4db764=_0x473dc0[_0xa09c('0x1f')],_0x2f45a3=_0x473dc0[_0xa09c('0x1f')]+_0x473dc0[_0xa09c('0x20')],_0x4c372e;if(_0x2f45a3>=_0x3e27a7){_0x2f45a3=_0x3e27a7;_0x4c372e=0xc8;}else{_0x4c372e=0xce;}_0x6e8c8f[_0xa09c('0x1c')](_0x4c372e);return _0x6e8c8f[_0xa09c('0x21')]('Content-Range',_0x4db764+'-'+_0x2f45a3+'/'+_0x3e27a7)[_0xa09c('0x1d')](_0x54cf15);}return null;};}function patchUpdates(_0x3e9327){return function(_0x451497){try{jsonpatch[_0xa09c('0x22')](_0x451497,_0x3e9327,!![]);}catch(_0x4ccdf2){return BPromise[_0xa09c('0x23')](_0x4ccdf2);}return _0x451497[_0xa09c('0x24')]();};}function saveUpdates(_0x3e035f,_0x24df25){return function(_0x217886){if(_0x217886){return _0x217886['update'](_0x3e035f)['then'](function(_0x2080ff){return _0x2080ff;});}return null;};}function removeEntity(_0x5795ea,_0x2a6b28){return function(_0x3b3a09){if(_0x3b3a09){return _0x3b3a09[_0xa09c('0x25')]()[_0xa09c('0x26')](function(){var _0x1bed9f=_0x3b3a09['get']({'plain':!![]});var _0x899e33=_0xa09c('0x27');return db[_0xa09c('0x28')][_0xa09c('0x25')]({'where':{'type':_0x899e33,'resourceId':_0x1bed9f['id']}})[_0xa09c('0x26')](function(){return _0x3b3a09;});})['then'](function(){_0x5795ea[_0xa09c('0x1c')](0xcc)[_0xa09c('0x29')]();});}};}function handleEntityNotFound(_0x1192c7,_0xa6a526){return function(_0x4cafde){if(!_0x4cafde){_0x1192c7[_0xa09c('0x1b')](0x194);}return _0x4cafde;};}function handleError(_0x4220f1,_0x5d5e14){_0x5d5e14=_0x5d5e14||0x1f4;return function(_0x2fca5d){logger['error'](_0x2fca5d['stack']);if(_0x2fca5d[_0xa09c('0x2a')]){delete _0x2fca5d['name'];}_0x4220f1[_0xa09c('0x1c')](_0x5d5e14)[_0xa09c('0x2b')](_0x2fca5d);};}exports[_0xa09c('0x2c')]=function(_0x594a48,_0x38f583){var _0x240b85={},_0x463248={},_0x63d144={'count':0x0,'rows':[]};var _0x3543f7=_[_0xa09c('0x2d')](db[_0xa09c('0x2e')]['rawAttributes'],function(_0x124b9c){return{'name':_0x124b9c[_0xa09c('0x2f')],'type':_0x124b9c[_0xa09c('0x30')][_0xa09c('0x31')]};});_0x463248[_0xa09c('0x32')]=_[_0xa09c('0x2d')](_0x3543f7,_0xa09c('0x2a'));_0x463248[_0xa09c('0x33')]=_[_0xa09c('0x34')](_0x594a48['query']);_0x463248[_0xa09c('0x35')]=_[_0xa09c('0x36')](_0x463248['model'],_0x463248[_0xa09c('0x33')]);_0x240b85[_0xa09c('0x37')]=_[_0xa09c('0x36')](_0x463248['model'],qs[_0xa09c('0x38')](_0x594a48[_0xa09c('0x33')][_0xa09c('0x38')]));_0x240b85[_0xa09c('0x37')]=_0x240b85['attributes']['length']?_0x240b85['attributes']:_0x463248['model'];if(!_0x594a48[_0xa09c('0x33')][_0xa09c('0x39')](_0xa09c('0x3a'))){_0x240b85['limit']=qs[_0xa09c('0x20')](_0x594a48[_0xa09c('0x33')]['limit']);_0x240b85[_0xa09c('0x1f')]=qs[_0xa09c('0x1f')](_0x594a48[_0xa09c('0x33')][_0xa09c('0x1f')]);}_0x240b85[_0xa09c('0x3b')]=qs['sort'](_0x594a48[_0xa09c('0x33')]['sort']);_0x240b85[_0xa09c('0x3c')]=qs[_0xa09c('0x35')](_[_0xa09c('0x3d')](_0x594a48[_0xa09c('0x33')],_0x463248['filters']),_0x3543f7);if(_0x594a48[_0xa09c('0x33')][_0xa09c('0x3e')]){_0x240b85[_0xa09c('0x3c')]=_[_0xa09c('0x3f')](_0x240b85[_0xa09c('0x3c')],{'$or':_[_0xa09c('0x2d')](_0x3543f7,function(_0x3ceee9){if(_0x3ceee9['type']!==_0xa09c('0x40')){var _0x4539e4={};_0x4539e4[_0x3ceee9[_0xa09c('0x2a')]]={'$like':'%'+_0x594a48[_0xa09c('0x33')]['filter']+'%'};return _0x4539e4;}})});}_0x240b85=_[_0xa09c('0x3f')]({},_0x240b85,_0x594a48['options']);var _0x516fb2={'where':_0x240b85['where']};return db[_0xa09c('0x2e')]['count'](_0x516fb2)[_0xa09c('0x26')](function(_0x3913f7){_0x63d144['count']=_0x3913f7;if(_0x594a48[_0xa09c('0x33')][_0xa09c('0x41')]){_0x240b85[_0xa09c('0x42')]=[{'all':!![]}];}return db[_0xa09c('0x2e')]['findAll'](_0x240b85);})[_0xa09c('0x26')](function(_0x634e01){_0x63d144[_0xa09c('0x43')]=_0x634e01;return _0x63d144;})['then'](respondWithFilteredResult(_0x38f583,_0x240b85))['catch'](handleError(_0x38f583,null));};exports[_0xa09c('0x44')]=function(_0x4eba98,_0x2a11fd){var _0x4a5c2b={'raw':!![],'where':{'id':_0x4eba98[_0xa09c('0x45')]['id']}},_0x205844={};_0x205844[_0xa09c('0x32')]=_[_0xa09c('0x34')](db[_0xa09c('0x2e')][_0xa09c('0x46')]);_0x205844[_0xa09c('0x33')]=_[_0xa09c('0x34')](_0x4eba98[_0xa09c('0x33')]);_0x205844['filters']=_[_0xa09c('0x36')](_0x205844[_0xa09c('0x32')],_0x205844['query']);_0x4a5c2b[_0xa09c('0x37')]=_[_0xa09c('0x36')](_0x205844['model'],qs[_0xa09c('0x38')](_0x4eba98['query'][_0xa09c('0x38')]));_0x4a5c2b['attributes']=_0x4a5c2b[_0xa09c('0x37')][_0xa09c('0x47')]?_0x4a5c2b['attributes']:_0x205844[_0xa09c('0x32')];if(_0x4eba98[_0xa09c('0x33')][_0xa09c('0x41')]){_0x4a5c2b['include']=[{'all':!![]}];}_0x4a5c2b=_[_0xa09c('0x3f')]({},_0x4a5c2b,_0x4eba98['options']);return db[_0xa09c('0x2e')]['find'](_0x4a5c2b)[_0xa09c('0x26')](handleEntityNotFound(_0x2a11fd,null))['then'](respondWithResult(_0x2a11fd,null))[_0xa09c('0x48')](handleError(_0x2a11fd,null));};exports['create']=function(_0x15307b,_0x16b552){return db[_0xa09c('0x2e')][_0xa09c('0x49')](_0x15307b[_0xa09c('0x4a')],{})[_0xa09c('0x26')](function(_0x5529b3){var _0xcd389f=_0x15307b[_0xa09c('0x4b')][_0xa09c('0x4c')]({'plain':!![]});if(!_0xcd389f)throw new Error(_0xa09c('0x4d'));if(_0xcd389f[_0xa09c('0x4e')]===_0xa09c('0x4b')){var _0x5ac394=_0x5529b3[_0xa09c('0x4c')]({'plain':!![]});var _0x4bf8cd=_0xa09c('0x4f');return db[_0xa09c('0x50')][_0xa09c('0x51')]({'where':{'name':_0x4bf8cd,'userProfileId':_0xcd389f[_0xa09c('0x52')]},'raw':!![]})[_0xa09c('0x26')](function(_0x389fc6){if(_0x389fc6&&_0x389fc6[_0xa09c('0x53')]===0x0){return db['UserProfileResource'][_0xa09c('0x49')]({'name':_0x5ac394[_0xa09c('0x2a')],'resourceId':_0x5ac394['id'],'type':'DefaultReports','sectionId':_0x389fc6['id']},{})[_0xa09c('0x26')](function(){return _0x5529b3;});}else{return _0x5529b3;}})[_0xa09c('0x48')](function(_0x3f0c52){logger[_0xa09c('0x54')](_0xa09c('0x55'),_0x3f0c52);throw _0x3f0c52;});}return _0x5529b3;})['then'](respondWithResult(_0x16b552,0xc9))['catch'](handleError(_0x16b552,null));};exports['update']=function(_0x477ae8,_0x36a94c){if(_0x477ae8[_0xa09c('0x4a')]['id']){delete _0x477ae8[_0xa09c('0x4a')]['id'];}return db['AnalyticDefaultReport']['find']({'where':{'id':_0x477ae8[_0xa09c('0x45')]['id']}})['then'](handleEntityNotFound(_0x36a94c,null))['then'](saveUpdates(_0x477ae8[_0xa09c('0x4a')],null))['then'](respondWithResult(_0x36a94c,null))[_0xa09c('0x48')](handleError(_0x36a94c,null));};exports[_0xa09c('0x25')]=function(_0x241399,_0x2ba59d){return db['AnalyticDefaultReport'][_0xa09c('0x51')]({'where':{'id':_0x241399['params']['id']}})[_0xa09c('0x26')](handleEntityNotFound(_0x2ba59d,null))['then'](removeEntity(_0x2ba59d,null))[_0xa09c('0x48')](handleError(_0x2ba59d,null));};exports[_0xa09c('0x56')]=function(_0x3dd9c5,_0x535dd6){var _0x3ce463=0xa;var _0x571312=[_0xa09c('0x57'),_0xa09c('0x58'),_0xa09c('0x59'),_0xa09c('0x5a')];var _0x3fe6ca={'SUM':_0xa09c('0x5b'),'COUNT':_0xa09c('0x5c'),'COUNT DISTINCT':_0xa09c('0x5d'),'MAX':_0xa09c('0x5e'),'MIN':_0xa09c('0x5f'),'AVG':_0xa09c('0x60'),'GROUP_CONCAT':_0xa09c('0x61'),'GROUP_CONCAT ASC':_0xa09c('0x62'),'GROUP_CONCAT DESC':_0xa09c('0x63')};var _0x3cc8cd={'SEC_TO_TIME':_0xa09c('0x64'),'DATE':_0xa09c('0x65'),'HOUR':_0xa09c('0x66'),'ROUND':_0xa09c('0x67'),'UNIX_TIMESTAMP':_0xa09c('0x68')};var _0x49c190=function(_0x4ef917){return!_[_0xa09c('0x69')]([_0xa09c('0x6a'),_0xa09c('0x6b'),'IS\x20EMPTY',_0xa09c('0x6c')],_0x4ef917);};var _0x5d2905=function(_0x4c093f){if(!_0x4c093f||!_0x4c093f[_0xa09c('0x6d')]['length']){return'';}for(var _0x31b6a8='(',_0x108a6c=0x0;_0x108a6c<_0x4c093f[_0xa09c('0x6d')]['length'];_0x108a6c+=0x1){_0x108a6c>0x0&&(_0x31b6a8+='\x20'+_0x4c093f[_0xa09c('0x6e')]+'\x20');_0x31b6a8+=_0x4c093f[_0xa09c('0x6d')][_0x108a6c][_0xa09c('0x6f')]?_0x5d2905(_0x4c093f['rules'][_0x108a6c][_0xa09c('0x6f')]):_0x4c093f['rules'][_0x108a6c][_0xa09c('0x70')]+'\x20'+_0x4c093f[_0xa09c('0x6d')][_0x108a6c]['condition']+(_0x49c190(_0x4c093f[_0xa09c('0x6d')][_0x108a6c][_0xa09c('0x71')])?'\x20'+_0x4c093f['rules'][_0x108a6c][_0xa09c('0x72')]:'');}return _0x31b6a8+')';};var _0x3e4629={'where':{'id':_0x3dd9c5['params']['id']}},_0x2a7da2,_0x30e85d,_0x1892c4,_0x12668a,_0x4e7d6f;_0x3e4629=_['merge']({},_0x3e4629,_0x3dd9c5[_0xa09c('0x73')]);return db[_0xa09c('0x2e')][_0xa09c('0x51')](_0x3e4629)[_0xa09c('0x26')](function(_0x16ac05){if(_0x16ac05){_0x2a7da2=_0x16ac05;return _0x16ac05[_0xa09c('0x74')]();}return null;})[_0xa09c('0x26')](function(_0x30f853){if(_0x30f853){if(!_0x30f853[_0xa09c('0x47')]){throw new db[(_0xa09c('0x75'))][(_0xa09c('0x76'))](_0xa09c('0x77'),0x193);}_0x30e85d=_0x30f853;return db['AnalyticMetric'][_0xa09c('0x78')]({'raw':!![]});}return null;})['then'](function(_0x3b3a90){if(_0x3b3a90){_0x1892c4=_[_0xa09c('0x79')](_0x3b3a90,'id');var _0x226d13;var _0x5bd521=squel[_0xa09c('0x7a')]();_0x5bd521['from'](_0x2a7da2[_0xa09c('0x7b')]);for(var _0x102668=0x0;_0x102668<_0x30e85d['length'];_0x102668+=0x1){_0x226d13=_0x30e85d[_0x102668]['MetricId']?_0x1892c4[_0x30e85d[_0x102668][_0xa09c('0x7c')]][_0xa09c('0x7d')]:_0x30e85d[_0x102668][_0xa09c('0x70')];_0x226d13=_0x30e85d[_0x102668][_0xa09c('0x7e')]?_[_0xa09c('0x7f')](_0x3fe6ca[_0x30e85d[_0x102668][_0xa09c('0x7e')]],'%s',_0x226d13):_0x226d13;_0x226d13=_0x30e85d[_0x102668][_0xa09c('0x80')]?_[_0xa09c('0x7f')](_0x3cc8cd[_0x30e85d[_0x102668][_0xa09c('0x80')]],'%s',_0x226d13):_0x226d13;if(_0x30e85d[_0x102668][_0xa09c('0x81')]){_0x5bd521[_0xa09c('0x6f')](_0x226d13);}_0x30e85d[_0x102668][_0xa09c('0x82')]&&_0x5bd521[_0xa09c('0x3b')](_0x226d13,_0x30e85d[_0x102668][_0xa09c('0x82')]===_0xa09c('0x83')?![]:!![]);_0x5bd521[_0xa09c('0x70')](_0x226d13,_0x30e85d[_0x102668][_0xa09c('0x84')]||_0x226d13);}if(_0x2a7da2[_0xa09c('0x85')]){_0x2a7da2[_0xa09c('0x85')]=JSON['parse'](_0x2a7da2[_0xa09c('0x85')]);for(var _0x4caa41=0x0;_0x4caa41<_0x2a7da2['joins'][_0xa09c('0x47')];_0x4caa41+=0x1){if(_0x2a7da2[_0xa09c('0x85')][_0x4caa41][_0xa09c('0x30')]&&_[_0xa09c('0x69')](_0x571312,_0x2a7da2[_0xa09c('0x85')][_0x4caa41][_0xa09c('0x30')])&&_0x2a7da2[_0xa09c('0x85')][_0x4caa41][_0xa09c('0x86')]&&_0x2a7da2[_0xa09c('0x85')][_0x4caa41][_0xa09c('0x87')]&&_0x2a7da2[_0xa09c('0x85')][_0x4caa41][_0xa09c('0x88')]){_0x5bd521[_0x2a7da2[_0xa09c('0x85')][_0x4caa41][_0xa09c('0x30')]](_0x2a7da2['joins'][_0x4caa41][_0xa09c('0x87')],null,util['format'](_0xa09c('0x89'),_0x2a7da2[_0xa09c('0x7b')],_0x2a7da2[_0xa09c('0x85')][_0x4caa41]['parentKey'],_0x2a7da2[_0xa09c('0x85')][_0x4caa41][_0xa09c('0x87')],_0x2a7da2[_0xa09c('0x85')][_0x4caa41][_0xa09c('0x88')]));}}}if(_0x2a7da2[_0xa09c('0x8a')]){_0x2a7da2[_0xa09c('0x8a')]=JSON[_0xa09c('0x8b')](_0x2a7da2[_0xa09c('0x8a')]);_0x5bd521[_0xa09c('0x3c')](_0x5d2905(_0x2a7da2[_0xa09c('0x8a')][_0xa09c('0x6f')]));}_0x4e7d6f=_0x5bd521['clone']();_0x5bd521[_0xa09c('0x20')](_0x3ce463);_0x5bd521['offset'](0x0);logger[_0xa09c('0x8c')]('Limited\x20Query:',_0x5bd521['toString']());return dbH[_0xa09c('0x8d')][_0xa09c('0x33')](_0x5bd521['toString'](),{'type':dbH['sequelize'][_0xa09c('0x8e')][_0xa09c('0x8f')]});}})[_0xa09c('0x26')](respondWithResult(_0x535dd6,null))[_0xa09c('0x48')](handleError(_0x535dd6,null));};function runReport(_0x55b09c,_0x50fe25,_0x3e864c){var _0x51ab85=_0x50fe25[_0xa09c('0x2a')];var _0x4be903=0xa;var _0x277ab4=[_0xa09c('0x57'),_0xa09c('0x58'),_0xa09c('0x59'),_0xa09c('0x5a')];var _0x56f39a={'SUM':_0xa09c('0x5b'),'COUNT':_0xa09c('0x5c'),'COUNT DISTINCT':_0xa09c('0x5d'),'MAX':_0xa09c('0x5e'),'MIN':_0xa09c('0x5f'),'AVG':_0xa09c('0x60'),'GROUP_CONCAT':_0xa09c('0x61'),'GROUP_CONCAT ASC':_0xa09c('0x62'),'GROUP_CONCAT DESC':_0xa09c('0x63')};var _0x362037={'SEC_TO_TIME':_0xa09c('0x64'),'DATE':_0xa09c('0x65'),'HOUR':_0xa09c('0x66'),'ROUND':_0xa09c('0x67'),'UNIX_TIMESTAMP':_0xa09c('0x68')};var _0x3dfa2b=function(_0x5eaa4c){return!_[_0xa09c('0x69')]([_0xa09c('0x6a'),'IS\x20NOT\x20NULL',_0xa09c('0x90'),'IS\x20NOT\x20EMPTY'],_0x5eaa4c);};var _0x2ec7f4=function(_0x1a9c24){if(!_0x1a9c24||!_0x1a9c24[_0xa09c('0x6d')]['length']){return'';}for(var _0xcd75c='(',_0x596a46=0x0;_0x596a46<_0x1a9c24[_0xa09c('0x6d')][_0xa09c('0x47')];_0x596a46+=0x1){_0x596a46>0x0&&(_0xcd75c+='\x20'+_0x1a9c24[_0xa09c('0x6e')]+'\x20');_0xcd75c+=_0x1a9c24[_0xa09c('0x6d')][_0x596a46][_0xa09c('0x6f')]?_0x2ec7f4(_0x1a9c24[_0xa09c('0x6d')][_0x596a46][_0xa09c('0x6f')]):_0x1a9c24['rules'][_0x596a46][_0xa09c('0x70')]+'\x20'+_0x1a9c24['rules'][_0x596a46][_0xa09c('0x71')]+(_0x3dfa2b(_0x1a9c24[_0xa09c('0x6d')][_0x596a46]['condition'])?'\x20'+_0x1a9c24[_0xa09c('0x6d')][_0x596a46][_0xa09c('0x72')]:'');}return _0xcd75c+')';};var _0x2ad577={'where':{'id':_0x55b09c['id']}},_0xff3ba5,_0x341e47,_0x54fa81,_0x8edc0f,_0x470cfb;_0x2ad577=_[_0xa09c('0x3f')]({},_0x2ad577,_0x3e864c);return db[_0xa09c('0x2e')]['find'](_0x2ad577)[_0xa09c('0x26')](function(_0xe93d34){if(_0xe93d34){_0xff3ba5=_0xe93d34;return _0xe93d34[_0xa09c('0x74')]();}return null;})[_0xa09c('0x26')](function(_0x108ba4){if(_0x108ba4){if(!_0x108ba4[_0xa09c('0x47')]){throw new db[(_0xa09c('0x75'))][(_0xa09c('0x76'))](_0xa09c('0x77'),0x193);}_0x341e47=_0x108ba4;return db[_0xa09c('0x91')][_0xa09c('0x78')]({'raw':!![]});}return null;})['then'](function(_0x217f07){if(_0x217f07){_0x54fa81=_[_0xa09c('0x79')](_0x217f07,'id');var _0x1f5730;var _0x3b5fb7=squel[_0xa09c('0x7a')]();_0x3b5fb7[_0xa09c('0x92')](_0xff3ba5[_0xa09c('0x7b')]);for(var _0xe81d45=0x0;_0xe81d45<_0x341e47[_0xa09c('0x47')];_0xe81d45+=0x1){_0x1f5730=_0x341e47[_0xe81d45][_0xa09c('0x7c')]?_0x54fa81[_0x341e47[_0xe81d45]['MetricId']][_0xa09c('0x7d')]:_0x341e47[_0xe81d45]['field'];_0x1f5730=_0x341e47[_0xe81d45][_0xa09c('0x7e')]?_['replace'](_0x56f39a[_0x341e47[_0xe81d45][_0xa09c('0x7e')]],'%s',_0x1f5730):_0x1f5730;_0x1f5730=_0x341e47[_0xe81d45][_0xa09c('0x80')]?_['replace'](_0x362037[_0x341e47[_0xe81d45]['format']],'%s',_0x1f5730):_0x1f5730;if(_0x341e47[_0xe81d45]['groupBy']){_0x3b5fb7['group'](_0x1f5730);}_0x341e47[_0xe81d45][_0xa09c('0x82')]&&_0x3b5fb7[_0xa09c('0x3b')](_0x1f5730,_0x341e47[_0xe81d45][_0xa09c('0x82')]==='DESC'?![]:!![]);_0x3b5fb7['field'](_0x1f5730,_0x341e47[_0xe81d45][_0xa09c('0x84')]||_0x1f5730);}if(_0xff3ba5['joins']){_0xff3ba5[_0xa09c('0x85')]=JSON['parse'](_0xff3ba5[_0xa09c('0x85')]);for(var _0x526d48=0x0;_0x526d48<_0xff3ba5[_0xa09c('0x85')][_0xa09c('0x47')];_0x526d48+=0x1){if(_0xff3ba5[_0xa09c('0x85')][_0x526d48][_0xa09c('0x30')]&&_[_0xa09c('0x69')](_0x277ab4,_0xff3ba5['joins'][_0x526d48][_0xa09c('0x30')])&&_0xff3ba5[_0xa09c('0x85')][_0x526d48]['parentKey']&&_0xff3ba5[_0xa09c('0x85')][_0x526d48][_0xa09c('0x87')]&&_0xff3ba5[_0xa09c('0x85')][_0x526d48][_0xa09c('0x88')]){_0x3b5fb7[_0xff3ba5['joins'][_0x526d48]['type']](_0xff3ba5[_0xa09c('0x85')][_0x526d48]['foreignTable'],null,util[_0xa09c('0x80')]('%s.%s\x20=\x20%s.%s',_0xff3ba5[_0xa09c('0x7b')],_0xff3ba5[_0xa09c('0x85')][_0x526d48][_0xa09c('0x86')],_0xff3ba5[_0xa09c('0x85')][_0x526d48][_0xa09c('0x87')],_0xff3ba5['joins'][_0x526d48]['foreignKey']));}}}if(_0xff3ba5[_0xa09c('0x8a')]){_0xff3ba5['conditions']=JSON[_0xa09c('0x8b')](_0xff3ba5[_0xa09c('0x8a')]);_0x3b5fb7[_0xa09c('0x3c')](_0x2ec7f4(_0xff3ba5[_0xa09c('0x8a')][_0xa09c('0x6f')]));}_0x470cfb=_0x3b5fb7[_0xa09c('0x93')]();_0x3b5fb7['limit'](_0x4be903);_0x3b5fb7['offset'](0x0);return;}})['then'](function(){if(_0x50fe25[_0xa09c('0x94')]===_0xa09c('0x95')){return null;}var _0x4fa302=_[_0xa09c('0x3f')](_0x50fe25,{'name':_0x50fe25['fullPath']||_0x50fe25['name']||_0xff3ba5[_0xa09c('0x2a')],'basename':_0x51ab85,'savename':util[_0xa09c('0x80')]('%s-%s.%s',_0x50fe25[_0xa09c('0x2a')]||_0xff3ba5['name'],require('randomstring')[_0xa09c('0x96')](0x4),_0x50fe25['output']||'csv'),'reportId':_0xff3ba5['id'],'reportType':_0xa09c('0x97')});return db[_0xa09c('0x98')]['create'](_0x4fa302,{'raw':!![]});})['then'](function(_0x93878a){if(_0xff3ba5[_0xa09c('0x7b')]===_0xa09c('0x99')){_0x470cfb[_0xa09c('0x3c')](_0xff3ba5[_0xa09c('0x7b')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x50fe25[_0xa09c('0x9a')],_0x50fe25['endDate']);}else{_0x470cfb[_0xa09c('0x3c')](_0xff3ba5[_0xa09c('0x7b')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x50fe25[_0xa09c('0x9a')],_0x50fe25[_0xa09c('0x9b')]);}if(_0x93878a){logger[_0xa09c('0x9c')](_0xa09c('0x9d'),_0x470cfb[_0xa09c('0x9e')]());require(_0xa09c('0x9f'))[_0xa09c('0xa0')](path[_0xa09c('0x57')](__dirname,'../../components/export/',_0x93878a[_0xa09c('0x94')]),[_0x93878a['id'],_0x470cfb[_0xa09c('0x9e')](),path[_0xa09c('0x57')](__dirname,_0xa09c('0xa1'),_0x93878a[_0xa09c('0xa2')]),_0x51ab85]);return _0x93878a;}else{var _0xb2f20c=squel[_0xa09c('0x7a')]();_0xb2f20c[_0xa09c('0x92')]('('+_0x470cfb[_0xa09c('0x9e')]()+')',_0xa09c('0xa3'));_0xb2f20c[_0xa09c('0x70')]('COUNT(*)',_0xa09c('0x1e'));_0x470cfb[_0xa09c('0x20')](_0x50fe25['limit']||_0x4be903);_0x470cfb['offset'](_0x50fe25[_0xa09c('0x1f')]||0x0);return dbH[_0xa09c('0x8d')]['query'](_0xb2f20c[_0xa09c('0x9e')](),{'type':dbH['sequelize']['QueryTypes'][_0xa09c('0x8f')]})[_0xa09c('0x26')](function(_0x5bd274){if(!_0x5bd274[_0xa09c('0x47')]){_0x8edc0f=0x0;}else{_0x8edc0f=_0x5bd274[0x0]['count']||0x0;}return dbH[_0xa09c('0x8d')]['query'](_0x470cfb[_0xa09c('0x9e')](),{'type':dbH[_0xa09c('0x8d')][_0xa09c('0x8e')][_0xa09c('0x8f')]});})[_0xa09c('0x26')](function(_0x18ae1b){return{'rows':_0x18ae1b||[],'count':_0x8edc0f};});}});}exports[_0xa09c('0xa4')]=function(_0x40f99e,_0x2773c0){return runReport(_0x40f99e[_0xa09c('0x45')],_0x40f99e[_0xa09c('0x33')],_0x40f99e[_0xa09c('0x73')])[_0xa09c('0x26')](respondWithResult(_0x2773c0,null))['catch'](handleError(_0x2773c0,null));};exports[_0xa09c('0xa5')]=runReport;exports[_0xa09c('0x33')]=function(_0x560309,_0x457df5){var _0x23ef1d=0xa;var _0x446232=[_0xa09c('0x57'),'left_join',_0xa09c('0x59'),_0xa09c('0x5a')];var _0x33b64b={'SUM':'SUM(%s)','COUNT':_0xa09c('0x5c'),'COUNT DISTINCT':_0xa09c('0x5d'),'MAX':_0xa09c('0x5e'),'MIN':_0xa09c('0x5f'),'AVG':'AVG(%s)','GROUP_CONCAT':_0xa09c('0x61'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x37100a={'SEC_TO_TIME':_0xa09c('0x64'),'DATE':_0xa09c('0x65'),'HOUR':_0xa09c('0x66'),'ROUND':_0xa09c('0x67'),'UNIX_TIMESTAMP':_0xa09c('0x68')};var _0x2404fc=function(_0x3c17a3){return!_['includes']([_0xa09c('0x6a'),_0xa09c('0x6b'),'IS\x20EMPTY',_0xa09c('0x6c')],_0x3c17a3);};var _0x4b2c56=function(_0x238723){if(!_0x238723||!_0x238723[_0xa09c('0x6d')]['length']){return'';}for(var _0x4c7a38='(',_0xd3a63a=0x0;_0xd3a63a<_0x238723[_0xa09c('0x6d')][_0xa09c('0x47')];_0xd3a63a+=0x1){_0xd3a63a>0x0&&(_0x4c7a38+='\x20'+_0x238723[_0xa09c('0x6e')]+'\x20');_0x4c7a38+=_0x238723[_0xa09c('0x6d')][_0xd3a63a][_0xa09c('0x6f')]?_0x4b2c56(_0x238723['rules'][_0xd3a63a][_0xa09c('0x6f')]):_0x238723[_0xa09c('0x6d')][_0xd3a63a][_0xa09c('0x70')]+'\x20'+_0x238723['rules'][_0xd3a63a][_0xa09c('0x71')]+(_0x2404fc(_0x238723[_0xa09c('0x6d')][_0xd3a63a][_0xa09c('0x71')])?'\x20'+_0x238723[_0xa09c('0x6d')][_0xd3a63a][_0xa09c('0x72')]:'');}return _0x4c7a38+')';};var _0x195ea0={'where':{'id':_0x560309['params']['id']}},_0x459b07,_0x4e6c21,_0xb6c08d,_0x58ef57,_0x4eaaf1;_0x195ea0=_['merge']({},_0x195ea0,_0x560309[_0xa09c('0x73')]);return db[_0xa09c('0x2e')]['find'](_0x195ea0)[_0xa09c('0x26')](function(_0x3b2b75){if(_0x3b2b75){_0x459b07=_0x3b2b75;return _0x3b2b75[_0xa09c('0x74')]();}return null;})[_0xa09c('0x26')](function(_0x417b6c){if(_0x417b6c){if(!_0x417b6c[_0xa09c('0x47')]){throw new db[(_0xa09c('0x75'))][(_0xa09c('0x76'))](_0xa09c('0x77'),0x193);}_0x4e6c21=_0x417b6c;return db[_0xa09c('0x91')][_0xa09c('0x78')]({'raw':!![]});}return null;})[_0xa09c('0x26')](function(_0x48eeb8){if(_0x48eeb8){_0xb6c08d=_[_0xa09c('0x79')](_0x48eeb8,'id');var _0x5d7a7b;var _0xec7b70=squel[_0xa09c('0x7a')]();_0xec7b70[_0xa09c('0x92')](_0x459b07[_0xa09c('0x7b')]);for(var _0x9c8fc1=0x0;_0x9c8fc1<_0x4e6c21[_0xa09c('0x47')];_0x9c8fc1+=0x1){_0x5d7a7b=_0x4e6c21[_0x9c8fc1][_0xa09c('0x7c')]?_0xb6c08d[_0x4e6c21[_0x9c8fc1][_0xa09c('0x7c')]]['metric']:_0x4e6c21[_0x9c8fc1][_0xa09c('0x70')];_0x5d7a7b=_0x4e6c21[_0x9c8fc1][_0xa09c('0x7e')]?_[_0xa09c('0x7f')](_0x33b64b[_0x4e6c21[_0x9c8fc1][_0xa09c('0x7e')]],'%s',_0x5d7a7b):_0x5d7a7b;_0x5d7a7b=_0x4e6c21[_0x9c8fc1]['format']?_['replace'](_0x37100a[_0x4e6c21[_0x9c8fc1]['format']],'%s',_0x5d7a7b):_0x5d7a7b;if(_0x4e6c21[_0x9c8fc1][_0xa09c('0x81')]){_0xec7b70[_0xa09c('0x6f')](_0x5d7a7b);}_0x4e6c21[_0x9c8fc1]['orderBy']&&_0xec7b70[_0xa09c('0x3b')](_0x5d7a7b,_0x4e6c21[_0x9c8fc1][_0xa09c('0x82')]===_0xa09c('0x83')?![]:!![]);_0xec7b70[_0xa09c('0x70')](_0x5d7a7b,_0x4e6c21[_0x9c8fc1][_0xa09c('0x84')]||_0x5d7a7b);}if(_0x459b07[_0xa09c('0x85')]){_0x459b07[_0xa09c('0x85')]=JSON[_0xa09c('0x8b')](_0x459b07[_0xa09c('0x85')]);for(var _0x2f1d59=0x0;_0x2f1d59<_0x459b07[_0xa09c('0x85')][_0xa09c('0x47')];_0x2f1d59+=0x1){if(_0x459b07['joins'][_0x2f1d59][_0xa09c('0x30')]&&_[_0xa09c('0x69')](_0x446232,_0x459b07[_0xa09c('0x85')][_0x2f1d59][_0xa09c('0x30')])&&_0x459b07[_0xa09c('0x85')][_0x2f1d59][_0xa09c('0x86')]&&_0x459b07['joins'][_0x2f1d59][_0xa09c('0x87')]&&_0x459b07[_0xa09c('0x85')][_0x2f1d59][_0xa09c('0x88')]){_0xec7b70[_0x459b07[_0xa09c('0x85')][_0x2f1d59][_0xa09c('0x30')]](_0x459b07[_0xa09c('0x85')][_0x2f1d59][_0xa09c('0x87')],null,util[_0xa09c('0x80')](_0xa09c('0x89'),_0x459b07['table'],_0x459b07['joins'][_0x2f1d59][_0xa09c('0x86')],_0x459b07[_0xa09c('0x85')][_0x2f1d59][_0xa09c('0x87')],_0x459b07['joins'][_0x2f1d59][_0xa09c('0x88')]));}}}if(_0x459b07[_0xa09c('0x8a')]){_0x459b07['conditions']=JSON[_0xa09c('0x8b')](_0x459b07[_0xa09c('0x8a')]);_0xec7b70[_0xa09c('0x3c')](_0x4b2c56(_0x459b07[_0xa09c('0x8a')]['group']));}_0x4eaaf1=_0xec7b70[_0xa09c('0x93')]();_0xec7b70[_0xa09c('0x20')](_0x23ef1d);_0xec7b70['offset'](0x0);logger['debug']('Limited\x20Query:',_0xec7b70[_0xa09c('0x9e')]());return dbH['sequelize'][_0xa09c('0x33')](_0xec7b70[_0xa09c('0x9e')](),{'type':dbH[_0xa09c('0x8d')][_0xa09c('0x8e')]['SELECT']});}})[_0xa09c('0x26')](function(){return{'sql':_0x4eaaf1[_0xa09c('0x9e')]()};})['then'](respondWithResult(_0x457df5,null))[_0xa09c('0x48')](handleError(_0x457df5,null));};
\ No newline at end of file
+var _0xf494=['name','send','index','map','AnalyticDefaultReport','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','catch','show','includeAll','find','create','body','user','Reports','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','join','left_join','cross_join','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NOT\x20NULL','IS\x20EMPTY','rules','group','field','value','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','table','MetricId','metric','function','replace','format','orderBy','DESC','alias','joins','parse','foreignTable','%s.%s\x20=\x20%s.%s','parentKey','foreignKey','conditions','debug','Limited\x20Query:','sequelize','toString','QueryTypes','right_join','SUM(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','ROUND(%s)','IS\x20NULL','operator','condition','getFields','groupBy','clone','output','fullPath','%s-%s.%s','generate','csv','default','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','endDate','info','child_process','fork','../../components/export/','../../files/reports','savename','countTable','COUNT(*)','SELECT','run','runReport','IS\x20NOT\x20EMPTY','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','reject','save','update','then','destroy','get','DefaultReports','error','stack'];(function(_0x306c0c,_0x184d7f){var _0x118365=function(_0x1fece1){while(--_0x1fece1){_0x306c0c['push'](_0x306c0c['shift']());}};_0x118365(++_0x184d7f);}(_0xf494,0x1c6));var _0x4f49=function(_0x1602c2,_0x47b449){_0x1602c2=_0x1602c2-0x0;var _0x182f40=_0xf494[_0x1602c2];return _0x182f40;};'use strict';var emlformat=require(_0x4f49('0x0'));var rimraf=require(_0x4f49('0x1'));var zipdir=require(_0x4f49('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x4f49('0x3'));var moment=require(_0x4f49('0x4'));var BPromise=require(_0x4f49('0x5'));var Mustache=require(_0x4f49('0x6'));var util=require(_0x4f49('0x7'));var path=require(_0x4f49('0x8'));var sox=require(_0x4f49('0x9'));var csv=require(_0x4f49('0xa'));var ejs=require(_0x4f49('0xb'));var fs=require('fs');var fs_extra=require(_0x4f49('0xc'));var _=require(_0x4f49('0xd'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x4f49('0xe'));var deskjs=require(_0x4f49('0xf'));var toCsv=require(_0x4f49('0xa'));var querystring=require(_0x4f49('0x10'));var Papa=require(_0x4f49('0x11'));var Redis=require(_0x4f49('0x12'));var authService=require(_0x4f49('0x13'));var qs=require(_0x4f49('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4f49('0x15'));var logger=require(_0x4f49('0x16'))('api');var utils=require(_0x4f49('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x4f49('0x18'))['db'];var dbH=require(_0x4f49('0x18'))['dbH'];function respondWithStatusCode(_0x1e1c37,_0x111a8b){_0x111a8b=_0x111a8b||0xcc;return function(_0x1b9145){if(_0x1b9145){return _0x1e1c37[_0x4f49('0x19')](_0x111a8b);}return _0x1e1c37[_0x4f49('0x1a')](_0x111a8b)[_0x4f49('0x1b')]();};}function respondWithResult(_0xfdb477,_0x5c373e){_0x5c373e=_0x5c373e||0xc8;return function(_0x515ace){if(_0x515ace){return _0xfdb477[_0x4f49('0x1a')](_0x5c373e)[_0x4f49('0x1c')](_0x515ace);}};}function respondWithFilteredResult(_0x5878f4,_0x5bdfaf){return function(_0x2f0a0d){if(_0x2f0a0d){var _0x2ecaaa=typeof _0x5bdfaf[_0x4f49('0x1d')]==='undefined'&&typeof _0x5bdfaf[_0x4f49('0x1e')]===_0x4f49('0x1f');var _0x4e85df=_0x2f0a0d['count'];var _0x5bb23b=_0x2ecaaa?0x0:_0x5bdfaf['offset'];var _0x47f1e8=_0x2ecaaa?_0x2f0a0d[_0x4f49('0x20')]:_0x5bdfaf[_0x4f49('0x1d')]+_0x5bdfaf[_0x4f49('0x1e')];var _0x407042;if(_0x47f1e8>=_0x4e85df){_0x47f1e8=_0x4e85df;_0x407042=0xc8;}else{_0x407042=0xce;}_0x5878f4['status'](_0x407042);return _0x5878f4[_0x4f49('0x21')](_0x4f49('0x22'),_0x5bb23b+'-'+_0x47f1e8+'/'+_0x4e85df)[_0x4f49('0x1c')](_0x2f0a0d);}return null;};}function patchUpdates(_0xaab5e7){return function(_0xea82f8){try{jsonpatch['apply'](_0xea82f8,_0xaab5e7,!![]);}catch(_0x3e7e28){return BPromise[_0x4f49('0x23')](_0x3e7e28);}return _0xea82f8[_0x4f49('0x24')]();};}function saveUpdates(_0x53b57d,_0x40755e){return function(_0x1d70a7){if(_0x1d70a7){return _0x1d70a7[_0x4f49('0x25')](_0x53b57d)[_0x4f49('0x26')](function(_0x9d30aa){return _0x9d30aa;});}return null;};}function removeEntity(_0x36187b,_0x559d98){return function(_0x4e9041){if(_0x4e9041){return _0x4e9041[_0x4f49('0x27')]()[_0x4f49('0x26')](function(){var _0x4fedbb=_0x4e9041[_0x4f49('0x28')]({'plain':!![]});var _0x2c1519=_0x4f49('0x29');return db['UserProfileResource'][_0x4f49('0x27')]({'where':{'type':_0x2c1519,'resourceId':_0x4fedbb['id']}})[_0x4f49('0x26')](function(){return _0x4e9041;});})[_0x4f49('0x26')](function(){_0x36187b[_0x4f49('0x1a')](0xcc)[_0x4f49('0x1b')]();});}};}function handleEntityNotFound(_0x122404,_0x4915af){return function(_0x50c571){if(!_0x50c571){_0x122404[_0x4f49('0x19')](0x194);}return _0x50c571;};}function handleError(_0x2c00ee,_0x605c91){_0x605c91=_0x605c91||0x1f4;return function(_0x560050){logger[_0x4f49('0x2a')](_0x560050[_0x4f49('0x2b')]);if(_0x560050[_0x4f49('0x2c')]){delete _0x560050['name'];}_0x2c00ee['status'](_0x605c91)[_0x4f49('0x2d')](_0x560050);};}exports[_0x4f49('0x2e')]=function(_0x7a6ea0,_0x5e7076){var _0x1eaac6={},_0x35aa33={},_0x173657={'count':0x0,'rows':[]};var _0x2ceda4=_[_0x4f49('0x2f')](db[_0x4f49('0x30')][_0x4f49('0x31')],function(_0x45ae19){return{'name':_0x45ae19[_0x4f49('0x32')],'type':_0x45ae19[_0x4f49('0x33')][_0x4f49('0x34')]};});_0x35aa33[_0x4f49('0x35')]=_[_0x4f49('0x2f')](_0x2ceda4,_0x4f49('0x2c'));_0x35aa33[_0x4f49('0x36')]=_[_0x4f49('0x37')](_0x7a6ea0[_0x4f49('0x36')]);_0x35aa33[_0x4f49('0x38')]=_[_0x4f49('0x39')](_0x35aa33['model'],_0x35aa33[_0x4f49('0x36')]);_0x1eaac6[_0x4f49('0x3a')]=_[_0x4f49('0x39')](_0x35aa33[_0x4f49('0x35')],qs[_0x4f49('0x3b')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x3b')]));_0x1eaac6[_0x4f49('0x3a')]=_0x1eaac6[_0x4f49('0x3a')][_0x4f49('0x3c')]?_0x1eaac6[_0x4f49('0x3a')]:_0x35aa33[_0x4f49('0x35')];if(!_0x7a6ea0[_0x4f49('0x36')]['hasOwnProperty'](_0x4f49('0x3d'))){_0x1eaac6[_0x4f49('0x1e')]=qs[_0x4f49('0x1e')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x1e')]);_0x1eaac6[_0x4f49('0x1d')]=qs[_0x4f49('0x1d')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x1d')]);}_0x1eaac6[_0x4f49('0x3e')]=qs[_0x4f49('0x3f')](_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x3f')]);_0x1eaac6[_0x4f49('0x40')]=qs['filters'](_[_0x4f49('0x41')](_0x7a6ea0[_0x4f49('0x36')],_0x35aa33['filters']),_0x2ceda4);if(_0x7a6ea0[_0x4f49('0x36')][_0x4f49('0x42')]){_0x1eaac6['where']=_[_0x4f49('0x43')](_0x1eaac6[_0x4f49('0x40')],{'$or':_[_0x4f49('0x2f')](_0x2ceda4,function(_0x200b1d){if(_0x200b1d[_0x4f49('0x33')]!==_0x4f49('0x44')){var _0x29e910={};_0x29e910[_0x200b1d['name']]={'$like':'%'+_0x7a6ea0['query']['filter']+'%'};return _0x29e910;}})});}_0x1eaac6=_[_0x4f49('0x43')]({},_0x1eaac6,_0x7a6ea0[_0x4f49('0x45')]);var _0x2e4355={'where':_0x1eaac6[_0x4f49('0x40')]};return db[_0x4f49('0x30')][_0x4f49('0x20')](_0x2e4355)[_0x4f49('0x26')](function(_0x23720a){_0x173657[_0x4f49('0x20')]=_0x23720a;if(_0x7a6ea0['query']['includeAll']){_0x1eaac6[_0x4f49('0x46')]=[{'all':!![]}];}return db[_0x4f49('0x30')][_0x4f49('0x47')](_0x1eaac6);})['then'](function(_0x2d6b56){_0x173657['rows']=_0x2d6b56;return _0x173657;})['then'](respondWithFilteredResult(_0x5e7076,_0x1eaac6))[_0x4f49('0x48')](handleError(_0x5e7076,null));};exports[_0x4f49('0x49')]=function(_0x40eadc,_0x497cb8){var _0x287781={'raw':!![],'where':{'id':_0x40eadc['params']['id']}},_0x11b4df={};_0x11b4df[_0x4f49('0x35')]=_['keys'](db[_0x4f49('0x30')][_0x4f49('0x31')]);_0x11b4df[_0x4f49('0x36')]=_['keys'](_0x40eadc[_0x4f49('0x36')]);_0x11b4df[_0x4f49('0x38')]=_[_0x4f49('0x39')](_0x11b4df[_0x4f49('0x35')],_0x11b4df[_0x4f49('0x36')]);_0x287781[_0x4f49('0x3a')]=_[_0x4f49('0x39')](_0x11b4df[_0x4f49('0x35')],qs[_0x4f49('0x3b')](_0x40eadc[_0x4f49('0x36')]['fields']));_0x287781[_0x4f49('0x3a')]=_0x287781[_0x4f49('0x3a')]['length']?_0x287781[_0x4f49('0x3a')]:_0x11b4df['model'];if(_0x40eadc[_0x4f49('0x36')][_0x4f49('0x4a')]){_0x287781[_0x4f49('0x46')]=[{'all':!![]}];}_0x287781=_[_0x4f49('0x43')]({},_0x287781,_0x40eadc['options']);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x287781)[_0x4f49('0x26')](handleEntityNotFound(_0x497cb8,null))[_0x4f49('0x26')](respondWithResult(_0x497cb8,null))[_0x4f49('0x48')](handleError(_0x497cb8,null));};exports[_0x4f49('0x4c')]=function(_0x37fdb7,_0xd282c){return db[_0x4f49('0x30')][_0x4f49('0x4c')](_0x37fdb7[_0x4f49('0x4d')],{})[_0x4f49('0x26')](function(_0x148031){var _0x2104d0=_0x37fdb7[_0x4f49('0x4e')][_0x4f49('0x28')]({'plain':!![]});if(!_0x2104d0)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2104d0['role']===_0x4f49('0x4e')){var _0x197670=_0x148031[_0x4f49('0x28')]({'plain':!![]});var _0xe46c90=_0x4f49('0x4f');return db[_0x4f49('0x50')][_0x4f49('0x4b')]({'where':{'name':_0xe46c90,'userProfileId':_0x2104d0['userProfileId']},'raw':!![]})[_0x4f49('0x26')](function(_0x4ff0a2){if(_0x4ff0a2&&_0x4ff0a2[_0x4f49('0x51')]===0x0){return db[_0x4f49('0x52')][_0x4f49('0x4c')]({'name':_0x197670[_0x4f49('0x2c')],'resourceId':_0x197670['id'],'type':'DefaultReports','sectionId':_0x4ff0a2['id']},{})[_0x4f49('0x26')](function(){return _0x148031;});}else{return _0x148031;}})['catch'](function(_0x52d18c){logger[_0x4f49('0x2a')](_0x4f49('0x53'),_0x52d18c);throw _0x52d18c;});}return _0x148031;})[_0x4f49('0x26')](respondWithResult(_0xd282c,0xc9))[_0x4f49('0x48')](handleError(_0xd282c,null));};exports['update']=function(_0x599c51,_0xd7f47b){if(_0x599c51[_0x4f49('0x4d')]['id']){delete _0x599c51['body']['id'];}return db[_0x4f49('0x30')]['find']({'where':{'id':_0x599c51['params']['id']}})[_0x4f49('0x26')](handleEntityNotFound(_0xd7f47b,null))['then'](saveUpdates(_0x599c51[_0x4f49('0x4d')],null))['then'](respondWithResult(_0xd7f47b,null))[_0x4f49('0x48')](handleError(_0xd7f47b,null));};exports[_0x4f49('0x27')]=function(_0x2472c9,_0x883408){return db[_0x4f49('0x30')][_0x4f49('0x4b')]({'where':{'id':_0x2472c9[_0x4f49('0x54')]['id']}})[_0x4f49('0x26')](handleEntityNotFound(_0x883408,null))['then'](removeEntity(_0x883408,null))[_0x4f49('0x48')](handleError(_0x883408,null));};exports['preview']=function(_0x213608,_0x1f640d){var _0xc4fc6b=0xa;var _0x467f12=[_0x4f49('0x55'),_0x4f49('0x56'),'right_join',_0x4f49('0x57')];var _0xd3689c={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':_0x4f49('0x59'),'MIN':_0x4f49('0x5a'),'AVG':_0x4f49('0x5b'),'GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0x564bf5={'SEC_TO_TIME':_0x4f49('0x5e'),'DATE':_0x4f49('0x5f'),'HOUR':_0x4f49('0x60'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x21807e=function(_0x265988){return!_[_0x4f49('0x62')](['IS\x20NULL',_0x4f49('0x63'),_0x4f49('0x64'),'IS\x20NOT\x20EMPTY'],_0x265988);};var _0x293839=function(_0x17b15){if(!_0x17b15||!_0x17b15[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x28ea73='(',_0x1b80f2=0x0;_0x1b80f2<_0x17b15[_0x4f49('0x65')][_0x4f49('0x3c')];_0x1b80f2+=0x1){_0x1b80f2>0x0&&(_0x28ea73+='\x20'+_0x17b15['operator']+'\x20');_0x28ea73+=_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x66')]?_0x293839(_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x66')]):_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x67')]+'\x20'+_0x17b15[_0x4f49('0x65')][_0x1b80f2]['condition']+(_0x21807e(_0x17b15[_0x4f49('0x65')][_0x1b80f2]['condition'])?'\x20'+_0x17b15[_0x4f49('0x65')][_0x1b80f2][_0x4f49('0x68')]:'');}return _0x28ea73+')';};var _0x4714c7={'where':{'id':_0x213608[_0x4f49('0x54')]['id']}},_0xf29378,_0xc7743e,_0x3f2f3f,_0x61a565,_0x297698;_0x4714c7=_[_0x4f49('0x43')]({},_0x4714c7,_0x213608['options']);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x4714c7)[_0x4f49('0x26')](function(_0x2cdaa4){if(_0x2cdaa4){_0xf29378=_0x2cdaa4;return _0x2cdaa4['getFields']();}return null;})['then'](function(_0x28e8ae){if(_0x28e8ae){if(!_0x28e8ae['length']){throw new db[(_0x4f49('0x69'))][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0xc7743e=_0x28e8ae;return db[_0x4f49('0x6c')][_0x4f49('0x47')]({'raw':!![]});}return null;})[_0x4f49('0x26')](function(_0x179431){if(_0x179431){_0x3f2f3f=_[_0x4f49('0x6d')](_0x179431,'id');var _0x3823f0;var _0x3e9b47=squel[_0x4f49('0x6e')]();_0x3e9b47[_0x4f49('0x6f')](_0xf29378[_0x4f49('0x70')]);for(var _0xd53de8=0x0;_0xd53de8<_0xc7743e[_0x4f49('0x3c')];_0xd53de8+=0x1){_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x71')]?_0x3f2f3f[_0xc7743e[_0xd53de8][_0x4f49('0x71')]][_0x4f49('0x72')]:_0xc7743e[_0xd53de8][_0x4f49('0x67')];_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x73')]?_[_0x4f49('0x74')](_0xd3689c[_0xc7743e[_0xd53de8][_0x4f49('0x73')]],'%s',_0x3823f0):_0x3823f0;_0x3823f0=_0xc7743e[_0xd53de8][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0x564bf5[_0xc7743e[_0xd53de8][_0x4f49('0x75')]],'%s',_0x3823f0):_0x3823f0;if(_0xc7743e[_0xd53de8]['groupBy']){_0x3e9b47[_0x4f49('0x66')](_0x3823f0);}_0xc7743e[_0xd53de8]['orderBy']&&_0x3e9b47[_0x4f49('0x3e')](_0x3823f0,_0xc7743e[_0xd53de8][_0x4f49('0x76')]===_0x4f49('0x77')?![]:!![]);_0x3e9b47[_0x4f49('0x67')](_0x3823f0,_0xc7743e[_0xd53de8][_0x4f49('0x78')]||_0x3823f0);}if(_0xf29378[_0x4f49('0x79')]){_0xf29378[_0x4f49('0x79')]=JSON[_0x4f49('0x7a')](_0xf29378[_0x4f49('0x79')]);for(var _0x541ac6=0x0;_0x541ac6<_0xf29378['joins'][_0x4f49('0x3c')];_0x541ac6+=0x1){if(_0xf29378['joins'][_0x541ac6][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x467f12,_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x33')])&&_0xf29378[_0x4f49('0x79')][_0x541ac6]['parentKey']&&_0xf29378['joins'][_0x541ac6][_0x4f49('0x7b')]&&_0xf29378[_0x4f49('0x79')][_0x541ac6]['foreignKey']){_0x3e9b47[_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x33')]](_0xf29378['joins'][_0x541ac6][_0x4f49('0x7b')],null,util['format'](_0x4f49('0x7c'),_0xf29378[_0x4f49('0x70')],_0xf29378['joins'][_0x541ac6][_0x4f49('0x7d')],_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x7b')],_0xf29378[_0x4f49('0x79')][_0x541ac6][_0x4f49('0x7e')]));}}}if(_0xf29378[_0x4f49('0x7f')]){_0xf29378['conditions']=JSON[_0x4f49('0x7a')](_0xf29378['conditions']);_0x3e9b47[_0x4f49('0x40')](_0x293839(_0xf29378['conditions'][_0x4f49('0x66')]));}_0x297698=_0x3e9b47['clone']();_0x3e9b47[_0x4f49('0x1e')](_0xc4fc6b);_0x3e9b47[_0x4f49('0x1d')](0x0);logger[_0x4f49('0x80')](_0x4f49('0x81'),_0x3e9b47['toString']());return dbH[_0x4f49('0x82')]['query'](_0x3e9b47[_0x4f49('0x83')](),{'type':dbH['sequelize'][_0x4f49('0x84')]['SELECT']});}})['then'](respondWithResult(_0x1f640d,null))[_0x4f49('0x48')](handleError(_0x1f640d,null));};function runReport(_0x20b2be,_0x16cb4d,_0x4c0e7a){var _0x289810=_0x16cb4d[_0x4f49('0x2c')];var _0x5c33c9=0xa;var _0x5d52ae=['join',_0x4f49('0x56'),_0x4f49('0x85'),_0x4f49('0x57')];var _0x87439={'SUM':_0x4f49('0x86'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':_0x4f49('0x59'),'MIN':_0x4f49('0x5a'),'AVG':'AVG(%s)','GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':_0x4f49('0x87'),'GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0x2902a1={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x4f49('0x5f'),'HOUR':_0x4f49('0x60'),'ROUND':_0x4f49('0x88'),'UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x389679=function(_0x5304c3){return!_[_0x4f49('0x62')]([_0x4f49('0x89'),'IS\x20NOT\x20NULL',_0x4f49('0x64'),'IS\x20NOT\x20EMPTY'],_0x5304c3);};var _0x351a33=function(_0x4d72a0){if(!_0x4d72a0||!_0x4d72a0[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x2ef19e='(',_0x6ad599=0x0;_0x6ad599<_0x4d72a0[_0x4f49('0x65')]['length'];_0x6ad599+=0x1){_0x6ad599>0x0&&(_0x2ef19e+='\x20'+_0x4d72a0[_0x4f49('0x8a')]+'\x20');_0x2ef19e+=_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x66')]?_0x351a33(_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['group']):_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['field']+'\x20'+_0x4d72a0[_0x4f49('0x65')][_0x6ad599]['condition']+(_0x389679(_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x8b')])?'\x20'+_0x4d72a0[_0x4f49('0x65')][_0x6ad599][_0x4f49('0x68')]:'');}return _0x2ef19e+')';};var _0x111e90={'where':{'id':_0x20b2be['id']}},_0xd253ed,_0x323a3a,_0xe0adc3,_0x3a26ff,_0x64f0ee;_0x111e90=_['merge']({},_0x111e90,_0x4c0e7a);return db[_0x4f49('0x30')][_0x4f49('0x4b')](_0x111e90)[_0x4f49('0x26')](function(_0x299849){if(_0x299849){_0xd253ed=_0x299849;return _0x299849[_0x4f49('0x8c')]();}return null;})[_0x4f49('0x26')](function(_0x55b28b){if(_0x55b28b){if(!_0x55b28b[_0x4f49('0x3c')]){throw new db[(_0x4f49('0x69'))][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0x323a3a=_0x55b28b;return db['AnalyticMetric'][_0x4f49('0x47')]({'raw':!![]});}return null;})['then'](function(_0x3c4e88){if(_0x3c4e88){_0xe0adc3=_[_0x4f49('0x6d')](_0x3c4e88,'id');var _0x5c5d2;var _0xa880a2=squel['select']();_0xa880a2[_0x4f49('0x6f')](_0xd253ed[_0x4f49('0x70')]);for(var _0x11c0a0=0x0;_0x11c0a0<_0x323a3a[_0x4f49('0x3c')];_0x11c0a0+=0x1){_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x71')]?_0xe0adc3[_0x323a3a[_0x11c0a0][_0x4f49('0x71')]][_0x4f49('0x72')]:_0x323a3a[_0x11c0a0][_0x4f49('0x67')];_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x73')]?_[_0x4f49('0x74')](_0x87439[_0x323a3a[_0x11c0a0][_0x4f49('0x73')]],'%s',_0x5c5d2):_0x5c5d2;_0x5c5d2=_0x323a3a[_0x11c0a0][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0x2902a1[_0x323a3a[_0x11c0a0][_0x4f49('0x75')]],'%s',_0x5c5d2):_0x5c5d2;if(_0x323a3a[_0x11c0a0][_0x4f49('0x8d')]){_0xa880a2[_0x4f49('0x66')](_0x5c5d2);}_0x323a3a[_0x11c0a0][_0x4f49('0x76')]&&_0xa880a2[_0x4f49('0x3e')](_0x5c5d2,_0x323a3a[_0x11c0a0]['orderBy']===_0x4f49('0x77')?![]:!![]);_0xa880a2[_0x4f49('0x67')](_0x5c5d2,_0x323a3a[_0x11c0a0][_0x4f49('0x78')]||_0x5c5d2);}if(_0xd253ed[_0x4f49('0x79')]){_0xd253ed['joins']=JSON[_0x4f49('0x7a')](_0xd253ed[_0x4f49('0x79')]);for(var _0x594460=0x0;_0x594460<_0xd253ed[_0x4f49('0x79')]['length'];_0x594460+=0x1){if(_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x5d52ae,_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x33')])&&_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7d')]&&_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7b')]&&_0xd253ed[_0x4f49('0x79')][_0x594460]['foreignKey']){_0xa880a2[_0xd253ed['joins'][_0x594460][_0x4f49('0x33')]](_0xd253ed['joins'][_0x594460][_0x4f49('0x7b')],null,util[_0x4f49('0x75')]('%s.%s\x20=\x20%s.%s',_0xd253ed['table'],_0xd253ed[_0x4f49('0x79')][_0x594460]['parentKey'],_0xd253ed[_0x4f49('0x79')][_0x594460][_0x4f49('0x7b')],_0xd253ed[_0x4f49('0x79')][_0x594460]['foreignKey']));}}}if(_0xd253ed[_0x4f49('0x7f')]){_0xd253ed['conditions']=JSON[_0x4f49('0x7a')](_0xd253ed[_0x4f49('0x7f')]);_0xa880a2[_0x4f49('0x40')](_0x351a33(_0xd253ed['conditions'][_0x4f49('0x66')]));}_0x64f0ee=_0xa880a2[_0x4f49('0x8e')]();_0xa880a2[_0x4f49('0x1e')](_0x5c33c9);_0xa880a2['offset'](0x0);return;}})['then'](function(){if(_0x16cb4d[_0x4f49('0x8f')]==='web'){return null;}var _0x2bc9df=_[_0x4f49('0x43')](_0x16cb4d,{'name':_0x16cb4d[_0x4f49('0x90')]||_0x16cb4d['name']||_0xd253ed[_0x4f49('0x2c')],'basename':_0x289810,'savename':util['format'](_0x4f49('0x91'),_0x16cb4d[_0x4f49('0x2c')]||_0xd253ed[_0x4f49('0x2c')],require('randomstring')[_0x4f49('0x92')](0x4),_0x16cb4d[_0x4f49('0x8f')]||_0x4f49('0x93')),'reportId':_0xd253ed['id'],'reportType':_0x4f49('0x94')});return db[_0x4f49('0x95')][_0x4f49('0x4c')](_0x2bc9df,{'raw':!![]});})['then'](function(_0x5b6ac7){if(_0xd253ed[_0x4f49('0x70')]===_0x4f49('0x96')){_0x64f0ee[_0x4f49('0x40')](_0xd253ed[_0x4f49('0x70')]+_0x4f49('0x97'),_0x16cb4d[_0x4f49('0x98')],_0x16cb4d[_0x4f49('0x99')]);}else{_0x64f0ee[_0x4f49('0x40')](_0xd253ed[_0x4f49('0x70')]+'.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x16cb4d[_0x4f49('0x98')],_0x16cb4d[_0x4f49('0x99')]);}if(_0x5b6ac7){logger[_0x4f49('0x9a')]('Run\x20Query:',_0x64f0ee[_0x4f49('0x83')]());require(_0x4f49('0x9b'))[_0x4f49('0x9c')](path['join'](__dirname,_0x4f49('0x9d'),_0x5b6ac7[_0x4f49('0x8f')]),[_0x5b6ac7['id'],_0x64f0ee[_0x4f49('0x83')](),path['join'](__dirname,_0x4f49('0x9e'),_0x5b6ac7[_0x4f49('0x9f')]),_0x289810]);return _0x5b6ac7;}else{var _0x5efb11=squel['select']();_0x5efb11[_0x4f49('0x6f')]('('+_0x64f0ee[_0x4f49('0x83')]()+')',_0x4f49('0xa0'));_0x5efb11[_0x4f49('0x67')](_0x4f49('0xa1'),_0x4f49('0x20'));_0x64f0ee['limit'](_0x16cb4d['limit']||_0x5c33c9);_0x64f0ee['offset'](_0x16cb4d[_0x4f49('0x1d')]||0x0);return dbH[_0x4f49('0x82')]['query'](_0x5efb11[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')][_0x4f49('0x84')]['SELECT']})['then'](function(_0x3633b5){if(!_0x3633b5['length']){_0x3a26ff=0x0;}else{_0x3a26ff=_0x3633b5[0x0][_0x4f49('0x20')]||0x0;}return dbH[_0x4f49('0x82')][_0x4f49('0x36')](_0x64f0ee[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')]['QueryTypes'][_0x4f49('0xa2')]});})[_0x4f49('0x26')](function(_0x45c938){return{'rows':_0x45c938||[],'count':_0x3a26ff};});}});}exports[_0x4f49('0xa3')]=function(_0x4a4d75,_0x93e85d){return runReport(_0x4a4d75[_0x4f49('0x54')],_0x4a4d75['query'],_0x4a4d75[_0x4f49('0x45')])[_0x4f49('0x26')](respondWithResult(_0x93e85d,null))[_0x4f49('0x48')](handleError(_0x93e85d,null));};exports[_0x4f49('0xa4')]=runReport;exports[_0x4f49('0x36')]=function(_0x40991b,_0x56290f){var _0x4994b6=0xa;var _0x1c7d87=[_0x4f49('0x55'),_0x4f49('0x56'),_0x4f49('0x85'),_0x4f49('0x57')];var _0x5cd00a={'SUM':_0x4f49('0x86'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x4f49('0x58'),'MAX':'MAX(%s)','MIN':'MIN(%s)','AVG':_0x4f49('0x5b'),'GROUP_CONCAT':_0x4f49('0x5c'),'GROUP_CONCAT ASC':_0x4f49('0x87'),'GROUP_CONCAT DESC':_0x4f49('0x5d')};var _0xd876f1={'SEC_TO_TIME':_0x4f49('0x5e'),'DATE':_0x4f49('0x5f'),'HOUR':'HOUR(%s)','ROUND':_0x4f49('0x88'),'UNIX_TIMESTAMP':_0x4f49('0x61')};var _0x1ae2c9=function(_0x566634){return!_[_0x4f49('0x62')]([_0x4f49('0x89'),_0x4f49('0x63'),'IS\x20EMPTY',_0x4f49('0xa5')],_0x566634);};var _0x541dc2=function(_0x4061bf){if(!_0x4061bf||!_0x4061bf[_0x4f49('0x65')][_0x4f49('0x3c')]){return'';}for(var _0x1bc18d='(',_0x5e6103=0x0;_0x5e6103<_0x4061bf[_0x4f49('0x65')][_0x4f49('0x3c')];_0x5e6103+=0x1){_0x5e6103>0x0&&(_0x1bc18d+='\x20'+_0x4061bf[_0x4f49('0x8a')]+'\x20');_0x1bc18d+=_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x66')]?_0x541dc2(_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x66')]):_0x4061bf[_0x4f49('0x65')][_0x5e6103]['field']+'\x20'+_0x4061bf['rules'][_0x5e6103][_0x4f49('0x8b')]+(_0x1ae2c9(_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x8b')])?'\x20'+_0x4061bf[_0x4f49('0x65')][_0x5e6103][_0x4f49('0x68')]:'');}return _0x1bc18d+')';};var _0x29dbab={'where':{'id':_0x40991b[_0x4f49('0x54')]['id']}},_0x5f459b,_0x1d090f,_0x37d2f4,_0x5bcb36,_0x3f04fa;_0x29dbab=_[_0x4f49('0x43')]({},_0x29dbab,_0x40991b['options']);return db['AnalyticDefaultReport'][_0x4f49('0x4b')](_0x29dbab)[_0x4f49('0x26')](function(_0x200848){if(_0x200848){_0x5f459b=_0x200848;return _0x200848['getFields']();}return null;})[_0x4f49('0x26')](function(_0x48f4bc){if(_0x48f4bc){if(!_0x48f4bc[_0x4f49('0x3c')]){throw new db['Sequelize'][(_0x4f49('0x6a'))](_0x4f49('0x6b'),0x193);}_0x1d090f=_0x48f4bc;return db['AnalyticMetric'][_0x4f49('0x47')]({'raw':!![]});}return null;})[_0x4f49('0x26')](function(_0x513bc9){if(_0x513bc9){_0x37d2f4=_[_0x4f49('0x6d')](_0x513bc9,'id');var _0x47567c;var _0x5f1538=squel[_0x4f49('0x6e')]();_0x5f1538[_0x4f49('0x6f')](_0x5f459b[_0x4f49('0x70')]);for(var _0xd91e48=0x0;_0xd91e48<_0x1d090f[_0x4f49('0x3c')];_0xd91e48+=0x1){_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x71')]?_0x37d2f4[_0x1d090f[_0xd91e48]['MetricId']][_0x4f49('0x72')]:_0x1d090f[_0xd91e48][_0x4f49('0x67')];_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x73')]?_['replace'](_0x5cd00a[_0x1d090f[_0xd91e48][_0x4f49('0x73')]],'%s',_0x47567c):_0x47567c;_0x47567c=_0x1d090f[_0xd91e48][_0x4f49('0x75')]?_[_0x4f49('0x74')](_0xd876f1[_0x1d090f[_0xd91e48][_0x4f49('0x75')]],'%s',_0x47567c):_0x47567c;if(_0x1d090f[_0xd91e48][_0x4f49('0x8d')]){_0x5f1538[_0x4f49('0x66')](_0x47567c);}_0x1d090f[_0xd91e48][_0x4f49('0x76')]&&_0x5f1538['order'](_0x47567c,_0x1d090f[_0xd91e48][_0x4f49('0x76')]==='DESC'?![]:!![]);_0x5f1538['field'](_0x47567c,_0x1d090f[_0xd91e48][_0x4f49('0x78')]||_0x47567c);}if(_0x5f459b['joins']){_0x5f459b[_0x4f49('0x79')]=JSON[_0x4f49('0x7a')](_0x5f459b[_0x4f49('0x79')]);for(var _0x85eb3f=0x0;_0x85eb3f<_0x5f459b[_0x4f49('0x79')][_0x4f49('0x3c')];_0x85eb3f+=0x1){if(_0x5f459b['joins'][_0x85eb3f][_0x4f49('0x33')]&&_[_0x4f49('0x62')](_0x1c7d87,_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x33')])&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7d')]&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f]['foreignTable']&&_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7e')]){_0x5f1538[_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x33')]](_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7b')],null,util[_0x4f49('0x75')](_0x4f49('0x7c'),_0x5f459b[_0x4f49('0x70')],_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7d')],_0x5f459b[_0x4f49('0x79')][_0x85eb3f]['foreignTable'],_0x5f459b[_0x4f49('0x79')][_0x85eb3f][_0x4f49('0x7e')]));}}}if(_0x5f459b['conditions']){_0x5f459b[_0x4f49('0x7f')]=JSON[_0x4f49('0x7a')](_0x5f459b[_0x4f49('0x7f')]);_0x5f1538[_0x4f49('0x40')](_0x541dc2(_0x5f459b[_0x4f49('0x7f')][_0x4f49('0x66')]));}_0x3f04fa=_0x5f1538['clone']();_0x5f1538['limit'](_0x4994b6);_0x5f1538['offset'](0x0);logger['debug'](_0x4f49('0x81'),_0x5f1538['toString']());return dbH[_0x4f49('0x82')][_0x4f49('0x36')](_0x5f1538[_0x4f49('0x83')](),{'type':dbH[_0x4f49('0x82')][_0x4f49('0x84')][_0x4f49('0xa2')]});}})['then'](function(){return{'sql':_0x3f04fa[_0x4f49('0x83')]()};})['then'](respondWithResult(_0x56290f,null))[_0x4f49('0x48')](handleError(_0x56290f,null));};
\ No newline at end of file