Built motion from commit (unavailable).|2.5.1
[motion2.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index ae8f331..07e94ef 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x60fa=['ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','field','condition','value','getFields','Sequelize','ValidationErrorItem','AnalyticMetric','keyBy','select','table','MetricId','function','format','replace','groupBy','orderBy','DESC','joins','parse','parentKey','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','conditions','clone','Limited\x20Query:','toString','sequelize','QueryTypes','SELECT','right_join','MAX(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','IS\x20NOT\x20NULL','Please\x20insert\x20at\x20least\x20one\x20field','from','metric','alias','output','web','%s-%s.%s','randomstring','generate','AnalyticExtractedReport','startDate','endDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','countTable','COUNT(*)','run','runReport','cross_join','HOUR(%s)','debug','html-pdf','rimraf','fast-json-patch','request-promise','moment','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','dbH','sendStatus','status','end','json','count','offset','set','apply','save','update','then','destroy','get','DefaultReports','error','name','send','index','map','rawAttributes','key','model','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','AnalyticDefaultReport','includeAll','include','findAll','show','params','length','find','create','body','role','user','UserProfileSection','autoAssociation','UserProfileResource','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','join','left_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','DATE(%s)'];(function(_0x245238,_0x326f25){var _0x1a64ee=function(_0x4f368b){while(--_0x4f368b){_0x245238['push'](_0x245238['shift']());}};_0x1a64ee(++_0x326f25);}(_0x60fa,0x181));var _0xa60f=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x60fa[_0x321bb2];return _0x9c12ed;};'use strict';var pdf=require(_0xa60f('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xa60f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa60f('0x2'));var rp=require(_0xa60f('0x3'));var moment=require(_0xa60f('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xa60f('0x5'));var path=require(_0xa60f('0x6'));var sox=require(_0xa60f('0x7'));var csv=require(_0xa60f('0x8'));var ejs=require(_0xa60f('0x9'));var fs=require('fs');var _=require(_0xa60f('0xa'));var squel=require(_0xa60f('0xb'));var crypto=require('crypto');var jsforce=require(_0xa60f('0xc'));var deskjs=require(_0xa60f('0xd'));var toCsv=require(_0xa60f('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xa60f('0xe'));var as=require(_0xa60f('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xa60f('0x10'));var utils=require(_0xa60f('0x11'));var config=require(_0xa60f('0x12'));var licenseUtil=require(_0xa60f('0x13'));var db=require('../../mysqldb')['db'];var dbH=require('../../mysqldb')[_0xa60f('0x14')];function respondWithStatusCode(_0x399619,_0x36f0ca){_0x36f0ca=_0x36f0ca||0xcc;return function(_0x760fc7){if(_0x760fc7){return _0x399619[_0xa60f('0x15')](_0x36f0ca);}return _0x399619[_0xa60f('0x16')](_0x36f0ca)[_0xa60f('0x17')]();};}function respondWithResult(_0x5f1317,_0x56328f){_0x56328f=_0x56328f||0xc8;return function(_0x510fc6){if(_0x510fc6){return _0x5f1317[_0xa60f('0x16')](_0x56328f)[_0xa60f('0x18')](_0x510fc6);}};}function respondWithFilteredResult(_0x9871c4,_0x50a627){return function(_0x3875eb){if(_0x3875eb){var _0x4dbec3=_0x3875eb[_0xa60f('0x19')],_0x284770=_0x50a627[_0xa60f('0x1a')],_0x2851d2=_0x50a627[_0xa60f('0x1a')]+_0x50a627['limit'],_0x3d8e77;if(_0x2851d2>=_0x4dbec3){_0x2851d2=_0x4dbec3;_0x3d8e77=0xc8;}else{_0x3d8e77=0xce;}_0x9871c4[_0xa60f('0x16')](_0x3d8e77);return _0x9871c4[_0xa60f('0x1b')]('Content-Range',_0x284770+'-'+_0x2851d2+'/'+_0x4dbec3)['json'](_0x3875eb);}return null;};}function patchUpdates(_0xe0199a){return function(_0x4e973f){try{jsonpatch[_0xa60f('0x1c')](_0x4e973f,_0xe0199a,!![]);}catch(_0x54e9f5){return BPromise['reject'](_0x54e9f5);}return _0x4e973f[_0xa60f('0x1d')]();};}function saveUpdates(_0x4c00ab,_0x38970c){return function(_0x2f00b4){if(_0x2f00b4){return _0x2f00b4[_0xa60f('0x1e')](_0x4c00ab)[_0xa60f('0x1f')](function(_0x2cf833){return _0x2cf833;});}return null;};}function removeEntity(_0x27b249,_0x126aae){return function(_0x3b5ae8){if(_0x3b5ae8){return _0x3b5ae8[_0xa60f('0x20')]()['then'](function(){var _0x48abfd=_0x3b5ae8[_0xa60f('0x21')]({'plain':!![]});var _0x3af65e=_0xa60f('0x22');return db['UserProfileResource'][_0xa60f('0x20')]({'where':{'type':_0x3af65e,'resourceId':_0x48abfd['id']}})[_0xa60f('0x1f')](function(){return _0x3b5ae8;});})[_0xa60f('0x1f')](function(){_0x27b249[_0xa60f('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1fb6ef,_0x5da7e0){return function(_0x2ad040){if(!_0x2ad040){_0x1fb6ef[_0xa60f('0x15')](0x194);}return _0x2ad040;};}function handleError(_0x5aafe5,_0x561748){_0x561748=_0x561748||0x1f4;return function(_0x330adf){logger[_0xa60f('0x23')](_0x330adf['stack']);if(_0x330adf[_0xa60f('0x24')]){delete _0x330adf['name'];}_0x5aafe5[_0xa60f('0x16')](_0x561748)[_0xa60f('0x25')](_0x330adf);};}exports[_0xa60f('0x26')]=function(_0x2d9bfb,_0x73301b){var _0x535236={},_0x4c4c5c={},_0x260eca={'count':0x0,'rows':[]};var _0xa5bfcd=_[_0xa60f('0x27')](db['AnalyticDefaultReport'][_0xa60f('0x28')],function(_0x4c70c6){return{'name':_0x4c70c6['fieldName'],'type':_0x4c70c6['type'][_0xa60f('0x29')]};});_0x4c4c5c[_0xa60f('0x2a')]=_[_0xa60f('0x27')](_0xa5bfcd,_0xa60f('0x24'));_0x4c4c5c['query']=_[_0xa60f('0x2b')](_0x2d9bfb[_0xa60f('0x2c')]);_0x4c4c5c[_0xa60f('0x2d')]=_[_0xa60f('0x2e')](_0x4c4c5c[_0xa60f('0x2a')],_0x4c4c5c['query']);_0x535236[_0xa60f('0x2f')]=_[_0xa60f('0x2e')](_0x4c4c5c['model'],qs[_0xa60f('0x30')](_0x2d9bfb[_0xa60f('0x2c')][_0xa60f('0x30')]));_0x535236[_0xa60f('0x2f')]=_0x535236[_0xa60f('0x2f')]['length']?_0x535236[_0xa60f('0x2f')]:_0x4c4c5c['model'];if(!_0x2d9bfb['query'][_0xa60f('0x31')](_0xa60f('0x32'))){_0x535236[_0xa60f('0x33')]=qs[_0xa60f('0x33')](_0x2d9bfb[_0xa60f('0x2c')][_0xa60f('0x33')]);_0x535236[_0xa60f('0x1a')]=qs[_0xa60f('0x1a')](_0x2d9bfb[_0xa60f('0x2c')]['offset']);}_0x535236[_0xa60f('0x34')]=qs['sort'](_0x2d9bfb[_0xa60f('0x2c')][_0xa60f('0x35')]);_0x535236['where']=qs['filters'](_[_0xa60f('0x36')](_0x2d9bfb[_0xa60f('0x2c')],_0x4c4c5c[_0xa60f('0x2d')]),_0xa5bfcd);if(_0x2d9bfb['query'][_0xa60f('0x37')]){_0x535236[_0xa60f('0x38')]=_[_0xa60f('0x39')](_0x535236[_0xa60f('0x38')],{'$or':_['map'](_0xa5bfcd,function(_0x327577){if(_0x327577[_0xa60f('0x3a')]!==_0xa60f('0x3b')){var _0x49bb4a={};_0x49bb4a[_0x327577['name']]={'$like':'%'+_0x2d9bfb[_0xa60f('0x2c')][_0xa60f('0x37')]+'%'};return _0x49bb4a;}})});}_0x535236=_['merge']({},_0x535236,_0x2d9bfb[_0xa60f('0x3c')]);var _0x15c9fa={'where':_0x535236[_0xa60f('0x38')]};return db[_0xa60f('0x3d')]['count'](_0x15c9fa)['then'](function(_0x5163b2){_0x260eca[_0xa60f('0x19')]=_0x5163b2;if(_0x2d9bfb[_0xa60f('0x2c')][_0xa60f('0x3e')]){_0x535236[_0xa60f('0x3f')]=[{'all':!![]}];}return db[_0xa60f('0x3d')][_0xa60f('0x40')](_0x535236);})['then'](function(_0x2372cb){_0x260eca['rows']=_0x2372cb;return _0x260eca;})[_0xa60f('0x1f')](respondWithFilteredResult(_0x73301b,_0x535236))['catch'](handleError(_0x73301b,null));};exports[_0xa60f('0x41')]=function(_0x267166,_0x9991be){var _0x180abe={'raw':!![],'where':{'id':_0x267166[_0xa60f('0x42')]['id']}},_0x172929={};_0x172929[_0xa60f('0x2a')]=_['keys'](db[_0xa60f('0x3d')][_0xa60f('0x28')]);_0x172929['query']=_['keys'](_0x267166[_0xa60f('0x2c')]);_0x172929[_0xa60f('0x2d')]=_[_0xa60f('0x2e')](_0x172929[_0xa60f('0x2a')],_0x172929[_0xa60f('0x2c')]);_0x180abe['attributes']=_[_0xa60f('0x2e')](_0x172929[_0xa60f('0x2a')],qs['fields'](_0x267166[_0xa60f('0x2c')][_0xa60f('0x30')]));_0x180abe[_0xa60f('0x2f')]=_0x180abe['attributes'][_0xa60f('0x43')]?_0x180abe[_0xa60f('0x2f')]:_0x172929[_0xa60f('0x2a')];if(_0x267166[_0xa60f('0x2c')][_0xa60f('0x3e')]){_0x180abe['include']=[{'all':!![]}];}_0x180abe=_[_0xa60f('0x39')]({},_0x180abe,_0x267166[_0xa60f('0x3c')]);return db[_0xa60f('0x3d')][_0xa60f('0x44')](_0x180abe)[_0xa60f('0x1f')](handleEntityNotFound(_0x9991be,null))[_0xa60f('0x1f')](respondWithResult(_0x9991be,null))['catch'](handleError(_0x9991be,null));};exports[_0xa60f('0x45')]=function(_0x4d057c,_0x541999){return db[_0xa60f('0x3d')][_0xa60f('0x45')](_0x4d057c[_0xa60f('0x46')],{})['then'](function(_0xe5a22b){var _0x107e91=_0x4d057c['user']['get']({'plain':!![]});if(!_0x107e91)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x107e91[_0xa60f('0x47')]===_0xa60f('0x48')){var _0x443c8a=_0xe5a22b[_0xa60f('0x21')]({'plain':!![]});var _0x11e236='Reports';return db[_0xa60f('0x49')][_0xa60f('0x44')]({'where':{'name':_0x11e236,'userProfileId':_0x107e91['userProfileId']},'raw':!![]})[_0xa60f('0x1f')](function(_0x2c85c6){if(_0x2c85c6&&_0x2c85c6[_0xa60f('0x4a')]===0x0){return db[_0xa60f('0x4b')][_0xa60f('0x45')]({'name':_0x443c8a[_0xa60f('0x24')],'resourceId':_0x443c8a['id'],'type':'DefaultReports','sectionId':_0x2c85c6['id']},{})[_0xa60f('0x1f')](function(){return _0xe5a22b;});}else{return _0xe5a22b;}})[_0xa60f('0x4c')](function(_0x5d2c71){logger['error'](_0xa60f('0x4d'),_0x5d2c71);throw _0x5d2c71;});}return _0xe5a22b;})[_0xa60f('0x1f')](respondWithResult(_0x541999,0xc9))[_0xa60f('0x4c')](handleError(_0x541999,null));};exports[_0xa60f('0x1e')]=function(_0x3bb54c,_0x4c2e48){if(_0x3bb54c[_0xa60f('0x46')]['id']){delete _0x3bb54c[_0xa60f('0x46')]['id'];}return db['AnalyticDefaultReport']['find']({'where':{'id':_0x3bb54c[_0xa60f('0x42')]['id']}})[_0xa60f('0x1f')](handleEntityNotFound(_0x4c2e48,null))['then'](saveUpdates(_0x3bb54c['body'],null))[_0xa60f('0x1f')](respondWithResult(_0x4c2e48,null))[_0xa60f('0x4c')](handleError(_0x4c2e48,null));};exports['destroy']=function(_0x582d20,_0x16afdd){return db['AnalyticDefaultReport'][_0xa60f('0x44')]({'where':{'id':_0x582d20[_0xa60f('0x42')]['id']}})['then'](handleEntityNotFound(_0x16afdd,null))[_0xa60f('0x1f')](removeEntity(_0x16afdd,null))['catch'](handleError(_0x16afdd,null));};exports['preview']=function(_0x2c383a,_0x2e7d06){var _0x599d85=0xa;var _0x595e45=[_0xa60f('0x4e'),_0xa60f('0x4f'),'right_join','cross_join'];var _0x567b1f={'SUM':_0xa60f('0x50'),'COUNT':_0xa60f('0x51'),'COUNT DISTINCT':_0xa60f('0x52'),'MAX':'MAX(%s)','MIN':_0xa60f('0x53'),'AVG':_0xa60f('0x54'),'GROUP_CONCAT':_0xa60f('0x55'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xa60f('0x56')};var _0x1f57fb={'SEC_TO_TIME':_0xa60f('0x57'),'DATE':_0xa60f('0x58'),'HOUR':'HOUR(%s)','ROUND':_0xa60f('0x59'),'UNIX_TIMESTAMP':_0xa60f('0x5a')};var _0x224bd5=function(_0x3b92f3){return!_[_0xa60f('0x5b')]([_0xa60f('0x5c'),'IS\x20NOT\x20NULL',_0xa60f('0x5d'),_0xa60f('0x5e')],_0x3b92f3);};var _0x46315a=function(_0x24044b){if(!_0x24044b||!_0x24044b[_0xa60f('0x5f')][_0xa60f('0x43')]){return'';}for(var _0x25f13f='(',_0x1b05b2=0x0;_0x1b05b2<_0x24044b[_0xa60f('0x5f')][_0xa60f('0x43')];_0x1b05b2+=0x1){_0x1b05b2>0x0&&(_0x25f13f+='\x20'+_0x24044b[_0xa60f('0x60')]+'\x20');_0x25f13f+=_0x24044b[_0xa60f('0x5f')][_0x1b05b2][_0xa60f('0x61')]?_0x46315a(_0x24044b[_0xa60f('0x5f')][_0x1b05b2][_0xa60f('0x61')]):_0x24044b['rules'][_0x1b05b2][_0xa60f('0x62')]+'\x20'+_0x24044b[_0xa60f('0x5f')][_0x1b05b2][_0xa60f('0x63')]+(_0x224bd5(_0x24044b[_0xa60f('0x5f')][_0x1b05b2][_0xa60f('0x63')])?'\x20'+_0x24044b[_0xa60f('0x5f')][_0x1b05b2][_0xa60f('0x64')]:'');}return _0x25f13f+')';};var _0x207a7a={'where':{'id':_0x2c383a[_0xa60f('0x42')]['id']}},_0x2d8354,_0x4b117d,_0x1f842c,_0x303be0,_0x57b03d;_0x207a7a=_[_0xa60f('0x39')]({},_0x207a7a,_0x2c383a[_0xa60f('0x3c')]);return db[_0xa60f('0x3d')][_0xa60f('0x44')](_0x207a7a)[_0xa60f('0x1f')](function(_0x1b8669){if(_0x1b8669){_0x2d8354=_0x1b8669;return _0x1b8669[_0xa60f('0x65')]();}return null;})['then'](function(_0xb116eb){if(_0xb116eb){if(!_0xb116eb['length']){throw new db[(_0xa60f('0x66'))][(_0xa60f('0x67'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x4b117d=_0xb116eb;return db[_0xa60f('0x68')][_0xa60f('0x40')]({'raw':!![]});}return null;})[_0xa60f('0x1f')](function(_0xb724a0){if(_0xb724a0){_0x1f842c=_[_0xa60f('0x69')](_0xb724a0,'id');var _0x53af2b;var _0x5dfc21=squel[_0xa60f('0x6a')]();_0x5dfc21['from'](_0x2d8354[_0xa60f('0x6b')]);for(var _0x398b23=0x0;_0x398b23<_0x4b117d[_0xa60f('0x43')];_0x398b23+=0x1){_0x53af2b=_0x4b117d[_0x398b23][_0xa60f('0x6c')]?_0x1f842c[_0x4b117d[_0x398b23]['MetricId']]['metric']:_0x4b117d[_0x398b23][_0xa60f('0x62')];_0x53af2b=_0x4b117d[_0x398b23][_0xa60f('0x6d')]?_['replace'](_0x567b1f[_0x4b117d[_0x398b23][_0xa60f('0x6d')]],'%s',_0x53af2b):_0x53af2b;_0x53af2b=_0x4b117d[_0x398b23][_0xa60f('0x6e')]?_[_0xa60f('0x6f')](_0x1f57fb[_0x4b117d[_0x398b23][_0xa60f('0x6e')]],'%s',_0x53af2b):_0x53af2b;if(_0x4b117d[_0x398b23][_0xa60f('0x70')]){_0x5dfc21[_0xa60f('0x61')](_0x53af2b);}_0x4b117d[_0x398b23]['orderBy']&&_0x5dfc21[_0xa60f('0x34')](_0x53af2b,_0x4b117d[_0x398b23][_0xa60f('0x71')]===_0xa60f('0x72')?![]:!![]);_0x5dfc21[_0xa60f('0x62')](_0x53af2b,_0x4b117d[_0x398b23]['alias']||_0x53af2b);}if(_0x2d8354[_0xa60f('0x73')]){_0x2d8354[_0xa60f('0x73')]=JSON[_0xa60f('0x74')](_0x2d8354[_0xa60f('0x73')]);for(var _0xcac248=0x0;_0xcac248<_0x2d8354[_0xa60f('0x73')][_0xa60f('0x43')];_0xcac248+=0x1){if(_0x2d8354[_0xa60f('0x73')][_0xcac248][_0xa60f('0x3a')]&&_['includes'](_0x595e45,_0x2d8354['joins'][_0xcac248]['type'])&&_0x2d8354[_0xa60f('0x73')][_0xcac248][_0xa60f('0x75')]&&_0x2d8354[_0xa60f('0x73')][_0xcac248][_0xa60f('0x76')]&&_0x2d8354[_0xa60f('0x73')][_0xcac248][_0xa60f('0x77')]){_0x5dfc21[_0x2d8354[_0xa60f('0x73')][_0xcac248][_0xa60f('0x3a')]](_0x2d8354['joins'][_0xcac248][_0xa60f('0x76')],null,util[_0xa60f('0x6e')](_0xa60f('0x78'),_0x2d8354['table'],_0x2d8354[_0xa60f('0x73')][_0xcac248][_0xa60f('0x75')],_0x2d8354[_0xa60f('0x73')][_0xcac248][_0xa60f('0x76')],_0x2d8354['joins'][_0xcac248][_0xa60f('0x77')]));}}}if(_0x2d8354[_0xa60f('0x79')]){_0x2d8354[_0xa60f('0x79')]=JSON[_0xa60f('0x74')](_0x2d8354[_0xa60f('0x79')]);_0x5dfc21['where'](_0x46315a(_0x2d8354['conditions'][_0xa60f('0x61')]));}_0x57b03d=_0x5dfc21[_0xa60f('0x7a')]();_0x5dfc21[_0xa60f('0x33')](_0x599d85);_0x5dfc21[_0xa60f('0x1a')](0x0);logger['debug'](_0xa60f('0x7b'),_0x5dfc21[_0xa60f('0x7c')]());return dbH[_0xa60f('0x7d')][_0xa60f('0x2c')](_0x5dfc21['toString'](),{'type':dbH[_0xa60f('0x7d')][_0xa60f('0x7e')][_0xa60f('0x7f')]});}})[_0xa60f('0x1f')](respondWithResult(_0x2e7d06,null))[_0xa60f('0x4c')](handleError(_0x2e7d06,null));};function runReport(_0x7b194c,_0x3113ba,_0x17116d){var _0x353a3e=_0x3113ba[_0xa60f('0x24')];var _0x1b60e1=0xa;var _0x18f246=[_0xa60f('0x4e'),_0xa60f('0x4f'),_0xa60f('0x80'),'cross_join'];var _0x1141e6={'SUM':'SUM(%s)','COUNT':'COUNT(%s)','COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xa60f('0x81'),'MIN':_0xa60f('0x53'),'AVG':_0xa60f('0x54'),'GROUP_CONCAT':_0xa60f('0x55'),'GROUP_CONCAT ASC':_0xa60f('0x82'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x46fbbe={'SEC_TO_TIME':_0xa60f('0x57'),'DATE':_0xa60f('0x58'),'HOUR':'HOUR(%s)','ROUND':_0xa60f('0x59'),'UNIX_TIMESTAMP':_0xa60f('0x5a')};var _0x51d88e=function(_0x5071e6){return!_['includes']([_0xa60f('0x5c'),_0xa60f('0x83'),_0xa60f('0x5d'),_0xa60f('0x5e')],_0x5071e6);};var _0x22f6a9=function(_0x23285b){if(!_0x23285b||!_0x23285b[_0xa60f('0x5f')][_0xa60f('0x43')]){return'';}for(var _0x124022='(',_0x2c2d70=0x0;_0x2c2d70<_0x23285b['rules'][_0xa60f('0x43')];_0x2c2d70+=0x1){_0x2c2d70>0x0&&(_0x124022+='\x20'+_0x23285b[_0xa60f('0x60')]+'\x20');_0x124022+=_0x23285b[_0xa60f('0x5f')][_0x2c2d70][_0xa60f('0x61')]?_0x22f6a9(_0x23285b['rules'][_0x2c2d70][_0xa60f('0x61')]):_0x23285b[_0xa60f('0x5f')][_0x2c2d70][_0xa60f('0x62')]+'\x20'+_0x23285b[_0xa60f('0x5f')][_0x2c2d70]['condition']+(_0x51d88e(_0x23285b[_0xa60f('0x5f')][_0x2c2d70][_0xa60f('0x63')])?'\x20'+_0x23285b[_0xa60f('0x5f')][_0x2c2d70][_0xa60f('0x64')]:'');}return _0x124022+')';};var _0x31f3={'where':{'id':_0x7b194c['id']}},_0x128a4f,_0x1d5b15,_0x5459c0,_0x45f8a8,_0x210a41;_0x31f3=_[_0xa60f('0x39')]({},_0x31f3,_0x17116d);return db[_0xa60f('0x3d')][_0xa60f('0x44')](_0x31f3)[_0xa60f('0x1f')](function(_0x561104){if(_0x561104){_0x128a4f=_0x561104;return _0x561104['getFields']();}return null;})[_0xa60f('0x1f')](function(_0x4f2cce){if(_0x4f2cce){if(!_0x4f2cce[_0xa60f('0x43')]){throw new db[(_0xa60f('0x66'))][(_0xa60f('0x67'))](_0xa60f('0x84'),0x193);}_0x1d5b15=_0x4f2cce;return db[_0xa60f('0x68')][_0xa60f('0x40')]({'raw':!![]});}return null;})[_0xa60f('0x1f')](function(_0x2bd559){if(_0x2bd559){_0x5459c0=_[_0xa60f('0x69')](_0x2bd559,'id');var _0x165da9;var _0x4f43b5=squel['select']();_0x4f43b5[_0xa60f('0x85')](_0x128a4f['table']);for(var _0x37ff2b=0x0;_0x37ff2b<_0x1d5b15[_0xa60f('0x43')];_0x37ff2b+=0x1){_0x165da9=_0x1d5b15[_0x37ff2b]['MetricId']?_0x5459c0[_0x1d5b15[_0x37ff2b][_0xa60f('0x6c')]][_0xa60f('0x86')]:_0x1d5b15[_0x37ff2b][_0xa60f('0x62')];_0x165da9=_0x1d5b15[_0x37ff2b][_0xa60f('0x6d')]?_[_0xa60f('0x6f')](_0x1141e6[_0x1d5b15[_0x37ff2b][_0xa60f('0x6d')]],'%s',_0x165da9):_0x165da9;_0x165da9=_0x1d5b15[_0x37ff2b][_0xa60f('0x6e')]?_[_0xa60f('0x6f')](_0x46fbbe[_0x1d5b15[_0x37ff2b][_0xa60f('0x6e')]],'%s',_0x165da9):_0x165da9;if(_0x1d5b15[_0x37ff2b][_0xa60f('0x70')]){_0x4f43b5[_0xa60f('0x61')](_0x165da9);}_0x1d5b15[_0x37ff2b][_0xa60f('0x71')]&&_0x4f43b5['order'](_0x165da9,_0x1d5b15[_0x37ff2b]['orderBy']===_0xa60f('0x72')?![]:!![]);_0x4f43b5[_0xa60f('0x62')](_0x165da9,_0x1d5b15[_0x37ff2b][_0xa60f('0x87')]||_0x165da9);}if(_0x128a4f[_0xa60f('0x73')]){_0x128a4f[_0xa60f('0x73')]=JSON['parse'](_0x128a4f[_0xa60f('0x73')]);for(var _0x5e7bdd=0x0;_0x5e7bdd<_0x128a4f[_0xa60f('0x73')][_0xa60f('0x43')];_0x5e7bdd+=0x1){if(_0x128a4f[_0xa60f('0x73')][_0x5e7bdd][_0xa60f('0x3a')]&&_[_0xa60f('0x5b')](_0x18f246,_0x128a4f[_0xa60f('0x73')][_0x5e7bdd][_0xa60f('0x3a')])&&_0x128a4f[_0xa60f('0x73')][_0x5e7bdd][_0xa60f('0x75')]&&_0x128a4f['joins'][_0x5e7bdd][_0xa60f('0x76')]&&_0x128a4f[_0xa60f('0x73')][_0x5e7bdd][_0xa60f('0x77')]){_0x4f43b5[_0x128a4f[_0xa60f('0x73')][_0x5e7bdd]['type']](_0x128a4f['joins'][_0x5e7bdd][_0xa60f('0x76')],null,util[_0xa60f('0x6e')](_0xa60f('0x78'),_0x128a4f['table'],_0x128a4f[_0xa60f('0x73')][_0x5e7bdd][_0xa60f('0x75')],_0x128a4f['joins'][_0x5e7bdd][_0xa60f('0x76')],_0x128a4f[_0xa60f('0x73')][_0x5e7bdd][_0xa60f('0x77')]));}}}if(_0x128a4f[_0xa60f('0x79')]){_0x128a4f['conditions']=JSON[_0xa60f('0x74')](_0x128a4f[_0xa60f('0x79')]);_0x4f43b5[_0xa60f('0x38')](_0x22f6a9(_0x128a4f[_0xa60f('0x79')][_0xa60f('0x61')]));}_0x210a41=_0x4f43b5[_0xa60f('0x7a')]();_0x4f43b5['limit'](_0x1b60e1);_0x4f43b5[_0xa60f('0x1a')](0x0);return;}})['then'](function(){if(_0x3113ba[_0xa60f('0x88')]===_0xa60f('0x89')){return null;}var _0x7349e2=_[_0xa60f('0x39')](_0x3113ba,{'name':_0x3113ba['fullPath']||_0x3113ba[_0xa60f('0x24')]||_0x128a4f[_0xa60f('0x24')],'basename':_0x353a3e,'savename':util[_0xa60f('0x6e')](_0xa60f('0x8a'),_0x3113ba[_0xa60f('0x24')]||_0x128a4f[_0xa60f('0x24')],require(_0xa60f('0x8b'))[_0xa60f('0x8c')](0x4),_0x3113ba['output']||'csv'),'reportId':_0x128a4f['id'],'reportType':'default'});return db[_0xa60f('0x8d')][_0xa60f('0x45')](_0x7349e2,{'raw':!![]});})[_0xa60f('0x1f')](function(_0x4a1a51){if(_0x128a4f[_0xa60f('0x6b')]==='cdr'){_0x210a41[_0xa60f('0x38')](_0x128a4f[_0xa60f('0x6b')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x3113ba[_0xa60f('0x8e')],_0x3113ba[_0xa60f('0x8f')]);}else{_0x210a41['where'](_0x128a4f[_0xa60f('0x6b')]+_0xa60f('0x90'),_0x3113ba['startDate'],_0x3113ba[_0xa60f('0x8f')]);}if(_0x4a1a51){logger[_0xa60f('0x91')](_0xa60f('0x92'),_0x210a41[_0xa60f('0x7c')]());require(_0xa60f('0x93'))[_0xa60f('0x94')](path['join'](__dirname,_0xa60f('0x95'),_0x4a1a51[_0xa60f('0x88')]),[_0x4a1a51['id'],_0x210a41['toString'](),path['join'](__dirname,_0xa60f('0x96'),_0x4a1a51['savename']),_0x353a3e]);return _0x4a1a51;}else{var _0x1025e0=squel[_0xa60f('0x6a')]();_0x1025e0['from']('('+_0x210a41[_0xa60f('0x7c')]()+')',_0xa60f('0x97'));_0x1025e0[_0xa60f('0x62')](_0xa60f('0x98'),_0xa60f('0x19'));_0x210a41['limit'](_0x3113ba[_0xa60f('0x33')]||_0x1b60e1);_0x210a41[_0xa60f('0x1a')](_0x3113ba[_0xa60f('0x1a')]||0x0);return dbH[_0xa60f('0x7d')][_0xa60f('0x2c')](_0x1025e0[_0xa60f('0x7c')](),{'type':dbH[_0xa60f('0x7d')]['QueryTypes'][_0xa60f('0x7f')]})[_0xa60f('0x1f')](function(_0x3aa43a){if(!_0x3aa43a['length']){_0x45f8a8=0x0;}else{_0x45f8a8=_0x3aa43a[0x0][_0xa60f('0x19')]||0x0;}return dbH['sequelize'][_0xa60f('0x2c')](_0x210a41['toString'](),{'type':dbH[_0xa60f('0x7d')][_0xa60f('0x7e')][_0xa60f('0x7f')]});})[_0xa60f('0x1f')](function(_0x2a9a3a){return{'rows':_0x2a9a3a||[],'count':_0x45f8a8};});}});}exports[_0xa60f('0x99')]=function(_0x8d041b,_0x54b52a){return runReport(_0x8d041b['params'],_0x8d041b[_0xa60f('0x2c')],_0x8d041b[_0xa60f('0x3c')])['then'](respondWithResult(_0x54b52a,null))[_0xa60f('0x4c')](handleError(_0x54b52a,null));};exports[_0xa60f('0x9a')]=runReport;exports[_0xa60f('0x2c')]=function(_0x566ff5,_0x558045){var _0x175599=0xa;var _0x260a83=[_0xa60f('0x4e'),'left_join','right_join',_0xa60f('0x9b')];var _0x2dfc3e={'SUM':_0xa60f('0x50'),'COUNT':_0xa60f('0x51'),'COUNT DISTINCT':_0xa60f('0x52'),'MAX':_0xa60f('0x81'),'MIN':_0xa60f('0x53'),'AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xa60f('0x56')};var _0x45389={'SEC_TO_TIME':_0xa60f('0x57'),'DATE':'DATE(%s)','HOUR':_0xa60f('0x9c'),'ROUND':_0xa60f('0x59'),'UNIX_TIMESTAMP':_0xa60f('0x5a')};var _0x2333dd=function(_0x21de5d){return!_[_0xa60f('0x5b')]([_0xa60f('0x5c'),'IS\x20NOT\x20NULL',_0xa60f('0x5d'),_0xa60f('0x5e')],_0x21de5d);};var _0x1ec70c=function(_0x2eb333){if(!_0x2eb333||!_0x2eb333[_0xa60f('0x5f')]['length']){return'';}for(var _0x272d45='(',_0x4fd5fb=0x0;_0x4fd5fb<_0x2eb333['rules'][_0xa60f('0x43')];_0x4fd5fb+=0x1){_0x4fd5fb>0x0&&(_0x272d45+='\x20'+_0x2eb333['operator']+'\x20');_0x272d45+=_0x2eb333[_0xa60f('0x5f')][_0x4fd5fb]['group']?_0x1ec70c(_0x2eb333[_0xa60f('0x5f')][_0x4fd5fb][_0xa60f('0x61')]):_0x2eb333[_0xa60f('0x5f')][_0x4fd5fb][_0xa60f('0x62')]+'\x20'+_0x2eb333['rules'][_0x4fd5fb][_0xa60f('0x63')]+(_0x2333dd(_0x2eb333[_0xa60f('0x5f')][_0x4fd5fb]['condition'])?'\x20'+_0x2eb333['rules'][_0x4fd5fb]['value']:'');}return _0x272d45+')';};var _0x61f8a3={'where':{'id':_0x566ff5[_0xa60f('0x42')]['id']}},_0x2bfc7b,_0x30abef,_0x5ef92e,_0x179c01,_0xe92f66;_0x61f8a3=_[_0xa60f('0x39')]({},_0x61f8a3,_0x566ff5[_0xa60f('0x3c')]);return db[_0xa60f('0x3d')][_0xa60f('0x44')](_0x61f8a3)[_0xa60f('0x1f')](function(_0x34634c){if(_0x34634c){_0x2bfc7b=_0x34634c;return _0x34634c[_0xa60f('0x65')]();}return null;})[_0xa60f('0x1f')](function(_0x6f1203){if(_0x6f1203){if(!_0x6f1203[_0xa60f('0x43')]){throw new db['Sequelize'][(_0xa60f('0x67'))](_0xa60f('0x84'),0x193);}_0x30abef=_0x6f1203;return db[_0xa60f('0x68')][_0xa60f('0x40')]({'raw':!![]});}return null;})[_0xa60f('0x1f')](function(_0x4042c1){if(_0x4042c1){_0x5ef92e=_[_0xa60f('0x69')](_0x4042c1,'id');var _0x4d6ca2;var _0x254b0a=squel[_0xa60f('0x6a')]();_0x254b0a['from'](_0x2bfc7b[_0xa60f('0x6b')]);for(var _0x2fc0e7=0x0;_0x2fc0e7<_0x30abef[_0xa60f('0x43')];_0x2fc0e7+=0x1){_0x4d6ca2=_0x30abef[_0x2fc0e7][_0xa60f('0x6c')]?_0x5ef92e[_0x30abef[_0x2fc0e7]['MetricId']]['metric']:_0x30abef[_0x2fc0e7][_0xa60f('0x62')];_0x4d6ca2=_0x30abef[_0x2fc0e7][_0xa60f('0x6d')]?_[_0xa60f('0x6f')](_0x2dfc3e[_0x30abef[_0x2fc0e7][_0xa60f('0x6d')]],'%s',_0x4d6ca2):_0x4d6ca2;_0x4d6ca2=_0x30abef[_0x2fc0e7][_0xa60f('0x6e')]?_['replace'](_0x45389[_0x30abef[_0x2fc0e7]['format']],'%s',_0x4d6ca2):_0x4d6ca2;if(_0x30abef[_0x2fc0e7]['groupBy']){_0x254b0a[_0xa60f('0x61')](_0x4d6ca2);}_0x30abef[_0x2fc0e7][_0xa60f('0x71')]&&_0x254b0a[_0xa60f('0x34')](_0x4d6ca2,_0x30abef[_0x2fc0e7][_0xa60f('0x71')]==='DESC'?![]:!![]);_0x254b0a['field'](_0x4d6ca2,_0x30abef[_0x2fc0e7][_0xa60f('0x87')]||_0x4d6ca2);}if(_0x2bfc7b[_0xa60f('0x73')]){_0x2bfc7b[_0xa60f('0x73')]=JSON[_0xa60f('0x74')](_0x2bfc7b[_0xa60f('0x73')]);for(var _0x3aa2f4=0x0;_0x3aa2f4<_0x2bfc7b[_0xa60f('0x73')][_0xa60f('0x43')];_0x3aa2f4+=0x1){if(_0x2bfc7b[_0xa60f('0x73')][_0x3aa2f4][_0xa60f('0x3a')]&&_[_0xa60f('0x5b')](_0x260a83,_0x2bfc7b[_0xa60f('0x73')][_0x3aa2f4][_0xa60f('0x3a')])&&_0x2bfc7b[_0xa60f('0x73')][_0x3aa2f4]['parentKey']&&_0x2bfc7b['joins'][_0x3aa2f4][_0xa60f('0x76')]&&_0x2bfc7b[_0xa60f('0x73')][_0x3aa2f4][_0xa60f('0x77')]){_0x254b0a[_0x2bfc7b[_0xa60f('0x73')][_0x3aa2f4][_0xa60f('0x3a')]](_0x2bfc7b[_0xa60f('0x73')][_0x3aa2f4][_0xa60f('0x76')],null,util[_0xa60f('0x6e')](_0xa60f('0x78'),_0x2bfc7b[_0xa60f('0x6b')],_0x2bfc7b[_0xa60f('0x73')][_0x3aa2f4]['parentKey'],_0x2bfc7b[_0xa60f('0x73')][_0x3aa2f4]['foreignTable'],_0x2bfc7b['joins'][_0x3aa2f4][_0xa60f('0x77')]));}}}if(_0x2bfc7b[_0xa60f('0x79')]){_0x2bfc7b[_0xa60f('0x79')]=JSON['parse'](_0x2bfc7b[_0xa60f('0x79')]);_0x254b0a[_0xa60f('0x38')](_0x1ec70c(_0x2bfc7b['conditions']['group']));}_0xe92f66=_0x254b0a[_0xa60f('0x7a')]();_0x254b0a[_0xa60f('0x33')](_0x175599);_0x254b0a[_0xa60f('0x1a')](0x0);logger[_0xa60f('0x9d')](_0xa60f('0x7b'),_0x254b0a['toString']());return dbH['sequelize'][_0xa60f('0x2c')](_0x254b0a[_0xa60f('0x7c')](),{'type':dbH[_0xa60f('0x7d')][_0xa60f('0x7e')][_0xa60f('0x7f')]});}})[_0xa60f('0x1f')](function(){return{'sql':_0xe92f66[_0xa60f('0x7c')]()};})[_0xa60f('0x1f')](respondWithResult(_0x558045,null))[_0xa60f('0x4c')](handleError(_0x558045,null));};
\ No newline at end of file
+var _0xbccb=['%s-%s.%s','randomstring','generate','csv','default','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','SELECT','run','runReport','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','status','count','offset','set','Content-Range','apply','save','update','destroy','then','get','DefaultReports','UserProfileResource','end','error','stack','name','send','index','AnalyticDefaultReport','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','length','limit','order','sort','where','pick','map','VIRTUAL','merge','options','includeAll','include','catch','show','params','keys','fields','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','preview','join','left_join','right_join','cross_join','SUM(%s)','COUNT(DISTINCT\x20%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','SEC_TO_TIME(%s)','DATE(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','includes','IS\x20NULL','IS\x20NOT\x20NULL','rules','operator','group','field','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','findAll','select','from','table','MetricId','function','replace','format','groupBy','orderBy','DESC','joins','parse','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','parentKey','conditions','clone','debug','Limited\x20Query:','toString','sequelize','QueryTypes','COUNT(%s)','MAX(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','IS\x20EMPTY','IS\x20NOT\x20EMPTY','condition','value','keyBy','metric','alias','output','web'];(function(_0x21bcc6,_0x51f500){var _0x13d711=function(_0x3458c9){while(--_0x3458c9){_0x21bcc6['push'](_0x21bcc6['shift']());}};_0x13d711(++_0x51f500);}(_0xbccb,0xb8));var _0xbbcc=function(_0x256e32,_0x4013bc){_0x256e32=_0x256e32-0x0;var _0x464070=_0xbccb[_0x256e32];return _0x464070;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xbbcc('0x0'));var rimraf=require(_0xbbcc('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xbbcc('0x2'));var rp=require('request-promise');var moment=require(_0xbbcc('0x3'));var BPromise=require(_0xbbcc('0x4'));var Mustache=require(_0xbbcc('0x5'));var util=require(_0xbbcc('0x6'));var path=require(_0xbbcc('0x7'));var sox=require(_0xbbcc('0x8'));var csv=require(_0xbbcc('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xbbcc('0xa'));var squel=require(_0xbbcc('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xbbcc('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xbbcc('0xd'));var Redis=require(_0xbbcc('0xe'));var authService=require(_0xbbcc('0xf'));var qs=require(_0xbbcc('0x10'));var as=require(_0xbbcc('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xbbcc('0x12'))(_0xbbcc('0x13'));var utils=require(_0xbbcc('0x14'));var config=require(_0xbbcc('0x15'));var licenseUtil=require(_0xbbcc('0x16'));var db=require(_0xbbcc('0x17'))['db'];var dbH=require(_0xbbcc('0x17'))[_0xbbcc('0x18')];function respondWithStatusCode(_0x4729b0,_0x56ea0b){_0x56ea0b=_0x56ea0b||0xcc;return function(_0x5416c7){if(_0x5416c7){return _0x4729b0[_0xbbcc('0x19')](_0x56ea0b);}return _0x4729b0[_0xbbcc('0x1a')](_0x56ea0b)['end']();};}function respondWithResult(_0x2127f1,_0x2aa1e3){_0x2aa1e3=_0x2aa1e3||0xc8;return function(_0x516c80){if(_0x516c80){return _0x2127f1['status'](_0x2aa1e3)['json'](_0x516c80);}};}function respondWithFilteredResult(_0xeea6a4,_0x334d98){return function(_0x3e50b2){if(_0x3e50b2){var _0x4ae7a6=_0x3e50b2[_0xbbcc('0x1b')],_0x32a7d6=_0x334d98[_0xbbcc('0x1c')],_0x52c2f9=_0x334d98[_0xbbcc('0x1c')]+_0x334d98['limit'],_0x546d33;if(_0x52c2f9>=_0x4ae7a6){_0x52c2f9=_0x4ae7a6;_0x546d33=0xc8;}else{_0x546d33=0xce;}_0xeea6a4[_0xbbcc('0x1a')](_0x546d33);return _0xeea6a4[_0xbbcc('0x1d')](_0xbbcc('0x1e'),_0x32a7d6+'-'+_0x52c2f9+'/'+_0x4ae7a6)['json'](_0x3e50b2);}return null;};}function patchUpdates(_0x24c982){return function(_0x37b06d){try{jsonpatch[_0xbbcc('0x1f')](_0x37b06d,_0x24c982,!![]);}catch(_0x2bd58d){return BPromise['reject'](_0x2bd58d);}return _0x37b06d[_0xbbcc('0x20')]();};}function saveUpdates(_0x5d064b,_0x5124b7){return function(_0x22e0eb){if(_0x22e0eb){return _0x22e0eb[_0xbbcc('0x21')](_0x5d064b)['then'](function(_0xb82e36){return _0xb82e36;});}return null;};}function removeEntity(_0x7884b6,_0x25a069){return function(_0x35ac46){if(_0x35ac46){return _0x35ac46[_0xbbcc('0x22')]()[_0xbbcc('0x23')](function(){var _0x56c70a=_0x35ac46[_0xbbcc('0x24')]({'plain':!![]});var _0x22e163=_0xbbcc('0x25');return db[_0xbbcc('0x26')][_0xbbcc('0x22')]({'where':{'type':_0x22e163,'resourceId':_0x56c70a['id']}})[_0xbbcc('0x23')](function(){return _0x35ac46;});})[_0xbbcc('0x23')](function(){_0x7884b6[_0xbbcc('0x1a')](0xcc)[_0xbbcc('0x27')]();});}};}function handleEntityNotFound(_0x51e17f,_0x53771a){return function(_0x39a9d8){if(!_0x39a9d8){_0x51e17f[_0xbbcc('0x19')](0x194);}return _0x39a9d8;};}function handleError(_0x446dfe,_0x3faca3){_0x3faca3=_0x3faca3||0x1f4;return function(_0x3c79e2){logger[_0xbbcc('0x28')](_0x3c79e2[_0xbbcc('0x29')]);if(_0x3c79e2['name']){delete _0x3c79e2[_0xbbcc('0x2a')];}_0x446dfe[_0xbbcc('0x1a')](_0x3faca3)[_0xbbcc('0x2b')](_0x3c79e2);};}exports[_0xbbcc('0x2c')]=function(_0x345a03,_0x10f05a){var _0x504697={},_0x39dccd={},_0xdcc7a8={'count':0x0,'rows':[]};var _0x1934d6=_['map'](db[_0xbbcc('0x2d')][_0xbbcc('0x2e')],function(_0x45dc30){return{'name':_0x45dc30[_0xbbcc('0x2f')],'type':_0x45dc30[_0xbbcc('0x30')][_0xbbcc('0x31')]};});_0x39dccd[_0xbbcc('0x32')]=_['map'](_0x1934d6,_0xbbcc('0x2a'));_0x39dccd[_0xbbcc('0x33')]=_['keys'](_0x345a03['query']);_0x39dccd[_0xbbcc('0x34')]=_[_0xbbcc('0x35')](_0x39dccd[_0xbbcc('0x32')],_0x39dccd['query']);_0x504697[_0xbbcc('0x36')]=_[_0xbbcc('0x35')](_0x39dccd['model'],qs['fields'](_0x345a03[_0xbbcc('0x33')]['fields']));_0x504697[_0xbbcc('0x36')]=_0x504697[_0xbbcc('0x36')][_0xbbcc('0x37')]?_0x504697[_0xbbcc('0x36')]:_0x39dccd[_0xbbcc('0x32')];if(!_0x345a03[_0xbbcc('0x33')]['hasOwnProperty']('nolimit')){_0x504697['limit']=qs['limit'](_0x345a03[_0xbbcc('0x33')][_0xbbcc('0x38')]);_0x504697[_0xbbcc('0x1c')]=qs[_0xbbcc('0x1c')](_0x345a03[_0xbbcc('0x33')][_0xbbcc('0x1c')]);}_0x504697[_0xbbcc('0x39')]=qs['sort'](_0x345a03['query'][_0xbbcc('0x3a')]);_0x504697[_0xbbcc('0x3b')]=qs[_0xbbcc('0x34')](_[_0xbbcc('0x3c')](_0x345a03['query'],_0x39dccd[_0xbbcc('0x34')]),_0x1934d6);if(_0x345a03[_0xbbcc('0x33')]['filter']){_0x504697[_0xbbcc('0x3b')]=_['merge'](_0x504697[_0xbbcc('0x3b')],{'$or':_[_0xbbcc('0x3d')](_0x1934d6,function(_0x8cf32b){if(_0x8cf32b[_0xbbcc('0x30')]!==_0xbbcc('0x3e')){var _0x9ecf74={};_0x9ecf74[_0x8cf32b[_0xbbcc('0x2a')]]={'$like':'%'+_0x345a03['query']['filter']+'%'};return _0x9ecf74;}})});}_0x504697=_[_0xbbcc('0x3f')]({},_0x504697,_0x345a03[_0xbbcc('0x40')]);var _0x53b4c9={'where':_0x504697[_0xbbcc('0x3b')]};return db[_0xbbcc('0x2d')][_0xbbcc('0x1b')](_0x53b4c9)[_0xbbcc('0x23')](function(_0x38d0e6){_0xdcc7a8[_0xbbcc('0x1b')]=_0x38d0e6;if(_0x345a03[_0xbbcc('0x33')][_0xbbcc('0x41')]){_0x504697[_0xbbcc('0x42')]=[{'all':!![]}];}return db['AnalyticDefaultReport']['findAll'](_0x504697);})[_0xbbcc('0x23')](function(_0xadddbc){_0xdcc7a8['rows']=_0xadddbc;return _0xdcc7a8;})['then'](respondWithFilteredResult(_0x10f05a,_0x504697))[_0xbbcc('0x43')](handleError(_0x10f05a,null));};exports[_0xbbcc('0x44')]=function(_0x3f984e,_0x2a3f74){var _0x32c4a1={'raw':!![],'where':{'id':_0x3f984e[_0xbbcc('0x45')]['id']}},_0x440253={};_0x440253['model']=_['keys'](db[_0xbbcc('0x2d')][_0xbbcc('0x2e')]);_0x440253[_0xbbcc('0x33')]=_[_0xbbcc('0x46')](_0x3f984e[_0xbbcc('0x33')]);_0x440253[_0xbbcc('0x34')]=_[_0xbbcc('0x35')](_0x440253[_0xbbcc('0x32')],_0x440253[_0xbbcc('0x33')]);_0x32c4a1[_0xbbcc('0x36')]=_['intersection'](_0x440253['model'],qs[_0xbbcc('0x47')](_0x3f984e[_0xbbcc('0x33')][_0xbbcc('0x47')]));_0x32c4a1['attributes']=_0x32c4a1[_0xbbcc('0x36')][_0xbbcc('0x37')]?_0x32c4a1['attributes']:_0x440253[_0xbbcc('0x32')];if(_0x3f984e['query'][_0xbbcc('0x41')]){_0x32c4a1[_0xbbcc('0x42')]=[{'all':!![]}];}_0x32c4a1=_[_0xbbcc('0x3f')]({},_0x32c4a1,_0x3f984e[_0xbbcc('0x40')]);return db[_0xbbcc('0x2d')][_0xbbcc('0x48')](_0x32c4a1)[_0xbbcc('0x23')](handleEntityNotFound(_0x2a3f74,null))[_0xbbcc('0x23')](respondWithResult(_0x2a3f74,null))[_0xbbcc('0x43')](handleError(_0x2a3f74,null));};exports[_0xbbcc('0x49')]=function(_0x4042bb,_0x2df6ff){return db[_0xbbcc('0x2d')]['create'](_0x4042bb[_0xbbcc('0x4a')],{})['then'](function(_0x51f2b9){var _0x2c09d0=_0x4042bb[_0xbbcc('0x4b')][_0xbbcc('0x24')]({'plain':!![]});if(!_0x2c09d0)throw new Error(_0xbbcc('0x4c'));if(_0x2c09d0[_0xbbcc('0x4d')]===_0xbbcc('0x4b')){var _0x11141e=_0x51f2b9[_0xbbcc('0x24')]({'plain':!![]});var _0x247d90=_0xbbcc('0x4e');return db[_0xbbcc('0x4f')][_0xbbcc('0x48')]({'where':{'name':_0x247d90,'userProfileId':_0x2c09d0[_0xbbcc('0x50')]},'raw':!![]})[_0xbbcc('0x23')](function(_0x23c52b){if(_0x23c52b&&_0x23c52b['autoAssociation']===0x0){return db[_0xbbcc('0x26')]['create']({'name':_0x11141e[_0xbbcc('0x2a')],'resourceId':_0x11141e['id'],'type':_0xbbcc('0x25'),'sectionId':_0x23c52b['id']},{})[_0xbbcc('0x23')](function(){return _0x51f2b9;});}else{return _0x51f2b9;}})[_0xbbcc('0x43')](function(_0x1b6c22){logger[_0xbbcc('0x28')](_0xbbcc('0x51'),_0x1b6c22);throw _0x1b6c22;});}return _0x51f2b9;})[_0xbbcc('0x23')](respondWithResult(_0x2df6ff,0xc9))[_0xbbcc('0x43')](handleError(_0x2df6ff,null));};exports[_0xbbcc('0x21')]=function(_0x38237a,_0x2e7623){if(_0x38237a[_0xbbcc('0x4a')]['id']){delete _0x38237a['body']['id'];}return db[_0xbbcc('0x2d')]['find']({'where':{'id':_0x38237a[_0xbbcc('0x45')]['id']}})[_0xbbcc('0x23')](handleEntityNotFound(_0x2e7623,null))['then'](saveUpdates(_0x38237a[_0xbbcc('0x4a')],null))[_0xbbcc('0x23')](respondWithResult(_0x2e7623,null))[_0xbbcc('0x43')](handleError(_0x2e7623,null));};exports['destroy']=function(_0x4e5238,_0x174a5){return db[_0xbbcc('0x2d')]['find']({'where':{'id':_0x4e5238[_0xbbcc('0x45')]['id']}})[_0xbbcc('0x23')](handleEntityNotFound(_0x174a5,null))[_0xbbcc('0x23')](removeEntity(_0x174a5,null))[_0xbbcc('0x43')](handleError(_0x174a5,null));};exports[_0xbbcc('0x52')]=function(_0x2bfc2a,_0x11d2aa){var _0x251313=0xa;var _0x312e27=[_0xbbcc('0x53'),_0xbbcc('0x54'),_0xbbcc('0x55'),_0xbbcc('0x56')];var _0x3ab18f={'SUM':_0xbbcc('0x57'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xbbcc('0x58'),'MAX':'MAX(%s)','MIN':_0xbbcc('0x59'),'AVG':_0xbbcc('0x5a'),'GROUP_CONCAT':_0xbbcc('0x5b'),'GROUP_CONCAT ASC':_0xbbcc('0x5c'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x5508be={'SEC_TO_TIME':_0xbbcc('0x5d'),'DATE':_0xbbcc('0x5e'),'HOUR':_0xbbcc('0x5f'),'ROUND':_0xbbcc('0x60'),'UNIX_TIMESTAMP':_0xbbcc('0x61')};var _0x45ced4=function(_0x2ea131){return!_[_0xbbcc('0x62')]([_0xbbcc('0x63'),_0xbbcc('0x64'),'IS\x20EMPTY','IS\x20NOT\x20EMPTY'],_0x2ea131);};var _0x2e3663=function(_0x12af63){if(!_0x12af63||!_0x12af63[_0xbbcc('0x65')][_0xbbcc('0x37')]){return'';}for(var _0x17bde6='(',_0x2a099f=0x0;_0x2a099f<_0x12af63['rules']['length'];_0x2a099f+=0x1){_0x2a099f>0x0&&(_0x17bde6+='\x20'+_0x12af63[_0xbbcc('0x66')]+'\x20');_0x17bde6+=_0x12af63[_0xbbcc('0x65')][_0x2a099f]['group']?_0x2e3663(_0x12af63['rules'][_0x2a099f][_0xbbcc('0x67')]):_0x12af63[_0xbbcc('0x65')][_0x2a099f][_0xbbcc('0x68')]+'\x20'+_0x12af63[_0xbbcc('0x65')][_0x2a099f]['condition']+(_0x45ced4(_0x12af63[_0xbbcc('0x65')][_0x2a099f]['condition'])?'\x20'+_0x12af63[_0xbbcc('0x65')][_0x2a099f]['value']:'');}return _0x17bde6+')';};var _0x2d7313={'where':{'id':_0x2bfc2a['params']['id']}},_0x8ca74c,_0x394f46,_0x19560f,_0x2be249,_0x13caea;_0x2d7313=_[_0xbbcc('0x3f')]({},_0x2d7313,_0x2bfc2a[_0xbbcc('0x40')]);return db['AnalyticDefaultReport'][_0xbbcc('0x48')](_0x2d7313)[_0xbbcc('0x23')](function(_0x4d2622){if(_0x4d2622){_0x8ca74c=_0x4d2622;return _0x4d2622[_0xbbcc('0x69')]();}return null;})[_0xbbcc('0x23')](function(_0x4d8bd8){if(_0x4d8bd8){if(!_0x4d8bd8[_0xbbcc('0x37')]){throw new db[(_0xbbcc('0x6a'))][(_0xbbcc('0x6b'))](_0xbbcc('0x6c'),0x193);}_0x394f46=_0x4d8bd8;return db[_0xbbcc('0x6d')][_0xbbcc('0x6e')]({'raw':!![]});}return null;})[_0xbbcc('0x23')](function(_0x236459){if(_0x236459){_0x19560f=_['keyBy'](_0x236459,'id');var _0x995fa5;var _0x4687d6=squel[_0xbbcc('0x6f')]();_0x4687d6[_0xbbcc('0x70')](_0x8ca74c[_0xbbcc('0x71')]);for(var _0x808c5f=0x0;_0x808c5f<_0x394f46['length'];_0x808c5f+=0x1){_0x995fa5=_0x394f46[_0x808c5f]['MetricId']?_0x19560f[_0x394f46[_0x808c5f][_0xbbcc('0x72')]]['metric']:_0x394f46[_0x808c5f][_0xbbcc('0x68')];_0x995fa5=_0x394f46[_0x808c5f][_0xbbcc('0x73')]?_[_0xbbcc('0x74')](_0x3ab18f[_0x394f46[_0x808c5f][_0xbbcc('0x73')]],'%s',_0x995fa5):_0x995fa5;_0x995fa5=_0x394f46[_0x808c5f][_0xbbcc('0x75')]?_['replace'](_0x5508be[_0x394f46[_0x808c5f]['format']],'%s',_0x995fa5):_0x995fa5;if(_0x394f46[_0x808c5f][_0xbbcc('0x76')]){_0x4687d6[_0xbbcc('0x67')](_0x995fa5);}_0x394f46[_0x808c5f][_0xbbcc('0x77')]&&_0x4687d6['order'](_0x995fa5,_0x394f46[_0x808c5f][_0xbbcc('0x77')]===_0xbbcc('0x78')?![]:!![]);_0x4687d6[_0xbbcc('0x68')](_0x995fa5,_0x394f46[_0x808c5f]['alias']||_0x995fa5);}if(_0x8ca74c[_0xbbcc('0x79')]){_0x8ca74c[_0xbbcc('0x79')]=JSON[_0xbbcc('0x7a')](_0x8ca74c[_0xbbcc('0x79')]);for(var _0x58b9dc=0x0;_0x58b9dc<_0x8ca74c[_0xbbcc('0x79')][_0xbbcc('0x37')];_0x58b9dc+=0x1){if(_0x8ca74c[_0xbbcc('0x79')][_0x58b9dc][_0xbbcc('0x30')]&&_[_0xbbcc('0x62')](_0x312e27,_0x8ca74c[_0xbbcc('0x79')][_0x58b9dc]['type'])&&_0x8ca74c[_0xbbcc('0x79')][_0x58b9dc]['parentKey']&&_0x8ca74c[_0xbbcc('0x79')][_0x58b9dc][_0xbbcc('0x7b')]&&_0x8ca74c['joins'][_0x58b9dc][_0xbbcc('0x7c')]){_0x4687d6[_0x8ca74c['joins'][_0x58b9dc][_0xbbcc('0x30')]](_0x8ca74c[_0xbbcc('0x79')][_0x58b9dc][_0xbbcc('0x7b')],null,util[_0xbbcc('0x75')](_0xbbcc('0x7d'),_0x8ca74c[_0xbbcc('0x71')],_0x8ca74c[_0xbbcc('0x79')][_0x58b9dc][_0xbbcc('0x7e')],_0x8ca74c['joins'][_0x58b9dc][_0xbbcc('0x7b')],_0x8ca74c[_0xbbcc('0x79')][_0x58b9dc][_0xbbcc('0x7c')]));}}}if(_0x8ca74c[_0xbbcc('0x7f')]){_0x8ca74c['conditions']=JSON[_0xbbcc('0x7a')](_0x8ca74c[_0xbbcc('0x7f')]);_0x4687d6[_0xbbcc('0x3b')](_0x2e3663(_0x8ca74c[_0xbbcc('0x7f')]['group']));}_0x13caea=_0x4687d6[_0xbbcc('0x80')]();_0x4687d6['limit'](_0x251313);_0x4687d6[_0xbbcc('0x1c')](0x0);logger[_0xbbcc('0x81')](_0xbbcc('0x82'),_0x4687d6[_0xbbcc('0x83')]());return dbH[_0xbbcc('0x84')][_0xbbcc('0x33')](_0x4687d6['toString'](),{'type':dbH[_0xbbcc('0x84')][_0xbbcc('0x85')]['SELECT']});}})[_0xbbcc('0x23')](respondWithResult(_0x11d2aa,null))[_0xbbcc('0x43')](handleError(_0x11d2aa,null));};function runReport(_0x9732de,_0x472c7b,_0x565231){var _0x2b4c50=_0x472c7b['name'];var _0x50e024=0xa;var _0x1a004b=[_0xbbcc('0x53'),_0xbbcc('0x54'),_0xbbcc('0x55'),'cross_join'];var _0x52b6e8={'SUM':'SUM(%s)','COUNT':_0xbbcc('0x86'),'COUNT DISTINCT':_0xbbcc('0x58'),'MAX':_0xbbcc('0x87'),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0xbbcc('0x88')};var _0x3ac334={'SEC_TO_TIME':_0xbbcc('0x5d'),'DATE':_0xbbcc('0x5e'),'HOUR':'HOUR(%s)','ROUND':_0xbbcc('0x60'),'UNIX_TIMESTAMP':_0xbbcc('0x61')};var _0xa9d90f=function(_0x4220ae){return!_[_0xbbcc('0x62')]([_0xbbcc('0x63'),_0xbbcc('0x64'),_0xbbcc('0x89'),_0xbbcc('0x8a')],_0x4220ae);};var _0x1a6e2d=function(_0x47be13){if(!_0x47be13||!_0x47be13['rules'][_0xbbcc('0x37')]){return'';}for(var _0x22f45b='(',_0x4ed1d6=0x0;_0x4ed1d6<_0x47be13['rules']['length'];_0x4ed1d6+=0x1){_0x4ed1d6>0x0&&(_0x22f45b+='\x20'+_0x47be13[_0xbbcc('0x66')]+'\x20');_0x22f45b+=_0x47be13['rules'][_0x4ed1d6][_0xbbcc('0x67')]?_0x1a6e2d(_0x47be13[_0xbbcc('0x65')][_0x4ed1d6][_0xbbcc('0x67')]):_0x47be13[_0xbbcc('0x65')][_0x4ed1d6]['field']+'\x20'+_0x47be13['rules'][_0x4ed1d6][_0xbbcc('0x8b')]+(_0xa9d90f(_0x47be13[_0xbbcc('0x65')][_0x4ed1d6][_0xbbcc('0x8b')])?'\x20'+_0x47be13[_0xbbcc('0x65')][_0x4ed1d6][_0xbbcc('0x8c')]:'');}return _0x22f45b+')';};var _0x523edd={'where':{'id':_0x9732de['id']}},_0x89eaf0,_0x30551c,_0x379f2d,_0x328716,_0x2b25dc;_0x523edd=_['merge']({},_0x523edd,_0x565231);return db[_0xbbcc('0x2d')][_0xbbcc('0x48')](_0x523edd)['then'](function(_0x2745bb){if(_0x2745bb){_0x89eaf0=_0x2745bb;return _0x2745bb[_0xbbcc('0x69')]();}return null;})[_0xbbcc('0x23')](function(_0x4a3a88){if(_0x4a3a88){if(!_0x4a3a88['length']){throw new db[(_0xbbcc('0x6a'))][(_0xbbcc('0x6b'))](_0xbbcc('0x6c'),0x193);}_0x30551c=_0x4a3a88;return db[_0xbbcc('0x6d')]['findAll']({'raw':!![]});}return null;})['then'](function(_0x45297d){if(_0x45297d){_0x379f2d=_[_0xbbcc('0x8d')](_0x45297d,'id');var _0x216fc8;var _0x57ae47=squel[_0xbbcc('0x6f')]();_0x57ae47[_0xbbcc('0x70')](_0x89eaf0[_0xbbcc('0x71')]);for(var _0x3817ef=0x0;_0x3817ef<_0x30551c['length'];_0x3817ef+=0x1){_0x216fc8=_0x30551c[_0x3817ef][_0xbbcc('0x72')]?_0x379f2d[_0x30551c[_0x3817ef][_0xbbcc('0x72')]][_0xbbcc('0x8e')]:_0x30551c[_0x3817ef]['field'];_0x216fc8=_0x30551c[_0x3817ef][_0xbbcc('0x73')]?_[_0xbbcc('0x74')](_0x52b6e8[_0x30551c[_0x3817ef]['function']],'%s',_0x216fc8):_0x216fc8;_0x216fc8=_0x30551c[_0x3817ef][_0xbbcc('0x75')]?_[_0xbbcc('0x74')](_0x3ac334[_0x30551c[_0x3817ef][_0xbbcc('0x75')]],'%s',_0x216fc8):_0x216fc8;if(_0x30551c[_0x3817ef][_0xbbcc('0x76')]){_0x57ae47[_0xbbcc('0x67')](_0x216fc8);}_0x30551c[_0x3817ef][_0xbbcc('0x77')]&&_0x57ae47[_0xbbcc('0x39')](_0x216fc8,_0x30551c[_0x3817ef][_0xbbcc('0x77')]===_0xbbcc('0x78')?![]:!![]);_0x57ae47['field'](_0x216fc8,_0x30551c[_0x3817ef][_0xbbcc('0x8f')]||_0x216fc8);}if(_0x89eaf0[_0xbbcc('0x79')]){_0x89eaf0['joins']=JSON['parse'](_0x89eaf0['joins']);for(var _0x2ad4c5=0x0;_0x2ad4c5<_0x89eaf0['joins'][_0xbbcc('0x37')];_0x2ad4c5+=0x1){if(_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5][_0xbbcc('0x30')]&&_[_0xbbcc('0x62')](_0x1a004b,_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5][_0xbbcc('0x30')])&&_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5][_0xbbcc('0x7e')]&&_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5]['foreignTable']&&_0x89eaf0['joins'][_0x2ad4c5][_0xbbcc('0x7c')]){_0x57ae47[_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5]['type']](_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5][_0xbbcc('0x7b')],null,util['format'](_0xbbcc('0x7d'),_0x89eaf0[_0xbbcc('0x71')],_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5][_0xbbcc('0x7e')],_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5][_0xbbcc('0x7b')],_0x89eaf0[_0xbbcc('0x79')][_0x2ad4c5][_0xbbcc('0x7c')]));}}}if(_0x89eaf0['conditions']){_0x89eaf0[_0xbbcc('0x7f')]=JSON['parse'](_0x89eaf0[_0xbbcc('0x7f')]);_0x57ae47['where'](_0x1a6e2d(_0x89eaf0[_0xbbcc('0x7f')][_0xbbcc('0x67')]));}_0x2b25dc=_0x57ae47[_0xbbcc('0x80')]();_0x57ae47[_0xbbcc('0x38')](_0x50e024);_0x57ae47[_0xbbcc('0x1c')](0x0);return;}})[_0xbbcc('0x23')](function(){if(_0x472c7b[_0xbbcc('0x90')]===_0xbbcc('0x91')){return null;}var _0x323c5a=_[_0xbbcc('0x3f')](_0x472c7b,{'name':_0x472c7b['fullPath']||_0x472c7b[_0xbbcc('0x2a')]||_0x89eaf0[_0xbbcc('0x2a')],'basename':_0x2b4c50,'savename':util[_0xbbcc('0x75')](_0xbbcc('0x92'),_0x472c7b['name']||_0x89eaf0['name'],require(_0xbbcc('0x93'))[_0xbbcc('0x94')](0x4),_0x472c7b['output']||_0xbbcc('0x95')),'reportId':_0x89eaf0['id'],'reportType':_0xbbcc('0x96')});return db['AnalyticExtractedReport'][_0xbbcc('0x49')](_0x323c5a,{'raw':!![]});})[_0xbbcc('0x23')](function(_0x186609){if(_0x89eaf0[_0xbbcc('0x71')]===_0xbbcc('0x97')){_0x2b25dc[_0xbbcc('0x3b')](_0x89eaf0[_0xbbcc('0x71')]+_0xbbcc('0x98'),_0x472c7b[_0xbbcc('0x99')],_0x472c7b['endDate']);}else{_0x2b25dc[_0xbbcc('0x3b')](_0x89eaf0[_0xbbcc('0x71')]+_0xbbcc('0x9a'),_0x472c7b[_0xbbcc('0x99')],_0x472c7b['endDate']);}if(_0x186609){logger[_0xbbcc('0x9b')](_0xbbcc('0x9c'),_0x2b25dc[_0xbbcc('0x83')]());require(_0xbbcc('0x9d'))[_0xbbcc('0x9e')](path[_0xbbcc('0x53')](__dirname,_0xbbcc('0x9f'),_0x186609[_0xbbcc('0x90')]),[_0x186609['id'],_0x2b25dc['toString'](),path['join'](__dirname,_0xbbcc('0xa0'),_0x186609[_0xbbcc('0xa1')]),_0x2b4c50]);return _0x186609;}else{var _0x8a81c2=squel['select']();_0x8a81c2[_0xbbcc('0x70')]('('+_0x2b25dc[_0xbbcc('0x83')]()+')','countTable');_0x8a81c2[_0xbbcc('0x68')]('COUNT(*)','count');_0x2b25dc[_0xbbcc('0x38')](_0x472c7b[_0xbbcc('0x38')]||_0x50e024);_0x2b25dc[_0xbbcc('0x1c')](_0x472c7b['offset']||0x0);return dbH[_0xbbcc('0x84')][_0xbbcc('0x33')](_0x8a81c2['toString'](),{'type':dbH['sequelize'][_0xbbcc('0x85')][_0xbbcc('0xa2')]})[_0xbbcc('0x23')](function(_0x39434e){if(!_0x39434e[_0xbbcc('0x37')]){_0x328716=0x0;}else{_0x328716=_0x39434e[0x0][_0xbbcc('0x1b')]||0x0;}return dbH[_0xbbcc('0x84')]['query'](_0x2b25dc[_0xbbcc('0x83')](),{'type':dbH[_0xbbcc('0x84')][_0xbbcc('0x85')][_0xbbcc('0xa2')]});})[_0xbbcc('0x23')](function(_0x47fe9b){return{'rows':_0x47fe9b||[],'count':_0x328716};});}});}exports[_0xbbcc('0xa3')]=function(_0x573b60,_0x289e15){return runReport(_0x573b60['params'],_0x573b60[_0xbbcc('0x33')],_0x573b60[_0xbbcc('0x40')])[_0xbbcc('0x23')](respondWithResult(_0x289e15,null))['catch'](handleError(_0x289e15,null));};exports[_0xbbcc('0xa4')]=runReport;exports[_0xbbcc('0x33')]=function(_0x182a3c,_0xbfe881){var _0x41e164=0xa;var _0x33c121=[_0xbbcc('0x53'),'left_join',_0xbbcc('0x55'),_0xbbcc('0x56')];var _0xf902d0={'SUM':_0xbbcc('0x57'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xbbcc('0x58'),'MAX':_0xbbcc('0x87'),'MIN':_0xbbcc('0x59'),'AVG':_0xbbcc('0x5a'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':_0xbbcc('0x5c'),'GROUP_CONCAT DESC':_0xbbcc('0x88')};var _0x5b8196={'SEC_TO_TIME':_0xbbcc('0x5d'),'DATE':'DATE(%s)','HOUR':_0xbbcc('0x5f'),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xbbcc('0x61')};var _0x1cdef2=function(_0x6140e7){return!_[_0xbbcc('0x62')](['IS\x20NULL',_0xbbcc('0x64'),_0xbbcc('0x89'),'IS\x20NOT\x20EMPTY'],_0x6140e7);};var _0x5d743a=function(_0xaa1ba8){if(!_0xaa1ba8||!_0xaa1ba8['rules'][_0xbbcc('0x37')]){return'';}for(var _0x1d443d='(',_0x55b85b=0x0;_0x55b85b<_0xaa1ba8[_0xbbcc('0x65')][_0xbbcc('0x37')];_0x55b85b+=0x1){_0x55b85b>0x0&&(_0x1d443d+='\x20'+_0xaa1ba8['operator']+'\x20');_0x1d443d+=_0xaa1ba8[_0xbbcc('0x65')][_0x55b85b][_0xbbcc('0x67')]?_0x5d743a(_0xaa1ba8[_0xbbcc('0x65')][_0x55b85b][_0xbbcc('0x67')]):_0xaa1ba8['rules'][_0x55b85b][_0xbbcc('0x68')]+'\x20'+_0xaa1ba8['rules'][_0x55b85b]['condition']+(_0x1cdef2(_0xaa1ba8[_0xbbcc('0x65')][_0x55b85b][_0xbbcc('0x8b')])?'\x20'+_0xaa1ba8['rules'][_0x55b85b][_0xbbcc('0x8c')]:'');}return _0x1d443d+')';};var _0x32d7bd={'where':{'id':_0x182a3c[_0xbbcc('0x45')]['id']}},_0xc8e013,_0x441629,_0x230343,_0x1984cf,_0x2f1637;_0x32d7bd=_[_0xbbcc('0x3f')]({},_0x32d7bd,_0x182a3c[_0xbbcc('0x40')]);return db[_0xbbcc('0x2d')][_0xbbcc('0x48')](_0x32d7bd)[_0xbbcc('0x23')](function(_0x17cc87){if(_0x17cc87){_0xc8e013=_0x17cc87;return _0x17cc87['getFields']();}return null;})['then'](function(_0xfe6d7c){if(_0xfe6d7c){if(!_0xfe6d7c[_0xbbcc('0x37')]){throw new db[(_0xbbcc('0x6a'))][(_0xbbcc('0x6b'))]('Please\x20insert\x20at\x20least\x20one\x20field',0x193);}_0x441629=_0xfe6d7c;return db[_0xbbcc('0x6d')]['findAll']({'raw':!![]});}return null;})['then'](function(_0xba2481){if(_0xba2481){_0x230343=_[_0xbbcc('0x8d')](_0xba2481,'id');var _0x2345da;var _0x3c29bd=squel[_0xbbcc('0x6f')]();_0x3c29bd['from'](_0xc8e013[_0xbbcc('0x71')]);for(var _0x369305=0x0;_0x369305<_0x441629['length'];_0x369305+=0x1){_0x2345da=_0x441629[_0x369305][_0xbbcc('0x72')]?_0x230343[_0x441629[_0x369305][_0xbbcc('0x72')]]['metric']:_0x441629[_0x369305]['field'];_0x2345da=_0x441629[_0x369305]['function']?_[_0xbbcc('0x74')](_0xf902d0[_0x441629[_0x369305][_0xbbcc('0x73')]],'%s',_0x2345da):_0x2345da;_0x2345da=_0x441629[_0x369305]['format']?_[_0xbbcc('0x74')](_0x5b8196[_0x441629[_0x369305][_0xbbcc('0x75')]],'%s',_0x2345da):_0x2345da;if(_0x441629[_0x369305]['groupBy']){_0x3c29bd['group'](_0x2345da);}_0x441629[_0x369305][_0xbbcc('0x77')]&&_0x3c29bd[_0xbbcc('0x39')](_0x2345da,_0x441629[_0x369305][_0xbbcc('0x77')]==='DESC'?![]:!![]);_0x3c29bd[_0xbbcc('0x68')](_0x2345da,_0x441629[_0x369305][_0xbbcc('0x8f')]||_0x2345da);}if(_0xc8e013[_0xbbcc('0x79')]){_0xc8e013[_0xbbcc('0x79')]=JSON[_0xbbcc('0x7a')](_0xc8e013[_0xbbcc('0x79')]);for(var _0x4b800c=0x0;_0x4b800c<_0xc8e013[_0xbbcc('0x79')][_0xbbcc('0x37')];_0x4b800c+=0x1){if(_0xc8e013[_0xbbcc('0x79')][_0x4b800c][_0xbbcc('0x30')]&&_['includes'](_0x33c121,_0xc8e013[_0xbbcc('0x79')][_0x4b800c][_0xbbcc('0x30')])&&_0xc8e013[_0xbbcc('0x79')][_0x4b800c][_0xbbcc('0x7e')]&&_0xc8e013[_0xbbcc('0x79')][_0x4b800c][_0xbbcc('0x7b')]&&_0xc8e013[_0xbbcc('0x79')][_0x4b800c]['foreignKey']){_0x3c29bd[_0xc8e013[_0xbbcc('0x79')][_0x4b800c][_0xbbcc('0x30')]](_0xc8e013['joins'][_0x4b800c][_0xbbcc('0x7b')],null,util[_0xbbcc('0x75')](_0xbbcc('0x7d'),_0xc8e013[_0xbbcc('0x71')],_0xc8e013[_0xbbcc('0x79')][_0x4b800c][_0xbbcc('0x7e')],_0xc8e013[_0xbbcc('0x79')][_0x4b800c][_0xbbcc('0x7b')],_0xc8e013['joins'][_0x4b800c][_0xbbcc('0x7c')]));}}}if(_0xc8e013['conditions']){_0xc8e013[_0xbbcc('0x7f')]=JSON[_0xbbcc('0x7a')](_0xc8e013['conditions']);_0x3c29bd[_0xbbcc('0x3b')](_0x5d743a(_0xc8e013[_0xbbcc('0x7f')][_0xbbcc('0x67')]));}_0x2f1637=_0x3c29bd['clone']();_0x3c29bd[_0xbbcc('0x38')](_0x41e164);_0x3c29bd[_0xbbcc('0x1c')](0x0);logger['debug'](_0xbbcc('0x82'),_0x3c29bd[_0xbbcc('0x83')]());return dbH[_0xbbcc('0x84')]['query'](_0x3c29bd['toString'](),{'type':dbH['sequelize'][_0xbbcc('0x85')][_0xbbcc('0xa2')]});}})['then'](function(){return{'sql':_0x2f1637[_0xbbcc('0x83')]()};})[_0xbbcc('0x23')](respondWithResult(_0xbfe881,null))[_0xbbcc('0x43')](handleError(_0xbfe881,null));};
\ No newline at end of file