Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index fe650e5..57074ee 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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(_0x92850b,_0xc43190){var _0x138c1f=function(_0x1587a3){while(--_0x1587a3){_0x92850b['push'](_0x92850b['shift']());}};_0x138c1f(++_0xc43190);}(_0xf494,0x1c6));var _0x4f49=function(_0x2f7c43,_0x5ca843){_0x2f7c43=_0x2f7c43-0x0;var _0x3da68f=_0xf494[_0x2f7c43];return _0x3da68f;};'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
+var _0x46ed=['SEC_TO_TIME(%s)','value','AnalyticMetric','select','DESC','output','fullPath','%s-%s.%s','randomstring','csv','default','AnalyticExtractedReport','cdr','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','endDate','info','Run\x20Query:','child_process','../../files/reports','savename','countTable','COUNT(*)','sequelize','runReport','left_join','COUNT(%s)','MIN(%s)','AVG(%s)','Limited\x20Query:','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','get','DefaultReports','UserProfileResource','destroy','sendStatus','error','stack','name','send','index','map','AnalyticDefaultReport','rawAttributes','fieldName','type','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','merge','options','includeAll','include','findAll','catch','params','find','create','body','user','Reports','UserProfileSection','userProfileId','autoAssociation','preview','join','right_join','cross_join','SUM(%s)','COUNT(DISTINCT\x20%s)','MAX(%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)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','keyBy','from','table','MetricId','metric','function','replace','format','groupBy','orderBy','order','alias','joins','parentKey','foreignKey','foreignTable','%s.%s\x20=\x20%s.%s','conditions','parse','clone','toString','QueryTypes','SELECT'];(function(_0x38f530,_0xce8ca4){var _0x569092=function(_0x57fbce){while(--_0x57fbce){_0x38f530['push'](_0x38f530['shift']());}};_0x569092(++_0xce8ca4);}(_0x46ed,0x168));var _0xd46e=function(_0x178e48,_0x3c9509){_0x178e48=_0x178e48-0x0;var _0x440d7e=_0x46ed[_0x178e48];return _0x440d7e;};'use strict';var emlformat=require(_0xd46e('0x0'));var rimraf=require(_0xd46e('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd46e('0x2'));var rp=require(_0xd46e('0x3'));var moment=require(_0xd46e('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xd46e('0x5'));var util=require(_0xd46e('0x6'));var path=require('path');var sox=require(_0xd46e('0x7'));var csv=require(_0xd46e('0x8'));var ejs=require(_0xd46e('0x9'));var fs=require('fs');var fs_extra=require(_0xd46e('0xa'));var _=require(_0xd46e('0xb'));var squel=require(_0xd46e('0xc'));var crypto=require(_0xd46e('0xd'));var jsforce=require(_0xd46e('0xe'));var deskjs=require(_0xd46e('0xf'));var toCsv=require(_0xd46e('0x8'));var querystring=require(_0xd46e('0x10'));var Papa=require('papaparse');var Redis=require(_0xd46e('0x11'));var authService=require(_0xd46e('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xd46e('0x13'));var hardwareService=require(_0xd46e('0x14'));var logger=require(_0xd46e('0x15'))(_0xd46e('0x16'));var utils=require(_0xd46e('0x17'));var config=require(_0xd46e('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xd46e('0x19'))['db'];var dbH=require('../../mysqldb')['dbH'];function respondWithStatusCode(_0xf3048c,_0x27dbfb){_0x27dbfb=_0x27dbfb||0xcc;return function(_0x53b309){if(_0x53b309){return _0xf3048c['sendStatus'](_0x27dbfb);}return _0xf3048c[_0xd46e('0x1a')](_0x27dbfb)[_0xd46e('0x1b')]();};}function respondWithResult(_0x1e9aae,_0x3fdf88){_0x3fdf88=_0x3fdf88||0xc8;return function(_0x50c7c3){if(_0x50c7c3){return _0x1e9aae[_0xd46e('0x1a')](_0x3fdf88)[_0xd46e('0x1c')](_0x50c7c3);}};}function respondWithFilteredResult(_0x417402,_0x3d72ce){return function(_0x36a317){if(_0x36a317){var _0x47fa8f=typeof _0x3d72ce[_0xd46e('0x1d')]===_0xd46e('0x1e')&&typeof _0x3d72ce[_0xd46e('0x1f')]==='undefined';var _0x5ddd04=_0x36a317[_0xd46e('0x20')];var _0x1bd574=_0x47fa8f?0x0:_0x3d72ce['offset'];var _0x4fd1f2=_0x47fa8f?_0x36a317[_0xd46e('0x20')]:_0x3d72ce[_0xd46e('0x1d')]+_0x3d72ce[_0xd46e('0x1f')];var _0x2273c5;if(_0x4fd1f2>=_0x5ddd04){_0x4fd1f2=_0x5ddd04;_0x2273c5=0xc8;}else{_0x2273c5=0xce;}_0x417402[_0xd46e('0x1a')](_0x2273c5);return _0x417402[_0xd46e('0x21')](_0xd46e('0x22'),_0x1bd574+'-'+_0x4fd1f2+'/'+_0x5ddd04)[_0xd46e('0x1c')](_0x36a317);}return null;};}function patchUpdates(_0xb4940){return function(_0x3c7e91){try{jsonpatch[_0xd46e('0x23')](_0x3c7e91,_0xb4940,!![]);}catch(_0x5ba94d){return BPromise[_0xd46e('0x24')](_0x5ba94d);}return _0x3c7e91[_0xd46e('0x25')]();};}function saveUpdates(_0x79aa51,_0x45ce0b){return function(_0x128246){if(_0x128246){return _0x128246[_0xd46e('0x26')](_0x79aa51)[_0xd46e('0x27')](function(_0x8a1be){return _0x8a1be;});}return null;};}function removeEntity(_0x62dea5,_0x4cf899){return function(_0x314570){if(_0x314570){return _0x314570['destroy']()['then'](function(){var _0x371054=_0x314570[_0xd46e('0x28')]({'plain':!![]});var _0x21135f=_0xd46e('0x29');return db[_0xd46e('0x2a')][_0xd46e('0x2b')]({'where':{'type':_0x21135f,'resourceId':_0x371054['id']}})[_0xd46e('0x27')](function(){return _0x314570;});})['then'](function(){_0x62dea5[_0xd46e('0x1a')](0xcc)[_0xd46e('0x1b')]();});}};}function handleEntityNotFound(_0xddbce9,_0x17db79){return function(_0x96f15c){if(!_0x96f15c){_0xddbce9[_0xd46e('0x2c')](0x194);}return _0x96f15c;};}function handleError(_0x58aeef,_0x465d54){_0x465d54=_0x465d54||0x1f4;return function(_0x3a1ced){logger[_0xd46e('0x2d')](_0x3a1ced[_0xd46e('0x2e')]);if(_0x3a1ced[_0xd46e('0x2f')]){delete _0x3a1ced[_0xd46e('0x2f')];}_0x58aeef[_0xd46e('0x1a')](_0x465d54)[_0xd46e('0x30')](_0x3a1ced);};}exports[_0xd46e('0x31')]=function(_0x45ea47,_0x2ff785){var _0x504324={},_0x2f4a1b={},_0x5ed8dc={'count':0x0,'rows':[]};var _0x1248ce=_[_0xd46e('0x32')](db[_0xd46e('0x33')][_0xd46e('0x34')],function(_0x5ef248){return{'name':_0x5ef248[_0xd46e('0x35')],'type':_0x5ef248[_0xd46e('0x36')]['key']};});_0x2f4a1b[_0xd46e('0x37')]=_[_0xd46e('0x32')](_0x1248ce,'name');_0x2f4a1b[_0xd46e('0x38')]=_[_0xd46e('0x39')](_0x45ea47[_0xd46e('0x38')]);_0x2f4a1b['filters']=_['intersection'](_0x2f4a1b[_0xd46e('0x37')],_0x2f4a1b[_0xd46e('0x38')]);_0x504324[_0xd46e('0x3a')]=_[_0xd46e('0x3b')](_0x2f4a1b[_0xd46e('0x37')],qs[_0xd46e('0x3c')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x3c')]));_0x504324['attributes']=_0x504324[_0xd46e('0x3a')][_0xd46e('0x3d')]?_0x504324[_0xd46e('0x3a')]:_0x2f4a1b[_0xd46e('0x37')];if(!_0x45ea47[_0xd46e('0x38')][_0xd46e('0x3e')](_0xd46e('0x3f'))){_0x504324['limit']=qs[_0xd46e('0x1f')](_0x45ea47[_0xd46e('0x38')]['limit']);_0x504324[_0xd46e('0x1d')]=qs[_0xd46e('0x1d')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x1d')]);}_0x504324['order']=qs[_0xd46e('0x40')](_0x45ea47[_0xd46e('0x38')][_0xd46e('0x40')]);_0x504324[_0xd46e('0x41')]=qs[_0xd46e('0x42')](_[_0xd46e('0x43')](_0x45ea47[_0xd46e('0x38')],_0x2f4a1b[_0xd46e('0x42')]),_0x1248ce);if(_0x45ea47['query'][_0xd46e('0x44')]){_0x504324[_0xd46e('0x41')]=_[_0xd46e('0x45')](_0x504324[_0xd46e('0x41')],{'$or':_[_0xd46e('0x32')](_0x1248ce,function(_0x56f99c){if(_0x56f99c[_0xd46e('0x36')]!=='VIRTUAL'){var _0x55230d={};_0x55230d[_0x56f99c['name']]={'$like':'%'+_0x45ea47['query'][_0xd46e('0x44')]+'%'};return _0x55230d;}})});}_0x504324=_['merge']({},_0x504324,_0x45ea47[_0xd46e('0x46')]);var _0x40720e={'where':_0x504324['where']};return db[_0xd46e('0x33')][_0xd46e('0x20')](_0x40720e)[_0xd46e('0x27')](function(_0x31ba12){_0x5ed8dc[_0xd46e('0x20')]=_0x31ba12;if(_0x45ea47[_0xd46e('0x38')][_0xd46e('0x47')]){_0x504324[_0xd46e('0x48')]=[{'all':!![]}];}return db[_0xd46e('0x33')][_0xd46e('0x49')](_0x504324);})[_0xd46e('0x27')](function(_0x5ea048){_0x5ed8dc['rows']=_0x5ea048;return _0x5ed8dc;})['then'](respondWithFilteredResult(_0x2ff785,_0x504324))[_0xd46e('0x4a')](handleError(_0x2ff785,null));};exports['show']=function(_0x168d35,_0x272f5f){var _0x3fdf67={'raw':!![],'where':{'id':_0x168d35[_0xd46e('0x4b')]['id']}},_0x416505={};_0x416505[_0xd46e('0x37')]=_[_0xd46e('0x39')](db[_0xd46e('0x33')]['rawAttributes']);_0x416505[_0xd46e('0x38')]=_['keys'](_0x168d35[_0xd46e('0x38')]);_0x416505[_0xd46e('0x42')]=_[_0xd46e('0x3b')](_0x416505[_0xd46e('0x37')],_0x416505[_0xd46e('0x38')]);_0x3fdf67['attributes']=_[_0xd46e('0x3b')](_0x416505[_0xd46e('0x37')],qs[_0xd46e('0x3c')](_0x168d35[_0xd46e('0x38')][_0xd46e('0x3c')]));_0x3fdf67['attributes']=_0x3fdf67[_0xd46e('0x3a')][_0xd46e('0x3d')]?_0x3fdf67[_0xd46e('0x3a')]:_0x416505[_0xd46e('0x37')];if(_0x168d35[_0xd46e('0x38')]['includeAll']){_0x3fdf67[_0xd46e('0x48')]=[{'all':!![]}];}_0x3fdf67=_[_0xd46e('0x45')]({},_0x3fdf67,_0x168d35[_0xd46e('0x46')]);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0x3fdf67)[_0xd46e('0x27')](handleEntityNotFound(_0x272f5f,null))[_0xd46e('0x27')](respondWithResult(_0x272f5f,null))[_0xd46e('0x4a')](handleError(_0x272f5f,null));};exports['create']=function(_0xf9dab,_0x71a8dc){return db[_0xd46e('0x33')][_0xd46e('0x4d')](_0xf9dab[_0xd46e('0x4e')],{})['then'](function(_0x4ae314){var _0x3a94cf=_0xf9dab[_0xd46e('0x4f')][_0xd46e('0x28')]({'plain':!![]});if(!_0x3a94cf)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3a94cf['role']===_0xd46e('0x4f')){var _0x9d8638=_0x4ae314['get']({'plain':!![]});var _0x2eee92=_0xd46e('0x50');return db[_0xd46e('0x51')][_0xd46e('0x4c')]({'where':{'name':_0x2eee92,'userProfileId':_0x3a94cf[_0xd46e('0x52')]},'raw':!![]})[_0xd46e('0x27')](function(_0x80ed51){if(_0x80ed51&&_0x80ed51[_0xd46e('0x53')]===0x0){return db['UserProfileResource'][_0xd46e('0x4d')]({'name':_0x9d8638[_0xd46e('0x2f')],'resourceId':_0x9d8638['id'],'type':_0xd46e('0x29'),'sectionId':_0x80ed51['id']},{})[_0xd46e('0x27')](function(){return _0x4ae314;});}else{return _0x4ae314;}})['catch'](function(_0x56dd9a){logger[_0xd46e('0x2d')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x56dd9a);throw _0x56dd9a;});}return _0x4ae314;})[_0xd46e('0x27')](respondWithResult(_0x71a8dc,0xc9))[_0xd46e('0x4a')](handleError(_0x71a8dc,null));};exports[_0xd46e('0x26')]=function(_0x31f7eb,_0x5a7870){if(_0x31f7eb[_0xd46e('0x4e')]['id']){delete _0x31f7eb['body']['id'];}return db[_0xd46e('0x33')][_0xd46e('0x4c')]({'where':{'id':_0x31f7eb[_0xd46e('0x4b')]['id']}})['then'](handleEntityNotFound(_0x5a7870,null))[_0xd46e('0x27')](saveUpdates(_0x31f7eb[_0xd46e('0x4e')],null))[_0xd46e('0x27')](respondWithResult(_0x5a7870,null))[_0xd46e('0x4a')](handleError(_0x5a7870,null));};exports[_0xd46e('0x2b')]=function(_0x2cc676,_0x2760ef){return db[_0xd46e('0x33')][_0xd46e('0x4c')]({'where':{'id':_0x2cc676[_0xd46e('0x4b')]['id']}})[_0xd46e('0x27')](handleEntityNotFound(_0x2760ef,null))[_0xd46e('0x27')](removeEntity(_0x2760ef,null))[_0xd46e('0x4a')](handleError(_0x2760ef,null));};exports[_0xd46e('0x54')]=function(_0x47a86c,_0x3ec709){var _0x37a22f=0xa;var _0xe0cd61=[_0xd46e('0x55'),'left_join',_0xd46e('0x56'),_0xd46e('0x57')];var _0xaf9641={'SUM':_0xd46e('0x58'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':_0xd46e('0x5c'),'GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x481dce={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':_0xd46e('0x61')};var _0x2dacb4=function(_0x2f9fcb){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),_0xd46e('0x64'),_0xd46e('0x65'),_0xd46e('0x66')],_0x2f9fcb);};var _0x1aaa99=function(_0x272514){if(!_0x272514||!_0x272514[_0xd46e('0x67')][_0xd46e('0x3d')]){return'';}for(var _0x476f09='(',_0x5067b7=0x0;_0x5067b7<_0x272514[_0xd46e('0x67')][_0xd46e('0x3d')];_0x5067b7+=0x1){_0x5067b7>0x0&&(_0x476f09+='\x20'+_0x272514[_0xd46e('0x68')]+'\x20');_0x476f09+=_0x272514['rules'][_0x5067b7][_0xd46e('0x69')]?_0x1aaa99(_0x272514[_0xd46e('0x67')][_0x5067b7]['group']):_0x272514[_0xd46e('0x67')][_0x5067b7][_0xd46e('0x6a')]+'\x20'+_0x272514[_0xd46e('0x67')][_0x5067b7]['condition']+(_0x2dacb4(_0x272514[_0xd46e('0x67')][_0x5067b7][_0xd46e('0x6b')])?'\x20'+_0x272514[_0xd46e('0x67')][_0x5067b7]['value']:'');}return _0x476f09+')';};var _0xe5f8cd={'where':{'id':_0x47a86c[_0xd46e('0x4b')]['id']}},_0x516e7d,_0x32eed0,_0x148187,_0x35db1b,_0x4f3ba0;_0xe5f8cd=_[_0xd46e('0x45')]({},_0xe5f8cd,_0x47a86c[_0xd46e('0x46')]);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0xe5f8cd)[_0xd46e('0x27')](function(_0x16f906){if(_0x16f906){_0x516e7d=_0x16f906;return _0x16f906[_0xd46e('0x6c')]();}return null;})[_0xd46e('0x27')](function(_0x3e55a3){if(_0x3e55a3){if(!_0x3e55a3[_0xd46e('0x3d')]){throw new db[(_0xd46e('0x6d'))][(_0xd46e('0x6e'))](_0xd46e('0x6f'),0x193);}_0x32eed0=_0x3e55a3;return db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0xd46e('0x27')](function(_0x3e0ed5){if(_0x3e0ed5){_0x148187=_[_0xd46e('0x70')](_0x3e0ed5,'id');var _0x2fff69;var _0x249938=squel['select']();_0x249938[_0xd46e('0x71')](_0x516e7d[_0xd46e('0x72')]);for(var _0xfb4073=0x0;_0xfb4073<_0x32eed0[_0xd46e('0x3d')];_0xfb4073+=0x1){_0x2fff69=_0x32eed0[_0xfb4073]['MetricId']?_0x148187[_0x32eed0[_0xfb4073][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x32eed0[_0xfb4073]['field'];_0x2fff69=_0x32eed0[_0xfb4073][_0xd46e('0x75')]?_[_0xd46e('0x76')](_0xaf9641[_0x32eed0[_0xfb4073]['function']],'%s',_0x2fff69):_0x2fff69;_0x2fff69=_0x32eed0[_0xfb4073][_0xd46e('0x77')]?_[_0xd46e('0x76')](_0x481dce[_0x32eed0[_0xfb4073]['format']],'%s',_0x2fff69):_0x2fff69;if(_0x32eed0[_0xfb4073][_0xd46e('0x78')]){_0x249938['group'](_0x2fff69);}_0x32eed0[_0xfb4073][_0xd46e('0x79')]&&_0x249938[_0xd46e('0x7a')](_0x2fff69,_0x32eed0[_0xfb4073]['orderBy']==='DESC'?![]:!![]);_0x249938[_0xd46e('0x6a')](_0x2fff69,_0x32eed0[_0xfb4073][_0xd46e('0x7b')]||_0x2fff69);}if(_0x516e7d[_0xd46e('0x7c')]){_0x516e7d[_0xd46e('0x7c')]=JSON['parse'](_0x516e7d[_0xd46e('0x7c')]);for(var _0x372509=0x0;_0x372509<_0x516e7d['joins'][_0xd46e('0x3d')];_0x372509+=0x1){if(_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0xe0cd61,_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x36')])&&_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7d')]&&_0x516e7d[_0xd46e('0x7c')][_0x372509]['foreignTable']&&_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7e')]){_0x249938[_0x516e7d['joins'][_0x372509][_0xd46e('0x36')]](_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7f')],null,util[_0xd46e('0x77')](_0xd46e('0x80'),_0x516e7d[_0xd46e('0x72')],_0x516e7d['joins'][_0x372509]['parentKey'],_0x516e7d[_0xd46e('0x7c')][_0x372509][_0xd46e('0x7f')],_0x516e7d['joins'][_0x372509]['foreignKey']));}}}if(_0x516e7d['conditions']){_0x516e7d[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0x516e7d[_0xd46e('0x81')]);_0x249938['where'](_0x1aaa99(_0x516e7d[_0xd46e('0x81')][_0xd46e('0x69')]));}_0x4f3ba0=_0x249938[_0xd46e('0x83')]();_0x249938['limit'](_0x37a22f);_0x249938['offset'](0x0);logger['debug']('Limited\x20Query:',_0x249938[_0xd46e('0x84')]());return dbH['sequelize'][_0xd46e('0x38')](_0x249938['toString'](),{'type':dbH['sequelize'][_0xd46e('0x85')][_0xd46e('0x86')]});}})[_0xd46e('0x27')](respondWithResult(_0x3ec709,null))[_0xd46e('0x4a')](handleError(_0x3ec709,null));};function runReport(_0xf16d87,_0x99872a,_0x57a7cc){var _0x586024=_0x99872a[_0xd46e('0x2f')];var _0x383919=0xa;var _0x114f2c=[_0xd46e('0x55'),'left_join',_0xd46e('0x56'),_0xd46e('0x57')];var _0x4ca21f={'SUM':_0xd46e('0x58'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':_0xd46e('0x5c'),'GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x5ef4cc={'SEC_TO_TIME':_0xd46e('0x87'),'DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':_0xd46e('0x61')};var _0x88460a=function(_0x3a3744){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),_0xd46e('0x64'),_0xd46e('0x65'),_0xd46e('0x66')],_0x3a3744);};var _0x3c476d=function(_0x1b2a6d){if(!_0x1b2a6d||!_0x1b2a6d[_0xd46e('0x67')][_0xd46e('0x3d')]){return'';}for(var _0x441f73='(',_0x1d2738=0x0;_0x1d2738<_0x1b2a6d['rules'][_0xd46e('0x3d')];_0x1d2738+=0x1){_0x1d2738>0x0&&(_0x441f73+='\x20'+_0x1b2a6d['operator']+'\x20');_0x441f73+=_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x69')]?_0x3c476d(_0x1b2a6d['rules'][_0x1d2738][_0xd46e('0x69')]):_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6a')]+'\x20'+_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6b')]+(_0x88460a(_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x6b')])?'\x20'+_0x1b2a6d[_0xd46e('0x67')][_0x1d2738][_0xd46e('0x88')]:'');}return _0x441f73+')';};var _0x3fa34d={'where':{'id':_0xf16d87['id']}},_0xc098c9,_0x5f5ba7,_0x493df5,_0x18e140,_0x459a0c;_0x3fa34d=_[_0xd46e('0x45')]({},_0x3fa34d,_0x57a7cc);return db[_0xd46e('0x33')][_0xd46e('0x4c')](_0x3fa34d)[_0xd46e('0x27')](function(_0x5b554e){if(_0x5b554e){_0xc098c9=_0x5b554e;return _0x5b554e[_0xd46e('0x6c')]();}return null;})[_0xd46e('0x27')](function(_0xa254f5){if(_0xa254f5){if(!_0xa254f5[_0xd46e('0x3d')]){throw new db[(_0xd46e('0x6d'))][(_0xd46e('0x6e'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x5f5ba7=_0xa254f5;return db[_0xd46e('0x89')][_0xd46e('0x49')]({'raw':!![]});}return null;})['then'](function(_0x3c8d68){if(_0x3c8d68){_0x493df5=_[_0xd46e('0x70')](_0x3c8d68,'id');var _0x9e222d;var _0x3da17e=squel[_0xd46e('0x8a')]();_0x3da17e[_0xd46e('0x71')](_0xc098c9[_0xd46e('0x72')]);for(var _0x282f71=0x0;_0x282f71<_0x5f5ba7[_0xd46e('0x3d')];_0x282f71+=0x1){_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x73')]?_0x493df5[_0x5f5ba7[_0x282f71][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x5f5ba7[_0x282f71][_0xd46e('0x6a')];_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x75')]?_['replace'](_0x4ca21f[_0x5f5ba7[_0x282f71]['function']],'%s',_0x9e222d):_0x9e222d;_0x9e222d=_0x5f5ba7[_0x282f71][_0xd46e('0x77')]?_[_0xd46e('0x76')](_0x5ef4cc[_0x5f5ba7[_0x282f71][_0xd46e('0x77')]],'%s',_0x9e222d):_0x9e222d;if(_0x5f5ba7[_0x282f71][_0xd46e('0x78')]){_0x3da17e[_0xd46e('0x69')](_0x9e222d);}_0x5f5ba7[_0x282f71][_0xd46e('0x79')]&&_0x3da17e['order'](_0x9e222d,_0x5f5ba7[_0x282f71][_0xd46e('0x79')]===_0xd46e('0x8b')?![]:!![]);_0x3da17e[_0xd46e('0x6a')](_0x9e222d,_0x5f5ba7[_0x282f71][_0xd46e('0x7b')]||_0x9e222d);}if(_0xc098c9['joins']){_0xc098c9[_0xd46e('0x7c')]=JSON[_0xd46e('0x82')](_0xc098c9['joins']);for(var _0xdf967c=0x0;_0xdf967c<_0xc098c9['joins']['length'];_0xdf967c+=0x1){if(_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0x114f2c,_0xc098c9[_0xd46e('0x7c')][_0xdf967c]['type'])&&_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7d')]&&_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7f')]&&_0xc098c9['joins'][_0xdf967c]['foreignKey']){_0x3da17e[_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x36')]](_0xc098c9['joins'][_0xdf967c]['foreignTable'],null,util[_0xd46e('0x77')](_0xd46e('0x80'),_0xc098c9[_0xd46e('0x72')],_0xc098c9[_0xd46e('0x7c')][_0xdf967c]['parentKey'],_0xc098c9[_0xd46e('0x7c')][_0xdf967c][_0xd46e('0x7f')],_0xc098c9['joins'][_0xdf967c][_0xd46e('0x7e')]));}}}if(_0xc098c9[_0xd46e('0x81')]){_0xc098c9[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0xc098c9[_0xd46e('0x81')]);_0x3da17e[_0xd46e('0x41')](_0x3c476d(_0xc098c9['conditions'][_0xd46e('0x69')]));}_0x459a0c=_0x3da17e[_0xd46e('0x83')]();_0x3da17e['limit'](_0x383919);_0x3da17e['offset'](0x0);return;}})[_0xd46e('0x27')](function(){if(_0x99872a[_0xd46e('0x8c')]==='web'){return null;}var _0x5e637d=_[_0xd46e('0x45')](_0x99872a,{'name':_0x99872a[_0xd46e('0x8d')]||_0x99872a['name']||_0xc098c9[_0xd46e('0x2f')],'basename':_0x586024,'savename':util[_0xd46e('0x77')](_0xd46e('0x8e'),_0x99872a[_0xd46e('0x2f')]||_0xc098c9[_0xd46e('0x2f')],require(_0xd46e('0x8f'))['generate'](0x4),_0x99872a[_0xd46e('0x8c')]||_0xd46e('0x90')),'reportId':_0xc098c9['id'],'reportType':_0xd46e('0x91')});return db[_0xd46e('0x92')][_0xd46e('0x4d')](_0x5e637d,{'raw':!![]});})[_0xd46e('0x27')](function(_0x3311a6){if(_0xc098c9[_0xd46e('0x72')]===_0xd46e('0x93')){_0x459a0c[_0xd46e('0x41')](_0xc098c9[_0xd46e('0x72')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x99872a[_0xd46e('0x94')],_0x99872a['endDate']);}else{_0x459a0c['where'](_0xc098c9[_0xd46e('0x72')]+_0xd46e('0x95'),_0x99872a[_0xd46e('0x94')],_0x99872a[_0xd46e('0x96')]);}if(_0x3311a6){logger[_0xd46e('0x97')](_0xd46e('0x98'),_0x459a0c[_0xd46e('0x84')]());require(_0xd46e('0x99'))['fork'](path[_0xd46e('0x55')](__dirname,'../../components/export/',_0x3311a6[_0xd46e('0x8c')]),[_0x3311a6['id'],_0x459a0c[_0xd46e('0x84')](),path[_0xd46e('0x55')](__dirname,_0xd46e('0x9a'),_0x3311a6[_0xd46e('0x9b')]),_0x586024]);return _0x3311a6;}else{var _0x399918=squel[_0xd46e('0x8a')]();_0x399918[_0xd46e('0x71')]('('+_0x459a0c['toString']()+')',_0xd46e('0x9c'));_0x399918[_0xd46e('0x6a')](_0xd46e('0x9d'),'count');_0x459a0c[_0xd46e('0x1f')](_0x99872a[_0xd46e('0x1f')]||_0x383919);_0x459a0c[_0xd46e('0x1d')](_0x99872a['offset']||0x0);return dbH[_0xd46e('0x9e')][_0xd46e('0x38')](_0x399918[_0xd46e('0x84')](),{'type':dbH[_0xd46e('0x9e')][_0xd46e('0x85')][_0xd46e('0x86')]})['then'](function(_0x4967ff){if(!_0x4967ff[_0xd46e('0x3d')]){_0x18e140=0x0;}else{_0x18e140=_0x4967ff[0x0][_0xd46e('0x20')]||0x0;}return dbH['sequelize'][_0xd46e('0x38')](_0x459a0c[_0xd46e('0x84')](),{'type':dbH[_0xd46e('0x9e')][_0xd46e('0x85')][_0xd46e('0x86')]});})[_0xd46e('0x27')](function(_0x4bb76b){return{'rows':_0x4bb76b||[],'count':_0x18e140};});}});}exports['run']=function(_0x204a9f,_0x52ca5a){return runReport(_0x204a9f[_0xd46e('0x4b')],_0x204a9f[_0xd46e('0x38')],_0x204a9f['options'])[_0xd46e('0x27')](respondWithResult(_0x52ca5a,null))[_0xd46e('0x4a')](handleError(_0x52ca5a,null));};exports[_0xd46e('0x9f')]=runReport;exports[_0xd46e('0x38')]=function(_0x786ae,_0x537c73){var _0x1610bd=0xa;var _0x20cc4c=[_0xd46e('0x55'),_0xd46e('0xa0'),_0xd46e('0x56'),_0xd46e('0x57')];var _0x368742={'SUM':_0xd46e('0x58'),'COUNT':_0xd46e('0xa1'),'COUNT DISTINCT':_0xd46e('0x59'),'MAX':_0xd46e('0x5a'),'MIN':_0xd46e('0xa2'),'AVG':_0xd46e('0xa3'),'GROUP_CONCAT':_0xd46e('0x5b'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xd46e('0x5d')};var _0x285cf8={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0xd46e('0x5e'),'HOUR':_0xd46e('0x5f'),'ROUND':_0xd46e('0x60'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0xc87da2=function(_0x195f02){return!_[_0xd46e('0x62')]([_0xd46e('0x63'),'IS\x20NOT\x20NULL',_0xd46e('0x65'),_0xd46e('0x66')],_0x195f02);};var _0x44322f=function(_0x49959f){if(!_0x49959f||!_0x49959f['rules'][_0xd46e('0x3d')]){return'';}for(var _0x2094e5='(',_0x85aac1=0x0;_0x85aac1<_0x49959f[_0xd46e('0x67')][_0xd46e('0x3d')];_0x85aac1+=0x1){_0x85aac1>0x0&&(_0x2094e5+='\x20'+_0x49959f[_0xd46e('0x68')]+'\x20');_0x2094e5+=_0x49959f['rules'][_0x85aac1][_0xd46e('0x69')]?_0x44322f(_0x49959f['rules'][_0x85aac1][_0xd46e('0x69')]):_0x49959f['rules'][_0x85aac1][_0xd46e('0x6a')]+'\x20'+_0x49959f['rules'][_0x85aac1]['condition']+(_0xc87da2(_0x49959f[_0xd46e('0x67')][_0x85aac1][_0xd46e('0x6b')])?'\x20'+_0x49959f[_0xd46e('0x67')][_0x85aac1][_0xd46e('0x88')]:'');}return _0x2094e5+')';};var _0x101a29={'where':{'id':_0x786ae[_0xd46e('0x4b')]['id']}},_0x3a44da,_0x417068,_0x52e73e,_0x206077,_0xe729b6;_0x101a29=_[_0xd46e('0x45')]({},_0x101a29,_0x786ae[_0xd46e('0x46')]);return db['AnalyticDefaultReport'][_0xd46e('0x4c')](_0x101a29)[_0xd46e('0x27')](function(_0x1d08bb){if(_0x1d08bb){_0x3a44da=_0x1d08bb;return _0x1d08bb['getFields']();}return null;})[_0xd46e('0x27')](function(_0x8c6ed1){if(_0x8c6ed1){if(!_0x8c6ed1['length']){throw new db['Sequelize']['ValidationErrorItem'](_0xd46e('0x6f'),0x193);}_0x417068=_0x8c6ed1;return db[_0xd46e('0x89')]['findAll']({'raw':!![]});}return null;})[_0xd46e('0x27')](function(_0x3a13f8){if(_0x3a13f8){_0x52e73e=_['keyBy'](_0x3a13f8,'id');var _0x5a8661;var _0x157fb0=squel[_0xd46e('0x8a')]();_0x157fb0[_0xd46e('0x71')](_0x3a44da[_0xd46e('0x72')]);for(var _0x50750f=0x0;_0x50750f<_0x417068['length'];_0x50750f+=0x1){_0x5a8661=_0x417068[_0x50750f][_0xd46e('0x73')]?_0x52e73e[_0x417068[_0x50750f][_0xd46e('0x73')]][_0xd46e('0x74')]:_0x417068[_0x50750f][_0xd46e('0x6a')];_0x5a8661=_0x417068[_0x50750f][_0xd46e('0x75')]?_[_0xd46e('0x76')](_0x368742[_0x417068[_0x50750f][_0xd46e('0x75')]],'%s',_0x5a8661):_0x5a8661;_0x5a8661=_0x417068[_0x50750f]['format']?_[_0xd46e('0x76')](_0x285cf8[_0x417068[_0x50750f][_0xd46e('0x77')]],'%s',_0x5a8661):_0x5a8661;if(_0x417068[_0x50750f]['groupBy']){_0x157fb0[_0xd46e('0x69')](_0x5a8661);}_0x417068[_0x50750f][_0xd46e('0x79')]&&_0x157fb0[_0xd46e('0x7a')](_0x5a8661,_0x417068[_0x50750f][_0xd46e('0x79')]===_0xd46e('0x8b')?![]:!![]);_0x157fb0[_0xd46e('0x6a')](_0x5a8661,_0x417068[_0x50750f][_0xd46e('0x7b')]||_0x5a8661);}if(_0x3a44da[_0xd46e('0x7c')]){_0x3a44da['joins']=JSON[_0xd46e('0x82')](_0x3a44da[_0xd46e('0x7c')]);for(var _0x3c819b=0x0;_0x3c819b<_0x3a44da[_0xd46e('0x7c')][_0xd46e('0x3d')];_0x3c819b+=0x1){if(_0x3a44da['joins'][_0x3c819b][_0xd46e('0x36')]&&_[_0xd46e('0x62')](_0x20cc4c,_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x36')])&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7d')]&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')]&&_0x3a44da[_0xd46e('0x7c')][_0x3c819b]['foreignKey']){_0x157fb0[_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x36')]](_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')],null,util['format']('%s.%s\x20=\x20%s.%s',_0x3a44da[_0xd46e('0x72')],_0x3a44da['joins'][_0x3c819b][_0xd46e('0x7d')],_0x3a44da[_0xd46e('0x7c')][_0x3c819b][_0xd46e('0x7f')],_0x3a44da[_0xd46e('0x7c')][_0x3c819b]['foreignKey']));}}}if(_0x3a44da[_0xd46e('0x81')]){_0x3a44da[_0xd46e('0x81')]=JSON[_0xd46e('0x82')](_0x3a44da[_0xd46e('0x81')]);_0x157fb0[_0xd46e('0x41')](_0x44322f(_0x3a44da[_0xd46e('0x81')][_0xd46e('0x69')]));}_0xe729b6=_0x157fb0[_0xd46e('0x83')]();_0x157fb0[_0xd46e('0x1f')](_0x1610bd);_0x157fb0['offset'](0x0);logger['debug'](_0xd46e('0xa4'),_0x157fb0['toString']());return dbH[_0xd46e('0x9e')][_0xd46e('0x38')](_0x157fb0[_0xd46e('0x84')](),{'type':dbH['sequelize'][_0xd46e('0x85')][_0xd46e('0x86')]});}})[_0xd46e('0x27')](function(){return{'sql':_0xe729b6['toString']()};})['then'](respondWithResult(_0x537c73,null))[_0xd46e('0x4a')](handleError(_0x537c73,null));};
\ No newline at end of file