Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / api / analyticCustomReport / analyticCustomReport.controller.js
index 62ce5ea..e5aa32a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdec0=['.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','run','right_join','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','path','sox','ejs','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','set','apply','save','update','then','get','CustomReports','UserProfileResource','destroy','error','stack','name','index','AnalyticCustomReport','rawAttributes','fieldName','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','limit','order','sort','filters','pick','filter','where','type','VIRTUAL','merge','count','includeAll','include','findAll','rows','catch','show','params','options','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','preview','join','left_join','cross_join','SUM(%s)','COUNT(%s)','COUNT(DISTINCT\x20%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','HOUR(%s)','ROUND(%s)','UNIX_TIMESTAMP(%s)','IS\x20EMPTY','rules','group','condition','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','table','MetricId','metric','function','format','replace','groupBy','orderBy','DESC','field','alias','joins','parse','foreignTable','%s.%s\x20=\x20%s.%s','parentKey','foreignKey','conditions','clone','debug','Limited\x20Query:','toString','sequelize','QueryTypes','SELECT','DATE(%s)','IS\x20NULL','IS\x20NOT\x20NULL','IS\x20NOT\x20EMPTY','operator','value','getFields','includes','output','web','randomstring','generate','AnalyticExtractedReport','cdr','startDate','endDate'];(function(_0x4637c9,_0x51126e){var _0x434a20=function(_0x325f90){while(--_0x325f90){_0x4637c9['push'](_0x4637c9['shift']());}};_0x434a20(++_0x51126e);}(_0xdec0,0xab));var _0x0dec=function(_0x13342f,_0x3d6303){_0x13342f=_0x13342f-0x0;var _0x2fc1fc=_0xdec0[_0x13342f];return _0x2fc1fc;};'use strict';var pdf=require(_0x0dec('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x0dec('0x1'));var zipdir=require(_0x0dec('0x2'));var jsonpatch=require(_0x0dec('0x3'));var rp=require(_0x0dec('0x4'));var moment=require(_0x0dec('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x0dec('0x6'));var util=require('util');var path=require(_0x0dec('0x7'));var sox=require(_0x0dec('0x8'));var csv=require('to-csv');var ejs=require(_0x0dec('0x9'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x0dec('0xa'));var deskjs=require(_0x0dec('0xb'));var toCsv=require(_0x0dec('0xc'));var querystring=require(_0x0dec('0xd'));var Papa=require(_0x0dec('0xe'));var Redis=require(_0x0dec('0xf'));var authService=require(_0x0dec('0x10'));var qs=require(_0x0dec('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0dec('0x12'));var logger=require('../../config/logger')(_0x0dec('0x13'));var utils=require(_0x0dec('0x14'));var config=require(_0x0dec('0x15'));var licenseUtil=require(_0x0dec('0x16'));var db=require(_0x0dec('0x17'))['db'];var dbH=require(_0x0dec('0x17'))['dbH'];function respondWithStatusCode(_0x58178c,_0x38d043){_0x38d043=_0x38d043||0xcc;return function(_0x1da885){if(_0x1da885){return _0x58178c[_0x0dec('0x18')](_0x38d043);}return _0x58178c[_0x0dec('0x19')](_0x38d043)[_0x0dec('0x1a')]();};}function respondWithResult(_0x328a9d,_0x4ca8f5){_0x4ca8f5=_0x4ca8f5||0xc8;return function(_0x1dcf87){if(_0x1dcf87){return _0x328a9d[_0x0dec('0x19')](_0x4ca8f5)[_0x0dec('0x1b')](_0x1dcf87);}};}function respondWithFilteredResult(_0xacea7c,_0xfe3929){return function(_0x36ec6b){if(_0x36ec6b){var _0x4bfea5=_0x36ec6b['count'],_0x314f85=_0xfe3929[_0x0dec('0x1c')],_0x3c7f78=_0xfe3929['offset']+_0xfe3929['limit'],_0x226cd3;if(_0x3c7f78>=_0x4bfea5){_0x3c7f78=_0x4bfea5;_0x226cd3=0xc8;}else{_0x226cd3=0xce;}_0xacea7c[_0x0dec('0x19')](_0x226cd3);return _0xacea7c[_0x0dec('0x1d')]('Content-Range',_0x314f85+'-'+_0x3c7f78+'/'+_0x4bfea5)[_0x0dec('0x1b')](_0x36ec6b);}return null;};}function patchUpdates(_0x545eb5){return function(_0x19e034){try{jsonpatch[_0x0dec('0x1e')](_0x19e034,_0x545eb5,!![]);}catch(_0x213286){return BPromise['reject'](_0x213286);}return _0x19e034[_0x0dec('0x1f')]();};}function saveUpdates(_0x535199,_0x16d005){return function(_0x28173c){if(_0x28173c){return _0x28173c[_0x0dec('0x20')](_0x535199)[_0x0dec('0x21')](function(_0x48e651){return _0x48e651;});}return null;};}function removeEntity(_0x264d55,_0x357f79){return function(_0x2bd1eb){if(_0x2bd1eb){return _0x2bd1eb['destroy']()[_0x0dec('0x21')](function(){var _0x24fd90=_0x2bd1eb[_0x0dec('0x22')]({'plain':!![]});var _0x1f7ea3=_0x0dec('0x23');return db[_0x0dec('0x24')][_0x0dec('0x25')]({'where':{'type':_0x1f7ea3,'resourceId':_0x24fd90['id']}})[_0x0dec('0x21')](function(){return _0x2bd1eb;});})[_0x0dec('0x21')](function(){_0x264d55[_0x0dec('0x19')](0xcc)[_0x0dec('0x1a')]();});}};}function handleEntityNotFound(_0x7e197b,_0xb1458c){return function(_0x276296){if(!_0x276296){_0x7e197b[_0x0dec('0x18')](0x194);}return _0x276296;};}function handleError(_0x29b94d,_0x1509a3){_0x1509a3=_0x1509a3||0x1f4;return function(_0x45912b){logger[_0x0dec('0x26')](_0x45912b[_0x0dec('0x27')]);if(_0x45912b[_0x0dec('0x28')]){delete _0x45912b[_0x0dec('0x28')];}_0x29b94d[_0x0dec('0x19')](_0x1509a3)['send'](_0x45912b);};}exports[_0x0dec('0x29')]=function(_0x2db7f6,_0xd7713){var _0x45deb1={},_0x38a711={},_0x218bf2={'count':0x0,'rows':[]};var _0x5ab647=_['map'](db[_0x0dec('0x2a')][_0x0dec('0x2b')],function(_0x26743a){return{'name':_0x26743a[_0x0dec('0x2c')],'type':_0x26743a['type']['key']};});_0x38a711[_0x0dec('0x2d')]=_['map'](_0x5ab647,_0x0dec('0x28'));_0x38a711[_0x0dec('0x2e')]=_[_0x0dec('0x2f')](_0x2db7f6[_0x0dec('0x2e')]);_0x38a711['filters']=_[_0x0dec('0x30')](_0x38a711[_0x0dec('0x2d')],_0x38a711[_0x0dec('0x2e')]);_0x45deb1[_0x0dec('0x31')]=_[_0x0dec('0x30')](_0x38a711[_0x0dec('0x2d')],qs[_0x0dec('0x32')](_0x2db7f6['query']['fields']));_0x45deb1['attributes']=_0x45deb1[_0x0dec('0x31')][_0x0dec('0x33')]?_0x45deb1[_0x0dec('0x31')]:_0x38a711[_0x0dec('0x2d')];if(!_0x2db7f6[_0x0dec('0x2e')][_0x0dec('0x34')]('nolimit')){_0x45deb1[_0x0dec('0x35')]=qs[_0x0dec('0x35')](_0x2db7f6[_0x0dec('0x2e')]['limit']);_0x45deb1[_0x0dec('0x1c')]=qs[_0x0dec('0x1c')](_0x2db7f6[_0x0dec('0x2e')][_0x0dec('0x1c')]);}_0x45deb1[_0x0dec('0x36')]=qs['sort'](_0x2db7f6['query'][_0x0dec('0x37')]);_0x45deb1['where']=qs[_0x0dec('0x38')](_[_0x0dec('0x39')](_0x2db7f6['query'],_0x38a711[_0x0dec('0x38')]),_0x5ab647);if(_0x2db7f6[_0x0dec('0x2e')][_0x0dec('0x3a')]){_0x45deb1[_0x0dec('0x3b')]=_['merge'](_0x45deb1[_0x0dec('0x3b')],{'$or':_['map'](_0x5ab647,function(_0x29002d){if(_0x29002d[_0x0dec('0x3c')]!==_0x0dec('0x3d')){var _0x2c9bd8={};_0x2c9bd8[_0x29002d[_0x0dec('0x28')]]={'$like':'%'+_0x2db7f6['query'][_0x0dec('0x3a')]+'%'};return _0x2c9bd8;}})});}_0x45deb1=_[_0x0dec('0x3e')]({},_0x45deb1,_0x2db7f6['options']);var _0x153988={'where':_0x45deb1[_0x0dec('0x3b')]};return db[_0x0dec('0x2a')][_0x0dec('0x3f')](_0x153988)[_0x0dec('0x21')](function(_0x65b561){_0x218bf2[_0x0dec('0x3f')]=_0x65b561;if(_0x2db7f6[_0x0dec('0x2e')][_0x0dec('0x40')]){_0x45deb1[_0x0dec('0x41')]=[{'all':!![]}];}return db[_0x0dec('0x2a')][_0x0dec('0x42')](_0x45deb1);})[_0x0dec('0x21')](function(_0x220948){_0x218bf2[_0x0dec('0x43')]=_0x220948;return _0x218bf2;})[_0x0dec('0x21')](respondWithFilteredResult(_0xd7713,_0x45deb1))[_0x0dec('0x44')](handleError(_0xd7713,null));};exports[_0x0dec('0x45')]=function(_0x141257,_0x377d66){var _0x1701a7={'raw':![],'where':{'id':_0x141257[_0x0dec('0x46')]['id']}},_0x52cb61={};_0x52cb61[_0x0dec('0x2d')]=_[_0x0dec('0x2f')](db[_0x0dec('0x2a')][_0x0dec('0x2b')]);_0x52cb61['query']=_[_0x0dec('0x2f')](_0x141257[_0x0dec('0x2e')]);_0x52cb61[_0x0dec('0x38')]=_[_0x0dec('0x30')](_0x52cb61[_0x0dec('0x2d')],_0x52cb61['query']);_0x1701a7[_0x0dec('0x31')]=_[_0x0dec('0x30')](_0x52cb61[_0x0dec('0x2d')],qs[_0x0dec('0x32')](_0x141257[_0x0dec('0x2e')][_0x0dec('0x32')]));_0x1701a7[_0x0dec('0x31')]=_0x1701a7['attributes']['length']?_0x1701a7['attributes']:_0x52cb61[_0x0dec('0x2d')];if(_0x141257[_0x0dec('0x2e')]['includeAll']){_0x1701a7[_0x0dec('0x41')]=[{'all':!![]}];}_0x1701a7=_['merge']({},_0x1701a7,_0x141257[_0x0dec('0x47')]);return db[_0x0dec('0x2a')][_0x0dec('0x48')](_0x1701a7)['then'](handleEntityNotFound(_0x377d66,null))[_0x0dec('0x21')](respondWithResult(_0x377d66,null))['catch'](handleError(_0x377d66,null));};exports[_0x0dec('0x49')]=function(_0x34a946,_0x21469c){return db[_0x0dec('0x2a')][_0x0dec('0x49')](_0x34a946['body'],{})[_0x0dec('0x21')](function(_0x6f9d15){var _0x3abe20=_0x34a946[_0x0dec('0x4a')]['get']({'plain':!![]});if(!_0x3abe20)throw new Error(_0x0dec('0x4b'));if(_0x3abe20[_0x0dec('0x4c')]===_0x0dec('0x4a')){var _0x282c07=_0x6f9d15[_0x0dec('0x22')]({'plain':!![]});var _0x28ef4c='Reports';return db[_0x0dec('0x4d')][_0x0dec('0x48')]({'where':{'name':_0x28ef4c,'userProfileId':_0x3abe20[_0x0dec('0x4e')]},'raw':!![]})['then'](function(_0x5cab19){if(_0x5cab19&&_0x5cab19[_0x0dec('0x4f')]===0x0){return db[_0x0dec('0x24')][_0x0dec('0x49')]({'name':_0x282c07[_0x0dec('0x28')],'resourceId':_0x282c07['id'],'type':_0x0dec('0x23'),'sectionId':_0x5cab19['id']},{})[_0x0dec('0x21')](function(){return _0x6f9d15;});}else{return _0x6f9d15;}})[_0x0dec('0x44')](function(_0x102dd8){logger[_0x0dec('0x26')](_0x0dec('0x50'),_0x102dd8);throw _0x102dd8;});}return _0x6f9d15;})['then'](respondWithResult(_0x21469c,0xc9))['catch'](handleError(_0x21469c,null));};exports[_0x0dec('0x20')]=function(_0x2e1d8d,_0x54fb5b){if(_0x2e1d8d[_0x0dec('0x51')]['id']){delete _0x2e1d8d['body']['id'];}return db[_0x0dec('0x2a')][_0x0dec('0x48')]({'where':{'id':_0x2e1d8d['params']['id']}})[_0x0dec('0x21')](handleEntityNotFound(_0x54fb5b,null))[_0x0dec('0x21')](saveUpdates(_0x2e1d8d[_0x0dec('0x51')],null))[_0x0dec('0x21')](respondWithResult(_0x54fb5b,null))[_0x0dec('0x44')](handleError(_0x54fb5b,null));};exports['destroy']=function(_0x5ac483,_0x47383f){return db['AnalyticCustomReport'][_0x0dec('0x48')]({'where':{'id':_0x5ac483[_0x0dec('0x46')]['id']}})['then'](handleEntityNotFound(_0x47383f,null))[_0x0dec('0x21')](removeEntity(_0x47383f,null))[_0x0dec('0x44')](handleError(_0x47383f,null));};exports[_0x0dec('0x52')]=function(_0x57f8d4,_0x1bc597){var _0x69380a=0xa;var _0x504133=[_0x0dec('0x53'),_0x0dec('0x54'),'right_join',_0x0dec('0x55')];var _0x596e39={'SUM':_0x0dec('0x56'),'COUNT':_0x0dec('0x57'),'COUNT DISTINCT':_0x0dec('0x58'),'MAX':_0x0dec('0x59'),'MIN':_0x0dec('0x5a'),'AVG':_0x0dec('0x5b'),'GROUP_CONCAT':_0x0dec('0x5c'),'GROUP_CONCAT ASC':_0x0dec('0x5d'),'GROUP_CONCAT DESC':_0x0dec('0x5e')};var _0x310510={'SEC_TO_TIME':_0x0dec('0x5f'),'DATE':'DATE(%s)','HOUR':_0x0dec('0x60'),'ROUND':_0x0dec('0x61'),'UNIX_TIMESTAMP':_0x0dec('0x62')};var _0x23a172=function(_0x5d0703){return!_['includes'](['IS\x20NULL','IS\x20NOT\x20NULL',_0x0dec('0x63'),'IS\x20NOT\x20EMPTY'],_0x5d0703);};var _0x4bb0db=function(_0x23e378){if(!_0x23e378||!_0x23e378[_0x0dec('0x64')][_0x0dec('0x33')]){return'';}for(var _0x4f45e2='(',_0x570d6f=0x0;_0x570d6f<_0x23e378[_0x0dec('0x64')][_0x0dec('0x33')];_0x570d6f+=0x1){_0x570d6f>0x0&&(_0x4f45e2+='\x20'+_0x23e378['operator']+'\x20');_0x4f45e2+=_0x23e378[_0x0dec('0x64')][_0x570d6f][_0x0dec('0x65')]?_0x4bb0db(_0x23e378[_0x0dec('0x64')][_0x570d6f][_0x0dec('0x65')]):_0x23e378['rules'][_0x570d6f]['field']+'\x20'+_0x23e378[_0x0dec('0x64')][_0x570d6f]['condition']+(_0x23a172(_0x23e378[_0x0dec('0x64')][_0x570d6f][_0x0dec('0x66')])?'\x20'+_0x23e378[_0x0dec('0x64')][_0x570d6f]['value']:'');}return _0x4f45e2+')';};var _0x8bf826={'where':{'id':_0x57f8d4['params']['id']}},_0x2388fd,_0x6788a6,_0x4b7ae0,_0x1ae0c1,_0x1d1e41;_0x8bf826=_[_0x0dec('0x3e')]({},_0x8bf826,_0x57f8d4[_0x0dec('0x47')]);return db['AnalyticCustomReport']['find'](_0x8bf826)[_0x0dec('0x21')](function(_0x18725c){if(_0x18725c){_0x2388fd=_0x18725c;return _0x18725c['getFields']();}return null;})[_0x0dec('0x21')](function(_0x4ec1fc){if(_0x4ec1fc){if(!_0x4ec1fc[_0x0dec('0x33')]){throw new db[(_0x0dec('0x67'))][(_0x0dec('0x68'))](_0x0dec('0x69'),0x193);}_0x6788a6=_0x4ec1fc;return db[_0x0dec('0x6a')][_0x0dec('0x42')]({'raw':!![]});}return null;})[_0x0dec('0x21')](function(_0x3b3046){if(_0x3b3046){_0x4b7ae0=_[_0x0dec('0x6b')](_0x3b3046,'id');var _0x325d26;var _0x26f8d6=squel[_0x0dec('0x6c')]();_0x26f8d6[_0x0dec('0x6d')](_0x2388fd[_0x0dec('0x6e')]);for(var _0x2394dc=0x0;_0x2394dc<_0x6788a6[_0x0dec('0x33')];_0x2394dc+=0x1){_0x325d26=_0x6788a6[_0x2394dc]['MetricId']?_0x4b7ae0[_0x6788a6[_0x2394dc][_0x0dec('0x6f')]][_0x0dec('0x70')]:_0x6788a6[_0x2394dc]['field'];_0x325d26=_0x6788a6[_0x2394dc][_0x0dec('0x71')]?_['replace'](_0x596e39[_0x6788a6[_0x2394dc][_0x0dec('0x71')]],'%s',_0x325d26):_0x325d26;_0x325d26=_0x6788a6[_0x2394dc][_0x0dec('0x72')]?_[_0x0dec('0x73')](_0x310510[_0x6788a6[_0x2394dc][_0x0dec('0x72')]],'%s',_0x325d26):_0x325d26;if(_0x6788a6[_0x2394dc][_0x0dec('0x74')]){_0x26f8d6[_0x0dec('0x65')](_0x325d26);}_0x6788a6[_0x2394dc][_0x0dec('0x75')]&&_0x26f8d6[_0x0dec('0x36')](_0x325d26,_0x6788a6[_0x2394dc][_0x0dec('0x75')]===_0x0dec('0x76')?![]:!![]);_0x26f8d6[_0x0dec('0x77')](_0x325d26,_0x6788a6[_0x2394dc][_0x0dec('0x78')]||_0x325d26);}if(_0x2388fd[_0x0dec('0x79')]){_0x2388fd['joins']=JSON[_0x0dec('0x7a')](_0x2388fd[_0x0dec('0x79')]);for(var _0x566878=0x0;_0x566878<_0x2388fd[_0x0dec('0x79')][_0x0dec('0x33')];_0x566878+=0x1){if(_0x2388fd[_0x0dec('0x79')][_0x566878]['type']&&_['includes'](_0x504133,_0x2388fd[_0x0dec('0x79')][_0x566878][_0x0dec('0x3c')])&&_0x2388fd[_0x0dec('0x79')][_0x566878]['parentKey']&&_0x2388fd[_0x0dec('0x79')][_0x566878][_0x0dec('0x7b')]&&_0x2388fd[_0x0dec('0x79')][_0x566878]['foreignKey']){_0x26f8d6[_0x2388fd[_0x0dec('0x79')][_0x566878]['type']](_0x2388fd['joins'][_0x566878][_0x0dec('0x7b')],null,util[_0x0dec('0x72')](_0x0dec('0x7c'),_0x2388fd['table'],_0x2388fd[_0x0dec('0x79')][_0x566878][_0x0dec('0x7d')],_0x2388fd[_0x0dec('0x79')][_0x566878][_0x0dec('0x7b')],_0x2388fd['joins'][_0x566878][_0x0dec('0x7e')]));}}}if(_0x2388fd[_0x0dec('0x7f')]){_0x2388fd[_0x0dec('0x7f')]=JSON[_0x0dec('0x7a')](_0x2388fd[_0x0dec('0x7f')]);_0x26f8d6[_0x0dec('0x3b')](_0x4bb0db(_0x2388fd['conditions'][_0x0dec('0x65')]));}_0x1d1e41=_0x26f8d6[_0x0dec('0x80')]();_0x26f8d6[_0x0dec('0x35')](_0x69380a);_0x26f8d6['offset'](0x0);logger[_0x0dec('0x81')](_0x0dec('0x82'),_0x26f8d6[_0x0dec('0x83')]());return dbH[_0x0dec('0x84')][_0x0dec('0x2e')](_0x26f8d6[_0x0dec('0x83')](),{'type':dbH[_0x0dec('0x84')][_0x0dec('0x85')][_0x0dec('0x86')]});}})['then'](respondWithResult(_0x1bc597,null))[_0x0dec('0x44')](handleError(_0x1bc597,null));};function runReport(_0x4a4e5f,_0x752c61,_0x4ed563){var _0x5706e8=_0x752c61[_0x0dec('0x28')];var _0x1eca4e=0xa;var _0x16cf8b=['join',_0x0dec('0x54'),'right_join',_0x0dec('0x55')];var _0x4fc697={'SUM':_0x0dec('0x56'),'COUNT':_0x0dec('0x57'),'COUNT DISTINCT':_0x0dec('0x58'),'MAX':_0x0dec('0x59'),'MIN':_0x0dec('0x5a'),'AVG':'AVG(%s)','GROUP_CONCAT':_0x0dec('0x5c'),'GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x0dec('0x5e')};var _0x265268={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':_0x0dec('0x87'),'HOUR':_0x0dec('0x60'),'ROUND':_0x0dec('0x61'),'UNIX_TIMESTAMP':_0x0dec('0x62')};var _0x5dd3cc=function(_0x421e12){return!_['includes']([_0x0dec('0x88'),_0x0dec('0x89'),_0x0dec('0x63'),_0x0dec('0x8a')],_0x421e12);};var _0x1064b5=function(_0x56065c){if(!_0x56065c||!_0x56065c[_0x0dec('0x64')][_0x0dec('0x33')]){return'';}for(var _0x40affc='(',_0x37eef8=0x0;_0x37eef8<_0x56065c[_0x0dec('0x64')][_0x0dec('0x33')];_0x37eef8+=0x1){_0x37eef8>0x0&&(_0x40affc+='\x20'+_0x56065c[_0x0dec('0x8b')]+'\x20');_0x40affc+=_0x56065c[_0x0dec('0x64')][_0x37eef8][_0x0dec('0x65')]?_0x1064b5(_0x56065c[_0x0dec('0x64')][_0x37eef8]['group']):_0x56065c['rules'][_0x37eef8][_0x0dec('0x77')]+'\x20'+_0x56065c[_0x0dec('0x64')][_0x37eef8]['condition']+(_0x5dd3cc(_0x56065c[_0x0dec('0x64')][_0x37eef8]['condition'])?'\x20'+_0x56065c[_0x0dec('0x64')][_0x37eef8][_0x0dec('0x8c')]:'');}return _0x40affc+')';};var _0x465e8d={'where':{'id':_0x4a4e5f['id']}},_0x523537,_0xaba70b,_0x46bf61,_0x51b101,_0x5ed766;_0x465e8d=_[_0x0dec('0x3e')]({},_0x465e8d,_0x4ed563);return db[_0x0dec('0x2a')][_0x0dec('0x48')](_0x465e8d)[_0x0dec('0x21')](function(_0x5ef22e){if(_0x5ef22e){_0x523537=_0x5ef22e;return _0x5ef22e[_0x0dec('0x8d')]();}return null;})[_0x0dec('0x21')](function(_0xf5ab6d){if(_0xf5ab6d){if(!_0xf5ab6d[_0x0dec('0x33')]){throw new db['Sequelize'][(_0x0dec('0x68'))](_0x0dec('0x69'),0x193);}_0xaba70b=_0xf5ab6d;return db[_0x0dec('0x6a')][_0x0dec('0x42')]({'raw':!![]});}return null;})[_0x0dec('0x21')](function(_0x47de49){if(_0x47de49){_0x46bf61=_['keyBy'](_0x47de49,'id');var _0x4da5a8;var _0x45046a=squel[_0x0dec('0x6c')]();_0x45046a[_0x0dec('0x6d')](_0x523537['table']);for(var _0x22135f=0x0;_0x22135f<_0xaba70b[_0x0dec('0x33')];_0x22135f+=0x1){_0x4da5a8=_0xaba70b[_0x22135f][_0x0dec('0x6f')]?_0x46bf61[_0xaba70b[_0x22135f][_0x0dec('0x6f')]]['metric']:_0xaba70b[_0x22135f]['field'];_0x4da5a8=_0xaba70b[_0x22135f][_0x0dec('0x71')]?_['replace'](_0x4fc697[_0xaba70b[_0x22135f][_0x0dec('0x71')]],'%s',_0x4da5a8):_0x4da5a8;_0x4da5a8=_0xaba70b[_0x22135f][_0x0dec('0x72')]?_['replace'](_0x265268[_0xaba70b[_0x22135f][_0x0dec('0x72')]],'%s',_0x4da5a8):_0x4da5a8;if(_0xaba70b[_0x22135f]['groupBy']){_0x45046a[_0x0dec('0x65')](_0x4da5a8);}_0xaba70b[_0x22135f][_0x0dec('0x75')]&&_0x45046a[_0x0dec('0x36')](_0x4da5a8,_0xaba70b[_0x22135f][_0x0dec('0x75')]===_0x0dec('0x76')?![]:!![]);_0x45046a[_0x0dec('0x77')](_0x4da5a8,_0xaba70b[_0x22135f][_0x0dec('0x78')]||_0x4da5a8);}if(_0x523537['joins']){_0x523537[_0x0dec('0x79')]=JSON[_0x0dec('0x7a')](_0x523537['joins']);for(var _0x2f2cd6=0x0;_0x2f2cd6<_0x523537[_0x0dec('0x79')][_0x0dec('0x33')];_0x2f2cd6+=0x1){if(_0x523537[_0x0dec('0x79')][_0x2f2cd6][_0x0dec('0x3c')]&&_[_0x0dec('0x8e')](_0x16cf8b,_0x523537['joins'][_0x2f2cd6][_0x0dec('0x3c')])&&_0x523537[_0x0dec('0x79')][_0x2f2cd6][_0x0dec('0x7d')]&&_0x523537['joins'][_0x2f2cd6][_0x0dec('0x7b')]&&_0x523537['joins'][_0x2f2cd6][_0x0dec('0x7e')]){_0x45046a[_0x523537[_0x0dec('0x79')][_0x2f2cd6]['type']](_0x523537[_0x0dec('0x79')][_0x2f2cd6][_0x0dec('0x7b')],null,util[_0x0dec('0x72')](_0x0dec('0x7c'),_0x523537['table'],_0x523537[_0x0dec('0x79')][_0x2f2cd6]['parentKey'],_0x523537[_0x0dec('0x79')][_0x2f2cd6][_0x0dec('0x7b')],_0x523537[_0x0dec('0x79')][_0x2f2cd6][_0x0dec('0x7e')]));}}}if(_0x523537['conditions']){_0x523537['conditions']=JSON['parse'](_0x523537[_0x0dec('0x7f')]);_0x45046a[_0x0dec('0x3b')](_0x1064b5(_0x523537[_0x0dec('0x7f')]['group']));}_0x5ed766=_0x45046a[_0x0dec('0x80')]();_0x45046a[_0x0dec('0x35')](_0x1eca4e);_0x45046a[_0x0dec('0x1c')](0x0);return;}})['then'](function(){if(_0x752c61[_0x0dec('0x8f')]===_0x0dec('0x90')){return null;}var _0x49ad53=_[_0x0dec('0x3e')](_0x752c61,{'name':_0x752c61['fullPath']||_0x752c61['name']||_0x523537[_0x0dec('0x28')],'basename':_0x5706e8,'savename':util['format']('%s-%s.%s',_0x752c61[_0x0dec('0x28')]||_0x523537['name'],require(_0x0dec('0x91'))[_0x0dec('0x92')](0x4),_0x752c61[_0x0dec('0x8f')]||'csv'),'reportId':_0x523537['id'],'reportType':'custom'});return db[_0x0dec('0x93')]['create'](_0x49ad53,{'raw':!![]});})[_0x0dec('0x21')](function(_0x205080){if(_0x523537[_0x0dec('0x6e')]===_0x0dec('0x94')){_0x5ed766[_0x0dec('0x3b')](_0x523537[_0x0dec('0x6e')]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x752c61[_0x0dec('0x95')],_0x752c61[_0x0dec('0x96')]);}else{_0x5ed766[_0x0dec('0x3b')](_0x523537[_0x0dec('0x6e')]+_0x0dec('0x97'),_0x752c61[_0x0dec('0x95')],_0x752c61[_0x0dec('0x96')]);}if(_0x205080){logger[_0x0dec('0x98')](_0x0dec('0x99'),_0x5ed766[_0x0dec('0x83')]());require(_0x0dec('0x9a'))[_0x0dec('0x9b')](path[_0x0dec('0x53')](__dirname,_0x0dec('0x9c'),_0x205080[_0x0dec('0x8f')]),[_0x205080['id'],_0x5ed766[_0x0dec('0x83')](),path[_0x0dec('0x53')](__dirname,_0x0dec('0x9d'),_0x205080[_0x0dec('0x9e')]),_0x5706e8]);return _0x205080;}else{var _0x388429=squel[_0x0dec('0x6c')]();_0x388429[_0x0dec('0x6d')]('('+_0x5ed766[_0x0dec('0x83')]()+')','countTable');_0x388429[_0x0dec('0x77')]('COUNT(*)','count');_0x5ed766[_0x0dec('0x35')](_0x752c61[_0x0dec('0x35')]||_0x1eca4e);_0x5ed766[_0x0dec('0x1c')](_0x752c61[_0x0dec('0x1c')]||0x0);return dbH[_0x0dec('0x84')][_0x0dec('0x2e')](_0x388429[_0x0dec('0x83')](),{'type':dbH[_0x0dec('0x84')][_0x0dec('0x85')][_0x0dec('0x86')]})[_0x0dec('0x21')](function(_0x538996){if(!_0x538996['length']){_0x51b101=0x0;}else{_0x51b101=_0x538996[0x0]['count']||0x0;}return dbH[_0x0dec('0x84')][_0x0dec('0x2e')](_0x5ed766[_0x0dec('0x83')](),{'type':dbH[_0x0dec('0x84')][_0x0dec('0x85')][_0x0dec('0x86')]});})[_0x0dec('0x21')](function(_0x6dd28){return{'rows':_0x6dd28||[],'count':_0x51b101};});}});}exports[_0x0dec('0x9f')]=function(_0x22f58d,_0x50bf82){return runReport(_0x22f58d[_0x0dec('0x46')],_0x22f58d[_0x0dec('0x2e')],_0x22f58d[_0x0dec('0x47')])['then'](respondWithResult(_0x50bf82,null))['catch'](handleError(_0x50bf82,null));};exports['runReport']=runReport;exports['query']=function(_0x5a0a53,_0x3dd484){var _0x74826a=0xa;var _0x43105e=['join','left_join',_0x0dec('0xa0'),_0x0dec('0x55')];var _0x13453b={'SUM':_0x0dec('0x56'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0x0dec('0x58'),'MAX':_0x0dec('0x59'),'MIN':'MIN(%s)','AVG':_0x0dec('0x5b'),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT DESC':_0x0dec('0x5e')};var _0x3e8ec6={'SEC_TO_TIME':_0x0dec('0x5f'),'DATE':_0x0dec('0x87'),'HOUR':_0x0dec('0x60'),'ROUND':_0x0dec('0x61'),'UNIX_TIMESTAMP':_0x0dec('0x62')};var _0x2c1e02=function(_0x4bf89e){return!_[_0x0dec('0x8e')]([_0x0dec('0x88'),_0x0dec('0x89'),_0x0dec('0x63'),'IS\x20NOT\x20EMPTY'],_0x4bf89e);};var _0x2253d1=function(_0x4b8e35){if(!_0x4b8e35||!_0x4b8e35[_0x0dec('0x64')][_0x0dec('0x33')]){return'';}for(var _0x32758f='(',_0x16c969=0x0;_0x16c969<_0x4b8e35[_0x0dec('0x64')]['length'];_0x16c969+=0x1){_0x16c969>0x0&&(_0x32758f+='\x20'+_0x4b8e35[_0x0dec('0x8b')]+'\x20');_0x32758f+=_0x4b8e35[_0x0dec('0x64')][_0x16c969][_0x0dec('0x65')]?_0x2253d1(_0x4b8e35[_0x0dec('0x64')][_0x16c969][_0x0dec('0x65')]):_0x4b8e35[_0x0dec('0x64')][_0x16c969][_0x0dec('0x77')]+'\x20'+_0x4b8e35[_0x0dec('0x64')][_0x16c969][_0x0dec('0x66')]+(_0x2c1e02(_0x4b8e35[_0x0dec('0x64')][_0x16c969][_0x0dec('0x66')])?'\x20'+_0x4b8e35[_0x0dec('0x64')][_0x16c969][_0x0dec('0x8c')]:'');}return _0x32758f+')';};var _0x5ab9f6={'where':{'id':_0x5a0a53['params']['id']}},_0x1e7052,_0x4e4e15,_0x2baea8,_0x30842d,_0x7d151a;_0x5ab9f6=_[_0x0dec('0x3e')]({},_0x5ab9f6,_0x5a0a53['options']);return db[_0x0dec('0x2a')][_0x0dec('0x48')](_0x5ab9f6)[_0x0dec('0x21')](function(_0x5c2a0b){if(_0x5c2a0b){_0x1e7052=_0x5c2a0b;return _0x5c2a0b['getFields']();}return null;})[_0x0dec('0x21')](function(_0x2bb6ab){if(_0x2bb6ab){if(!_0x2bb6ab[_0x0dec('0x33')]){throw new db[(_0x0dec('0x67'))]['ValidationErrorItem'](_0x0dec('0x69'),0x193);}_0x4e4e15=_0x2bb6ab;return db[_0x0dec('0x6a')][_0x0dec('0x42')]({'raw':!![]});}return null;})[_0x0dec('0x21')](function(_0x9a855e){if(_0x9a855e){_0x2baea8=_[_0x0dec('0x6b')](_0x9a855e,'id');var _0x1a764e;var _0x7050a=squel['select']();_0x7050a[_0x0dec('0x6d')](_0x1e7052['table']);for(var _0x308ef2=0x0;_0x308ef2<_0x4e4e15[_0x0dec('0x33')];_0x308ef2+=0x1){_0x1a764e=_0x4e4e15[_0x308ef2][_0x0dec('0x6f')]?_0x2baea8[_0x4e4e15[_0x308ef2]['MetricId']][_0x0dec('0x70')]:_0x4e4e15[_0x308ef2]['field'];_0x1a764e=_0x4e4e15[_0x308ef2][_0x0dec('0x71')]?_[_0x0dec('0x73')](_0x13453b[_0x4e4e15[_0x308ef2][_0x0dec('0x71')]],'%s',_0x1a764e):_0x1a764e;_0x1a764e=_0x4e4e15[_0x308ef2]['format']?_['replace'](_0x3e8ec6[_0x4e4e15[_0x308ef2][_0x0dec('0x72')]],'%s',_0x1a764e):_0x1a764e;if(_0x4e4e15[_0x308ef2][_0x0dec('0x74')]){_0x7050a[_0x0dec('0x65')](_0x1a764e);}_0x4e4e15[_0x308ef2][_0x0dec('0x75')]&&_0x7050a[_0x0dec('0x36')](_0x1a764e,_0x4e4e15[_0x308ef2]['orderBy']==='DESC'?![]:!![]);_0x7050a[_0x0dec('0x77')](_0x1a764e,_0x4e4e15[_0x308ef2]['alias']||_0x1a764e);}if(_0x1e7052['joins']){_0x1e7052['joins']=JSON[_0x0dec('0x7a')](_0x1e7052[_0x0dec('0x79')]);for(var _0x21c118=0x0;_0x21c118<_0x1e7052[_0x0dec('0x79')][_0x0dec('0x33')];_0x21c118+=0x1){if(_0x1e7052[_0x0dec('0x79')][_0x21c118][_0x0dec('0x3c')]&&_[_0x0dec('0x8e')](_0x43105e,_0x1e7052[_0x0dec('0x79')][_0x21c118]['type'])&&_0x1e7052[_0x0dec('0x79')][_0x21c118][_0x0dec('0x7d')]&&_0x1e7052[_0x0dec('0x79')][_0x21c118][_0x0dec('0x7b')]&&_0x1e7052['joins'][_0x21c118][_0x0dec('0x7e')]){_0x7050a[_0x1e7052[_0x0dec('0x79')][_0x21c118][_0x0dec('0x3c')]](_0x1e7052[_0x0dec('0x79')][_0x21c118][_0x0dec('0x7b')],null,util['format']('%s.%s\x20=\x20%s.%s',_0x1e7052['table'],_0x1e7052[_0x0dec('0x79')][_0x21c118][_0x0dec('0x7d')],_0x1e7052[_0x0dec('0x79')][_0x21c118][_0x0dec('0x7b')],_0x1e7052[_0x0dec('0x79')][_0x21c118][_0x0dec('0x7e')]));}}}if(_0x1e7052[_0x0dec('0x7f')]){_0x1e7052['conditions']=JSON[_0x0dec('0x7a')](_0x1e7052['conditions']);_0x7050a[_0x0dec('0x3b')](_0x2253d1(_0x1e7052[_0x0dec('0x7f')][_0x0dec('0x65')]));}_0x7d151a=_0x7050a[_0x0dec('0x80')]();_0x7050a[_0x0dec('0x35')](_0x74826a);_0x7050a['offset'](0x0);logger[_0x0dec('0x81')](_0x0dec('0x82'),_0x7050a[_0x0dec('0x83')]());return dbH[_0x0dec('0x84')][_0x0dec('0x2e')](_0x7050a[_0x0dec('0x83')](),{'type':dbH[_0x0dec('0x84')]['QueryTypes'][_0x0dec('0x86')]});}})[_0x0dec('0x21')](function(){return{'sql':_0x7d151a[_0x0dec('0x83')]()};})[_0x0dec('0x21')](respondWithResult(_0x3dd484,null))['catch'](handleError(_0x3dd484,null));};
\ No newline at end of file
+var _0x415c=['IS\x20NULL','IS\x20EMPTY','IS\x20NOT\x20EMPTY','rules','operator','group','condition','params','getFields','Sequelize','ValidationErrorItem','Please\x20insert\x20at\x20least\x20one\x20field','AnalyticMetric','keyBy','select','from','table','MetricId','field','function','replace','format','groupBy','orderBy','order','joins','parse','foreignTable','foreignKey','%s.%s\x20=\x20%s.%s','parentKey','conditions','sequelize','toString','SELECT','right_join','COUNT(DISTINCT\x20%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','SEC_TO_TIME(%s)','DATE(%s)','UNIX_TIMESTAMP(%s)','IS\x20NOT\x20NULL','value','metric','DESC','alias','clone','output','%s-%s.%s','randomstring','generate','custom','AnalyticExtractedReport','cdr','.calldate\x20BETWEEN\x20?\x20AND\x20?','startDate','.createdAt\x20BETWEEN\x20?\x20AND\x20?','info','Run\x20Query:','child_process','fork','../../components/export/','../../files/reports','savename','COUNT(*)','QueryTypes','run','debug','Limited\x20Query:','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','dbH','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','get','CustomReports','UserProfileResource','error','stack','name','index','AnalyticCustomReport','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','sort','pick','filter','where','merge','map','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Reports','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','preview','join','left_join','cross_join','SUM(%s)','COUNT(%s)','MAX(%s)','MIN(%s)','AVG(%s)','GROUP_CONCAT(%s)','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','HOUR(%s)','ROUND(%s)','includes'];(function(_0x4771d9,_0x16e00b){var _0x42e8eb=function(_0x579242){while(--_0x579242){_0x4771d9['push'](_0x4771d9['shift']());}};_0x42e8eb(++_0x16e00b);}(_0x415c,0x197));var _0xc415=function(_0x2e7daa,_0x5a764b){_0x2e7daa=_0x2e7daa-0x0;var _0x3b1036=_0x415c[_0x2e7daa];return _0x3b1036;};'use strict';var emlformat=require(_0xc415('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xc415('0x1'));var jsonpatch=require(_0xc415('0x2'));var rp=require(_0xc415('0x3'));var moment=require(_0xc415('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xc415('0x5'));var util=require(_0xc415('0x6'));var path=require(_0xc415('0x7'));var sox=require(_0xc415('0x8'));var csv=require('to-csv');var ejs=require(_0xc415('0x9'));var fs=require('fs');var fs_extra=require(_0xc415('0xa'));var _=require(_0xc415('0xb'));var squel=require(_0xc415('0xc'));var crypto=require('crypto');var jsforce=require(_0xc415('0xd'));var deskjs=require(_0xc415('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xc415('0xf'));var Redis=require(_0xc415('0x10'));var authService=require(_0xc415('0x11'));var qs=require(_0xc415('0x12'));var as=require(_0xc415('0x13'));var hardwareService=require(_0xc415('0x14'));var logger=require(_0xc415('0x15'))(_0xc415('0x16'));var utils=require('../../config/utils');var config=require(_0xc415('0x17'));var licenseUtil=require(_0xc415('0x18'));var db=require(_0xc415('0x19'))['db'];var dbH=require('../../mysqldb')[_0xc415('0x1a')];function respondWithStatusCode(_0x35b1f5,_0x5a865e){_0x5a865e=_0x5a865e||0xcc;return function(_0x53efb0){if(_0x53efb0){return _0x35b1f5[_0xc415('0x1b')](_0x5a865e);}return _0x35b1f5[_0xc415('0x1c')](_0x5a865e)[_0xc415('0x1d')]();};}function respondWithResult(_0x2bac1,_0x3fbac5){_0x3fbac5=_0x3fbac5||0xc8;return function(_0x212ef1){if(_0x212ef1){return _0x2bac1['status'](_0x3fbac5)[_0xc415('0x1e')](_0x212ef1);}};}function respondWithFilteredResult(_0x343c0d,_0x3ed8c9){return function(_0x46f942){if(_0x46f942){var _0x1cc047=typeof _0x3ed8c9[_0xc415('0x1f')]===_0xc415('0x20')&&typeof _0x3ed8c9[_0xc415('0x21')]===_0xc415('0x20');var _0x298895=_0x46f942[_0xc415('0x22')];var _0x491c86=_0x1cc047?0x0:_0x3ed8c9[_0xc415('0x1f')];var _0x356e9e=_0x1cc047?_0x46f942['count']:_0x3ed8c9[_0xc415('0x1f')]+_0x3ed8c9['limit'];var _0x4e1119;if(_0x356e9e>=_0x298895){_0x356e9e=_0x298895;_0x4e1119=0xc8;}else{_0x4e1119=0xce;}_0x343c0d[_0xc415('0x1c')](_0x4e1119);return _0x343c0d[_0xc415('0x23')](_0xc415('0x24'),_0x491c86+'-'+_0x356e9e+'/'+_0x298895)[_0xc415('0x1e')](_0x46f942);}return null;};}function patchUpdates(_0x9eeb08){return function(_0x3b5881){try{jsonpatch['apply'](_0x3b5881,_0x9eeb08,!![]);}catch(_0x3f3797){return BPromise[_0xc415('0x25')](_0x3f3797);}return _0x3b5881[_0xc415('0x26')]();};}function saveUpdates(_0x11a99e,_0x41783e){return function(_0x2ddb4b){if(_0x2ddb4b){return _0x2ddb4b[_0xc415('0x27')](_0x11a99e)[_0xc415('0x28')](function(_0x4fcb10){return _0x4fcb10;});}return null;};}function removeEntity(_0x1b87b1,_0x5b2986){return function(_0x48a46d){if(_0x48a46d){return _0x48a46d[_0xc415('0x29')]()[_0xc415('0x28')](function(){var _0x281dd0=_0x48a46d[_0xc415('0x2a')]({'plain':!![]});var _0x4b5841=_0xc415('0x2b');return db[_0xc415('0x2c')][_0xc415('0x29')]({'where':{'type':_0x4b5841,'resourceId':_0x281dd0['id']}})[_0xc415('0x28')](function(){return _0x48a46d;});})['then'](function(){_0x1b87b1[_0xc415('0x1c')](0xcc)[_0xc415('0x1d')]();});}};}function handleEntityNotFound(_0x4e6718,_0x508730){return function(_0x54229f){if(!_0x54229f){_0x4e6718[_0xc415('0x1b')](0x194);}return _0x54229f;};}function handleError(_0x21462b,_0x5d5e5d){_0x5d5e5d=_0x5d5e5d||0x1f4;return function(_0x2d8ef7){logger[_0xc415('0x2d')](_0x2d8ef7[_0xc415('0x2e')]);if(_0x2d8ef7['name']){delete _0x2d8ef7[_0xc415('0x2f')];}_0x21462b['status'](_0x5d5e5d)['send'](_0x2d8ef7);};}exports[_0xc415('0x30')]=function(_0x15bcc3,_0x4d08c6){var _0x38ed36={},_0x1c036c={},_0x594739={'count':0x0,'rows':[]};var _0x10c39e=_['map'](db[_0xc415('0x31')][_0xc415('0x32')],function(_0x4c92c1){return{'name':_0x4c92c1[_0xc415('0x33')],'type':_0x4c92c1[_0xc415('0x34')][_0xc415('0x35')]};});_0x1c036c[_0xc415('0x36')]=_['map'](_0x10c39e,'name');_0x1c036c[_0xc415('0x37')]=_[_0xc415('0x38')](_0x15bcc3[_0xc415('0x37')]);_0x1c036c[_0xc415('0x39')]=_[_0xc415('0x3a')](_0x1c036c['model'],_0x1c036c[_0xc415('0x37')]);_0x38ed36[_0xc415('0x3b')]=_[_0xc415('0x3a')](_0x1c036c[_0xc415('0x36')],qs[_0xc415('0x3c')](_0x15bcc3['query']['fields']));_0x38ed36[_0xc415('0x3b')]=_0x38ed36[_0xc415('0x3b')][_0xc415('0x3d')]?_0x38ed36[_0xc415('0x3b')]:_0x1c036c[_0xc415('0x36')];if(!_0x15bcc3[_0xc415('0x37')][_0xc415('0x3e')]('nolimit')){_0x38ed36[_0xc415('0x21')]=qs[_0xc415('0x21')](_0x15bcc3[_0xc415('0x37')][_0xc415('0x21')]);_0x38ed36['offset']=qs[_0xc415('0x1f')](_0x15bcc3[_0xc415('0x37')][_0xc415('0x1f')]);}_0x38ed36['order']=qs['sort'](_0x15bcc3[_0xc415('0x37')][_0xc415('0x3f')]);_0x38ed36['where']=qs[_0xc415('0x39')](_[_0xc415('0x40')](_0x15bcc3['query'],_0x1c036c['filters']),_0x10c39e);if(_0x15bcc3[_0xc415('0x37')][_0xc415('0x41')]){_0x38ed36[_0xc415('0x42')]=_[_0xc415('0x43')](_0x38ed36[_0xc415('0x42')],{'$or':_[_0xc415('0x44')](_0x10c39e,function(_0x2d3596){if(_0x2d3596[_0xc415('0x34')]!==_0xc415('0x45')){var _0x4c4ceb={};_0x4c4ceb[_0x2d3596[_0xc415('0x2f')]]={'$like':'%'+_0x15bcc3[_0xc415('0x37')][_0xc415('0x41')]+'%'};return _0x4c4ceb;}})});}_0x38ed36=_[_0xc415('0x43')]({},_0x38ed36,_0x15bcc3[_0xc415('0x46')]);var _0x31a103={'where':_0x38ed36[_0xc415('0x42')]};return db[_0xc415('0x31')]['count'](_0x31a103)[_0xc415('0x28')](function(_0x3f89c1){_0x594739['count']=_0x3f89c1;if(_0x15bcc3[_0xc415('0x37')][_0xc415('0x47')]){_0x38ed36[_0xc415('0x48')]=[{'all':!![]}];}return db[_0xc415('0x31')][_0xc415('0x49')](_0x38ed36);})[_0xc415('0x28')](function(_0x5495c6){_0x594739[_0xc415('0x4a')]=_0x5495c6;return _0x594739;})[_0xc415('0x28')](respondWithFilteredResult(_0x4d08c6,_0x38ed36))[_0xc415('0x4b')](handleError(_0x4d08c6,null));};exports[_0xc415('0x4c')]=function(_0x5a22eb,_0x10eea0){var _0x31026b={'raw':![],'where':{'id':_0x5a22eb['params']['id']}},_0x2399a5={};_0x2399a5['model']=_[_0xc415('0x38')](db[_0xc415('0x31')][_0xc415('0x32')]);_0x2399a5['query']=_[_0xc415('0x38')](_0x5a22eb[_0xc415('0x37')]);_0x2399a5[_0xc415('0x39')]=_[_0xc415('0x3a')](_0x2399a5[_0xc415('0x36')],_0x2399a5['query']);_0x31026b[_0xc415('0x3b')]=_[_0xc415('0x3a')](_0x2399a5[_0xc415('0x36')],qs['fields'](_0x5a22eb[_0xc415('0x37')]['fields']));_0x31026b[_0xc415('0x3b')]=_0x31026b[_0xc415('0x3b')][_0xc415('0x3d')]?_0x31026b['attributes']:_0x2399a5['model'];if(_0x5a22eb[_0xc415('0x37')][_0xc415('0x47')]){_0x31026b[_0xc415('0x48')]=[{'all':!![]}];}_0x31026b=_[_0xc415('0x43')]({},_0x31026b,_0x5a22eb[_0xc415('0x46')]);return db['AnalyticCustomReport'][_0xc415('0x4d')](_0x31026b)['then'](handleEntityNotFound(_0x10eea0,null))[_0xc415('0x28')](respondWithResult(_0x10eea0,null))[_0xc415('0x4b')](handleError(_0x10eea0,null));};exports[_0xc415('0x4e')]=function(_0x46eb14,_0xb12861){return db[_0xc415('0x31')][_0xc415('0x4e')](_0x46eb14[_0xc415('0x4f')],{})[_0xc415('0x28')](function(_0xd2b1d5){var _0x31ee2a=_0x46eb14[_0xc415('0x50')]['get']({'plain':!![]});if(!_0x31ee2a)throw new Error(_0xc415('0x51'));if(_0x31ee2a[_0xc415('0x52')]===_0xc415('0x50')){var _0x4381ac=_0xd2b1d5[_0xc415('0x2a')]({'plain':!![]});var _0x355293=_0xc415('0x53');return db[_0xc415('0x54')][_0xc415('0x4d')]({'where':{'name':_0x355293,'userProfileId':_0x31ee2a['userProfileId']},'raw':!![]})[_0xc415('0x28')](function(_0x3f89d5){if(_0x3f89d5&&_0x3f89d5['autoAssociation']===0x0){return db['UserProfileResource'][_0xc415('0x4e')]({'name':_0x4381ac[_0xc415('0x2f')],'resourceId':_0x4381ac['id'],'type':'CustomReports','sectionId':_0x3f89d5['id']},{})[_0xc415('0x28')](function(){return _0xd2b1d5;});}else{return _0xd2b1d5;}})[_0xc415('0x4b')](function(_0x58a21f){logger['error'](_0xc415('0x55'),_0x58a21f);throw _0x58a21f;});}return _0xd2b1d5;})[_0xc415('0x28')](respondWithResult(_0xb12861,0xc9))[_0xc415('0x4b')](handleError(_0xb12861,null));};exports[_0xc415('0x27')]=function(_0x35d54d,_0x33adca){if(_0x35d54d[_0xc415('0x4f')]['id']){delete _0x35d54d[_0xc415('0x4f')]['id'];}return db[_0xc415('0x31')][_0xc415('0x4d')]({'where':{'id':_0x35d54d['params']['id']}})[_0xc415('0x28')](handleEntityNotFound(_0x33adca,null))[_0xc415('0x28')](saveUpdates(_0x35d54d[_0xc415('0x4f')],null))['then'](respondWithResult(_0x33adca,null))[_0xc415('0x4b')](handleError(_0x33adca,null));};exports[_0xc415('0x29')]=function(_0xeee817,_0xa2e50){return db[_0xc415('0x31')][_0xc415('0x4d')]({'where':{'id':_0xeee817['params']['id']}})[_0xc415('0x28')](handleEntityNotFound(_0xa2e50,null))[_0xc415('0x28')](removeEntity(_0xa2e50,null))[_0xc415('0x4b')](handleError(_0xa2e50,null));};exports[_0xc415('0x56')]=function(_0x2c1de3,_0x1da3d6){var _0x2ca646=0xa;var _0x75fe0e=[_0xc415('0x57'),_0xc415('0x58'),'right_join',_0xc415('0x59')];var _0x4bb740={'SUM':_0xc415('0x5a'),'COUNT':_0xc415('0x5b'),'COUNT DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0xc415('0x5c'),'MIN':_0xc415('0x5d'),'AVG':_0xc415('0x5e'),'GROUP_CONCAT':_0xc415('0x5f'),'GROUP_CONCAT ASC':_0xc415('0x60'),'GROUP_CONCAT DESC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)'};var _0x8c70ac={'SEC_TO_TIME':'SEC_TO_TIME(%s)','DATE':'DATE(%s)','HOUR':_0xc415('0x61'),'ROUND':_0xc415('0x62'),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'};var _0x3bb4b2=function(_0x1dcd63){return!_[_0xc415('0x63')]([_0xc415('0x64'),'IS\x20NOT\x20NULL',_0xc415('0x65'),_0xc415('0x66')],_0x1dcd63);};var _0x274b63=function(_0xfdb3bb){if(!_0xfdb3bb||!_0xfdb3bb[_0xc415('0x67')][_0xc415('0x3d')]){return'';}for(var _0x1b17b0='(',_0x1e7117=0x0;_0x1e7117<_0xfdb3bb[_0xc415('0x67')][_0xc415('0x3d')];_0x1e7117+=0x1){_0x1e7117>0x0&&(_0x1b17b0+='\x20'+_0xfdb3bb[_0xc415('0x68')]+'\x20');_0x1b17b0+=_0xfdb3bb['rules'][_0x1e7117][_0xc415('0x69')]?_0x274b63(_0xfdb3bb[_0xc415('0x67')][_0x1e7117][_0xc415('0x69')]):_0xfdb3bb[_0xc415('0x67')][_0x1e7117]['field']+'\x20'+_0xfdb3bb[_0xc415('0x67')][_0x1e7117][_0xc415('0x6a')]+(_0x3bb4b2(_0xfdb3bb[_0xc415('0x67')][_0x1e7117]['condition'])?'\x20'+_0xfdb3bb[_0xc415('0x67')][_0x1e7117]['value']:'');}return _0x1b17b0+')';};var _0x4b7f0b={'where':{'id':_0x2c1de3[_0xc415('0x6b')]['id']}},_0x400d07,_0x2e9914,_0xcb8288,_0x118580,_0x4e879e;_0x4b7f0b=_[_0xc415('0x43')]({},_0x4b7f0b,_0x2c1de3[_0xc415('0x46')]);return db[_0xc415('0x31')]['find'](_0x4b7f0b)[_0xc415('0x28')](function(_0xc184a6){if(_0xc184a6){_0x400d07=_0xc184a6;return _0xc184a6[_0xc415('0x6c')]();}return null;})[_0xc415('0x28')](function(_0x505108){if(_0x505108){if(!_0x505108[_0xc415('0x3d')]){throw new db[(_0xc415('0x6d'))][(_0xc415('0x6e'))](_0xc415('0x6f'),0x193);}_0x2e9914=_0x505108;return db[_0xc415('0x70')][_0xc415('0x49')]({'raw':!![]});}return null;})[_0xc415('0x28')](function(_0x298e12){if(_0x298e12){_0xcb8288=_[_0xc415('0x71')](_0x298e12,'id');var _0x14171c;var _0x593ab2=squel[_0xc415('0x72')]();_0x593ab2[_0xc415('0x73')](_0x400d07[_0xc415('0x74')]);for(var _0x4fb9b0=0x0;_0x4fb9b0<_0x2e9914['length'];_0x4fb9b0+=0x1){_0x14171c=_0x2e9914[_0x4fb9b0][_0xc415('0x75')]?_0xcb8288[_0x2e9914[_0x4fb9b0][_0xc415('0x75')]]['metric']:_0x2e9914[_0x4fb9b0][_0xc415('0x76')];_0x14171c=_0x2e9914[_0x4fb9b0][_0xc415('0x77')]?_[_0xc415('0x78')](_0x4bb740[_0x2e9914[_0x4fb9b0][_0xc415('0x77')]],'%s',_0x14171c):_0x14171c;_0x14171c=_0x2e9914[_0x4fb9b0][_0xc415('0x79')]?_[_0xc415('0x78')](_0x8c70ac[_0x2e9914[_0x4fb9b0][_0xc415('0x79')]],'%s',_0x14171c):_0x14171c;if(_0x2e9914[_0x4fb9b0][_0xc415('0x7a')]){_0x593ab2[_0xc415('0x69')](_0x14171c);}_0x2e9914[_0x4fb9b0][_0xc415('0x7b')]&&_0x593ab2[_0xc415('0x7c')](_0x14171c,_0x2e9914[_0x4fb9b0]['orderBy']==='DESC'?![]:!![]);_0x593ab2[_0xc415('0x76')](_0x14171c,_0x2e9914[_0x4fb9b0]['alias']||_0x14171c);}if(_0x400d07['joins']){_0x400d07[_0xc415('0x7d')]=JSON[_0xc415('0x7e')](_0x400d07[_0xc415('0x7d')]);for(var _0x585fbc=0x0;_0x585fbc<_0x400d07[_0xc415('0x7d')][_0xc415('0x3d')];_0x585fbc+=0x1){if(_0x400d07['joins'][_0x585fbc]['type']&&_[_0xc415('0x63')](_0x75fe0e,_0x400d07['joins'][_0x585fbc][_0xc415('0x34')])&&_0x400d07[_0xc415('0x7d')][_0x585fbc]['parentKey']&&_0x400d07[_0xc415('0x7d')][_0x585fbc][_0xc415('0x7f')]&&_0x400d07[_0xc415('0x7d')][_0x585fbc][_0xc415('0x80')]){_0x593ab2[_0x400d07[_0xc415('0x7d')][_0x585fbc][_0xc415('0x34')]](_0x400d07[_0xc415('0x7d')][_0x585fbc][_0xc415('0x7f')],null,util[_0xc415('0x79')](_0xc415('0x81'),_0x400d07[_0xc415('0x74')],_0x400d07[_0xc415('0x7d')][_0x585fbc][_0xc415('0x82')],_0x400d07['joins'][_0x585fbc]['foreignTable'],_0x400d07[_0xc415('0x7d')][_0x585fbc]['foreignKey']));}}}if(_0x400d07[_0xc415('0x83')]){_0x400d07['conditions']=JSON['parse'](_0x400d07[_0xc415('0x83')]);_0x593ab2[_0xc415('0x42')](_0x274b63(_0x400d07[_0xc415('0x83')][_0xc415('0x69')]));}_0x4e879e=_0x593ab2['clone']();_0x593ab2[_0xc415('0x21')](_0x2ca646);_0x593ab2[_0xc415('0x1f')](0x0);logger['debug']('Limited\x20Query:',_0x593ab2['toString']());return dbH[_0xc415('0x84')][_0xc415('0x37')](_0x593ab2[_0xc415('0x85')](),{'type':dbH['sequelize']['QueryTypes'][_0xc415('0x86')]});}})['then'](respondWithResult(_0x1da3d6,null))[_0xc415('0x4b')](handleError(_0x1da3d6,null));};function runReport(_0x32f39c,_0x4bdf5e,_0x2679c4){var _0x230459=_0x4bdf5e[_0xc415('0x2f')];var _0x519452=0xa;var _0x1ec2b3=[_0xc415('0x57'),_0xc415('0x58'),_0xc415('0x87'),'cross_join'];var _0x23d998={'SUM':_0xc415('0x5a'),'COUNT':'COUNT(%s)','COUNT DISTINCT':_0xc415('0x88'),'MAX':_0xc415('0x5c'),'MIN':_0xc415('0x5d'),'AVG':_0xc415('0x5e'),'GROUP_CONCAT':_0xc415('0x5f'),'GROUP_CONCAT ASC':_0xc415('0x60'),'GROUP_CONCAT DESC':_0xc415('0x89')};var _0x400e0f={'SEC_TO_TIME':_0xc415('0x8a'),'DATE':_0xc415('0x8b'),'HOUR':'HOUR(%s)','ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0xc415('0x8c')};var _0x3a3827=function(_0x49fb39){return!_[_0xc415('0x63')]([_0xc415('0x64'),_0xc415('0x8d'),'IS\x20EMPTY',_0xc415('0x66')],_0x49fb39);};var _0x1736db=function(_0xd23fbf){if(!_0xd23fbf||!_0xd23fbf[_0xc415('0x67')][_0xc415('0x3d')]){return'';}for(var _0x56076b='(',_0x3643c1=0x0;_0x3643c1<_0xd23fbf[_0xc415('0x67')][_0xc415('0x3d')];_0x3643c1+=0x1){_0x3643c1>0x0&&(_0x56076b+='\x20'+_0xd23fbf[_0xc415('0x68')]+'\x20');_0x56076b+=_0xd23fbf[_0xc415('0x67')][_0x3643c1]['group']?_0x1736db(_0xd23fbf[_0xc415('0x67')][_0x3643c1][_0xc415('0x69')]):_0xd23fbf[_0xc415('0x67')][_0x3643c1]['field']+'\x20'+_0xd23fbf['rules'][_0x3643c1][_0xc415('0x6a')]+(_0x3a3827(_0xd23fbf[_0xc415('0x67')][_0x3643c1][_0xc415('0x6a')])?'\x20'+_0xd23fbf[_0xc415('0x67')][_0x3643c1][_0xc415('0x8e')]:'');}return _0x56076b+')';};var _0x205abd={'where':{'id':_0x32f39c['id']}},_0x3b3fca,_0x20aa71,_0x41498e,_0x460c73,_0x3a0fc2;_0x205abd=_[_0xc415('0x43')]({},_0x205abd,_0x2679c4);return db[_0xc415('0x31')][_0xc415('0x4d')](_0x205abd)['then'](function(_0x37a23e){if(_0x37a23e){_0x3b3fca=_0x37a23e;return _0x37a23e[_0xc415('0x6c')]();}return null;})[_0xc415('0x28')](function(_0x15f097){if(_0x15f097){if(!_0x15f097['length']){throw new db[(_0xc415('0x6d'))][(_0xc415('0x6e'))](_0xc415('0x6f'),0x193);}_0x20aa71=_0x15f097;return db['AnalyticMetric']['findAll']({'raw':!![]});}return null;})[_0xc415('0x28')](function(_0x58e2c7){if(_0x58e2c7){_0x41498e=_[_0xc415('0x71')](_0x58e2c7,'id');var _0x1485ed;var _0x67710e=squel[_0xc415('0x72')]();_0x67710e['from'](_0x3b3fca[_0xc415('0x74')]);for(var _0x542a3f=0x0;_0x542a3f<_0x20aa71[_0xc415('0x3d')];_0x542a3f+=0x1){_0x1485ed=_0x20aa71[_0x542a3f][_0xc415('0x75')]?_0x41498e[_0x20aa71[_0x542a3f][_0xc415('0x75')]][_0xc415('0x8f')]:_0x20aa71[_0x542a3f][_0xc415('0x76')];_0x1485ed=_0x20aa71[_0x542a3f]['function']?_[_0xc415('0x78')](_0x23d998[_0x20aa71[_0x542a3f][_0xc415('0x77')]],'%s',_0x1485ed):_0x1485ed;_0x1485ed=_0x20aa71[_0x542a3f][_0xc415('0x79')]?_[_0xc415('0x78')](_0x400e0f[_0x20aa71[_0x542a3f][_0xc415('0x79')]],'%s',_0x1485ed):_0x1485ed;if(_0x20aa71[_0x542a3f][_0xc415('0x7a')]){_0x67710e[_0xc415('0x69')](_0x1485ed);}_0x20aa71[_0x542a3f][_0xc415('0x7b')]&&_0x67710e[_0xc415('0x7c')](_0x1485ed,_0x20aa71[_0x542a3f]['orderBy']===_0xc415('0x90')?![]:!![]);_0x67710e[_0xc415('0x76')](_0x1485ed,_0x20aa71[_0x542a3f][_0xc415('0x91')]||_0x1485ed);}if(_0x3b3fca[_0xc415('0x7d')]){_0x3b3fca['joins']=JSON[_0xc415('0x7e')](_0x3b3fca['joins']);for(var _0x65b61c=0x0;_0x65b61c<_0x3b3fca[_0xc415('0x7d')][_0xc415('0x3d')];_0x65b61c+=0x1){if(_0x3b3fca['joins'][_0x65b61c][_0xc415('0x34')]&&_[_0xc415('0x63')](_0x1ec2b3,_0x3b3fca['joins'][_0x65b61c][_0xc415('0x34')])&&_0x3b3fca['joins'][_0x65b61c][_0xc415('0x82')]&&_0x3b3fca['joins'][_0x65b61c][_0xc415('0x7f')]&&_0x3b3fca[_0xc415('0x7d')][_0x65b61c]['foreignKey']){_0x67710e[_0x3b3fca[_0xc415('0x7d')][_0x65b61c][_0xc415('0x34')]](_0x3b3fca['joins'][_0x65b61c]['foreignTable'],null,util[_0xc415('0x79')](_0xc415('0x81'),_0x3b3fca[_0xc415('0x74')],_0x3b3fca[_0xc415('0x7d')][_0x65b61c][_0xc415('0x82')],_0x3b3fca[_0xc415('0x7d')][_0x65b61c][_0xc415('0x7f')],_0x3b3fca[_0xc415('0x7d')][_0x65b61c][_0xc415('0x80')]));}}}if(_0x3b3fca['conditions']){_0x3b3fca[_0xc415('0x83')]=JSON[_0xc415('0x7e')](_0x3b3fca['conditions']);_0x67710e[_0xc415('0x42')](_0x1736db(_0x3b3fca[_0xc415('0x83')][_0xc415('0x69')]));}_0x3a0fc2=_0x67710e[_0xc415('0x92')]();_0x67710e[_0xc415('0x21')](_0x519452);_0x67710e[_0xc415('0x1f')](0x0);return;}})[_0xc415('0x28')](function(){if(_0x4bdf5e[_0xc415('0x93')]==='web'){return null;}var _0x155616=_['merge'](_0x4bdf5e,{'name':_0x4bdf5e['fullPath']||_0x4bdf5e[_0xc415('0x2f')]||_0x3b3fca[_0xc415('0x2f')],'basename':_0x230459,'savename':util[_0xc415('0x79')](_0xc415('0x94'),_0x4bdf5e[_0xc415('0x2f')]||_0x3b3fca[_0xc415('0x2f')],require(_0xc415('0x95'))[_0xc415('0x96')](0x4),_0x4bdf5e[_0xc415('0x93')]||'csv'),'reportId':_0x3b3fca['id'],'reportType':_0xc415('0x97')});return db[_0xc415('0x98')][_0xc415('0x4e')](_0x155616,{'raw':!![]});})[_0xc415('0x28')](function(_0x3d912b){if(_0x3b3fca['table']===_0xc415('0x99')){_0x3a0fc2[_0xc415('0x42')](_0x3b3fca['table']+_0xc415('0x9a'),_0x4bdf5e[_0xc415('0x9b')],_0x4bdf5e['endDate']);}else{_0x3a0fc2[_0xc415('0x42')](_0x3b3fca[_0xc415('0x74')]+_0xc415('0x9c'),_0x4bdf5e['startDate'],_0x4bdf5e['endDate']);}if(_0x3d912b){logger[_0xc415('0x9d')](_0xc415('0x9e'),_0x3a0fc2[_0xc415('0x85')]());require(_0xc415('0x9f'))[_0xc415('0xa0')](path['join'](__dirname,_0xc415('0xa1'),_0x3d912b['output']),[_0x3d912b['id'],_0x3a0fc2['toString'](),path[_0xc415('0x57')](__dirname,_0xc415('0xa2'),_0x3d912b[_0xc415('0xa3')]),_0x230459]);return _0x3d912b;}else{var _0x4e02a0=squel[_0xc415('0x72')]();_0x4e02a0[_0xc415('0x73')]('('+_0x3a0fc2['toString']()+')','countTable');_0x4e02a0[_0xc415('0x76')](_0xc415('0xa4'),_0xc415('0x22'));_0x3a0fc2[_0xc415('0x21')](_0x4bdf5e[_0xc415('0x21')]||_0x519452);_0x3a0fc2[_0xc415('0x1f')](_0x4bdf5e['offset']||0x0);return dbH[_0xc415('0x84')]['query'](_0x4e02a0[_0xc415('0x85')](),{'type':dbH[_0xc415('0x84')][_0xc415('0xa5')]['SELECT']})[_0xc415('0x28')](function(_0x251692){if(!_0x251692[_0xc415('0x3d')]){_0x460c73=0x0;}else{_0x460c73=_0x251692[0x0][_0xc415('0x22')]||0x0;}return dbH[_0xc415('0x84')]['query'](_0x3a0fc2['toString'](),{'type':dbH[_0xc415('0x84')]['QueryTypes'][_0xc415('0x86')]});})[_0xc415('0x28')](function(_0x31e5ce){return{'rows':_0x31e5ce||[],'count':_0x460c73};});}});}exports[_0xc415('0xa6')]=function(_0x24b94c,_0x1b1a85){return runReport(_0x24b94c[_0xc415('0x6b')],_0x24b94c[_0xc415('0x37')],_0x24b94c[_0xc415('0x46')])[_0xc415('0x28')](respondWithResult(_0x1b1a85,null))[_0xc415('0x4b')](handleError(_0x1b1a85,null));};exports['runReport']=runReport;exports[_0xc415('0x37')]=function(_0x1241dc,_0x9d3a24){var _0x477ba8=0xa;var _0x31ecd4=['join',_0xc415('0x58'),'right_join',_0xc415('0x59')];var _0x67c171={'SUM':'SUM(%s)','COUNT':_0xc415('0x5b'),'COUNT DISTINCT':_0xc415('0x88'),'MAX':_0xc415('0x5c'),'MIN':_0xc415('0x5d'),'AVG':_0xc415('0x5e'),'GROUP_CONCAT':_0xc415('0x5f'),'GROUP_CONCAT ASC':_0xc415('0x60'),'GROUP_CONCAT DESC':_0xc415('0x89')};var _0x27e582={'SEC_TO_TIME':_0xc415('0x8a'),'DATE':'DATE(%s)','HOUR':_0xc415('0x61'),'ROUND':_0xc415('0x62'),'UNIX_TIMESTAMP':_0xc415('0x8c')};var _0x3966e5=function(_0x197d7f){return!_[_0xc415('0x63')]([_0xc415('0x64'),_0xc415('0x8d'),_0xc415('0x65'),_0xc415('0x66')],_0x197d7f);};var _0x55db7c=function(_0x22a1ab){if(!_0x22a1ab||!_0x22a1ab[_0xc415('0x67')][_0xc415('0x3d')]){return'';}for(var _0x4da32c='(',_0x427319=0x0;_0x427319<_0x22a1ab[_0xc415('0x67')]['length'];_0x427319+=0x1){_0x427319>0x0&&(_0x4da32c+='\x20'+_0x22a1ab[_0xc415('0x68')]+'\x20');_0x4da32c+=_0x22a1ab[_0xc415('0x67')][_0x427319][_0xc415('0x69')]?_0x55db7c(_0x22a1ab[_0xc415('0x67')][_0x427319][_0xc415('0x69')]):_0x22a1ab[_0xc415('0x67')][_0x427319][_0xc415('0x76')]+'\x20'+_0x22a1ab[_0xc415('0x67')][_0x427319][_0xc415('0x6a')]+(_0x3966e5(_0x22a1ab[_0xc415('0x67')][_0x427319]['condition'])?'\x20'+_0x22a1ab[_0xc415('0x67')][_0x427319][_0xc415('0x8e')]:'');}return _0x4da32c+')';};var _0x4cfc66={'where':{'id':_0x1241dc['params']['id']}},_0x486734,_0x4d3af7,_0x3198eb,_0x27322d,_0x265d20;_0x4cfc66=_[_0xc415('0x43')]({},_0x4cfc66,_0x1241dc[_0xc415('0x46')]);return db[_0xc415('0x31')][_0xc415('0x4d')](_0x4cfc66)['then'](function(_0x186dca){if(_0x186dca){_0x486734=_0x186dca;return _0x186dca[_0xc415('0x6c')]();}return null;})[_0xc415('0x28')](function(_0x1e091f){if(_0x1e091f){if(!_0x1e091f['length']){throw new db[(_0xc415('0x6d'))][(_0xc415('0x6e'))](_0xc415('0x6f'),0x193);}_0x4d3af7=_0x1e091f;return db['AnalyticMetric'][_0xc415('0x49')]({'raw':!![]});}return null;})[_0xc415('0x28')](function(_0x4e5430){if(_0x4e5430){_0x3198eb=_['keyBy'](_0x4e5430,'id');var _0x2cea62;var _0x12f11c=squel['select']();_0x12f11c[_0xc415('0x73')](_0x486734[_0xc415('0x74')]);for(var _0x4b262f=0x0;_0x4b262f<_0x4d3af7['length'];_0x4b262f+=0x1){_0x2cea62=_0x4d3af7[_0x4b262f][_0xc415('0x75')]?_0x3198eb[_0x4d3af7[_0x4b262f][_0xc415('0x75')]][_0xc415('0x8f')]:_0x4d3af7[_0x4b262f][_0xc415('0x76')];_0x2cea62=_0x4d3af7[_0x4b262f][_0xc415('0x77')]?_[_0xc415('0x78')](_0x67c171[_0x4d3af7[_0x4b262f]['function']],'%s',_0x2cea62):_0x2cea62;_0x2cea62=_0x4d3af7[_0x4b262f]['format']?_[_0xc415('0x78')](_0x27e582[_0x4d3af7[_0x4b262f][_0xc415('0x79')]],'%s',_0x2cea62):_0x2cea62;if(_0x4d3af7[_0x4b262f][_0xc415('0x7a')]){_0x12f11c[_0xc415('0x69')](_0x2cea62);}_0x4d3af7[_0x4b262f][_0xc415('0x7b')]&&_0x12f11c[_0xc415('0x7c')](_0x2cea62,_0x4d3af7[_0x4b262f][_0xc415('0x7b')]===_0xc415('0x90')?![]:!![]);_0x12f11c[_0xc415('0x76')](_0x2cea62,_0x4d3af7[_0x4b262f][_0xc415('0x91')]||_0x2cea62);}if(_0x486734[_0xc415('0x7d')]){_0x486734[_0xc415('0x7d')]=JSON[_0xc415('0x7e')](_0x486734[_0xc415('0x7d')]);for(var _0x26f212=0x0;_0x26f212<_0x486734[_0xc415('0x7d')]['length'];_0x26f212+=0x1){if(_0x486734[_0xc415('0x7d')][_0x26f212][_0xc415('0x34')]&&_[_0xc415('0x63')](_0x31ecd4,_0x486734[_0xc415('0x7d')][_0x26f212]['type'])&&_0x486734[_0xc415('0x7d')][_0x26f212][_0xc415('0x82')]&&_0x486734['joins'][_0x26f212][_0xc415('0x7f')]&&_0x486734[_0xc415('0x7d')][_0x26f212][_0xc415('0x80')]){_0x12f11c[_0x486734[_0xc415('0x7d')][_0x26f212]['type']](_0x486734[_0xc415('0x7d')][_0x26f212]['foreignTable'],null,util['format'](_0xc415('0x81'),_0x486734['table'],_0x486734[_0xc415('0x7d')][_0x26f212][_0xc415('0x82')],_0x486734[_0xc415('0x7d')][_0x26f212][_0xc415('0x7f')],_0x486734[_0xc415('0x7d')][_0x26f212]['foreignKey']));}}}if(_0x486734[_0xc415('0x83')]){_0x486734[_0xc415('0x83')]=JSON[_0xc415('0x7e')](_0x486734['conditions']);_0x12f11c[_0xc415('0x42')](_0x55db7c(_0x486734['conditions']['group']));}_0x265d20=_0x12f11c[_0xc415('0x92')]();_0x12f11c[_0xc415('0x21')](_0x477ba8);_0x12f11c['offset'](0x0);logger[_0xc415('0xa7')](_0xc415('0xa8'),_0x12f11c[_0xc415('0x85')]());return dbH['sequelize'][_0xc415('0x37')](_0x12f11c[_0xc415('0x85')](),{'type':dbH[_0xc415('0x84')]['QueryTypes'][_0xc415('0x86')]});}})[_0xc415('0x28')](function(){return{'sql':_0x265d20[_0xc415('0x85')]()};})[_0xc415('0x28')](respondWithResult(_0x9d3a24,null))['catch'](handleError(_0x9d3a24,null));};
\ No newline at end of file