Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / analyticExtractedReport / analyticExtractedReport.controller.js
index ca00a68..811c888 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xed67=['offset','undefined','limit','count','Content-Range','apply','reject','then','get','destroy','stack','name','index','map','AnalyticExtractedReport','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','hasOwnProperty','sort','where','pick','merge','VIRTUAL','filter','includeAll','include','findAll','rows','catch','show','params','length','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','download','output','existsSync','root','server/files/reports','savename','ValidationError','Report\x20not\x20found\x20or\x20empty','exists','join','format','%s.%s','basename','toLowerCase','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','path','sox','to-csv','ejs','fs-extra','lodash','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','end','json'];(function(_0x3b2370,_0x3add2e){var _0xf8a798=function(_0x37bcf5){while(--_0x37bcf5){_0x3b2370['push'](_0x3b2370['shift']());}};_0xf8a798(++_0x3add2e);}(_0xed67,0x9f));var _0x7ed6=function(_0x1bc013,_0x7771c6){_0x1bc013=_0x1bc013-0x0;var _0x55df36=_0xed67[_0x1bc013];return _0x55df36;};'use strict';var emlformat=require(_0x7ed6('0x0'));var rimraf=require(_0x7ed6('0x1'));var zipdir=require(_0x7ed6('0x2'));var jsonpatch=require(_0x7ed6('0x3'));var rp=require('request-promise');var moment=require(_0x7ed6('0x4'));var BPromise=require(_0x7ed6('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x7ed6('0x6'));var sox=require(_0x7ed6('0x7'));var csv=require(_0x7ed6('0x8'));var ejs=require(_0x7ed6('0x9'));var fs=require('fs');var fs_extra=require(_0x7ed6('0xa'));var _=require(_0x7ed6('0xb'));var squel=require('squel');var crypto=require(_0x7ed6('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x7ed6('0xd'));var toCsv=require(_0x7ed6('0x8'));var querystring=require(_0x7ed6('0xe'));var Papa=require(_0x7ed6('0xf'));var Redis=require('ioredis');var authService=require(_0x7ed6('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x7ed6('0x11'));var hardwareService=require(_0x7ed6('0x12'));var logger=require(_0x7ed6('0x13'))(_0x7ed6('0x14'));var utils=require('../../config/utils');var config=require(_0x7ed6('0x15'));var licenseUtil=require(_0x7ed6('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4da7e9,_0x9825a1){_0x9825a1=_0x9825a1||0xcc;return function(_0x6ca96b){if(_0x6ca96b){return _0x4da7e9[_0x7ed6('0x17')](_0x9825a1);}return _0x4da7e9[_0x7ed6('0x18')](_0x9825a1)[_0x7ed6('0x19')]();};}function respondWithResult(_0x53bc02,_0x4235f3){_0x4235f3=_0x4235f3||0xc8;return function(_0x501a77){if(_0x501a77){return _0x53bc02[_0x7ed6('0x18')](_0x4235f3)[_0x7ed6('0x1a')](_0x501a77);}};}function respondWithFilteredResult(_0x7da8ec,_0xff699e){return function(_0xf14d5){if(_0xf14d5){var _0x509775=typeof _0xff699e[_0x7ed6('0x1b')]===_0x7ed6('0x1c')&&typeof _0xff699e[_0x7ed6('0x1d')]===_0x7ed6('0x1c');var _0x391230=_0xf14d5[_0x7ed6('0x1e')];var _0x36b774=_0x509775?0x0:_0xff699e[_0x7ed6('0x1b')];var _0x3f9b6e=_0x509775?_0xf14d5[_0x7ed6('0x1e')]:_0xff699e[_0x7ed6('0x1b')]+_0xff699e['limit'];var _0x229464;if(_0x3f9b6e>=_0x391230){_0x3f9b6e=_0x391230;_0x229464=0xc8;}else{_0x229464=0xce;}_0x7da8ec[_0x7ed6('0x18')](_0x229464);return _0x7da8ec['set'](_0x7ed6('0x1f'),_0x36b774+'-'+_0x3f9b6e+'/'+_0x391230)['json'](_0xf14d5);}return null;};}function patchUpdates(_0x3f09d5){return function(_0x534007){try{jsonpatch[_0x7ed6('0x20')](_0x534007,_0x3f09d5,!![]);}catch(_0x11015f){return BPromise[_0x7ed6('0x21')](_0x11015f);}return _0x534007['save']();};}function saveUpdates(_0x10f792,_0x4ef839){return function(_0x6ae4c6){if(_0x6ae4c6){return _0x6ae4c6['update'](_0x10f792)[_0x7ed6('0x22')](function(_0x338fe0){return _0x338fe0;});}return null;};}function removeEntity(_0x5ada38,_0x6d1ae7){return function(_0x5abc1b){if(_0x5abc1b){return _0x5abc1b['destroy']()[_0x7ed6('0x22')](function(){var _0x5d7d78=_0x5abc1b[_0x7ed6('0x23')]({'plain':!![]});var _0x49c264='ExtractedReports';return db['UserProfileResource'][_0x7ed6('0x24')]({'where':{'type':_0x49c264,'resourceId':_0x5d7d78['id']}})['then'](function(){return _0x5abc1b;});})[_0x7ed6('0x22')](function(){_0x5ada38[_0x7ed6('0x18')](0xcc)[_0x7ed6('0x19')]();});}};}function handleEntityNotFound(_0x4163a8,_0x32ef12){return function(_0x1a232){if(!_0x1a232){_0x4163a8['sendStatus'](0x194);}return _0x1a232;};}function handleError(_0x2f1d87,_0x105a12){_0x105a12=_0x105a12||0x1f4;return function(_0x442e92){logger['error'](_0x442e92[_0x7ed6('0x25')]);if(_0x442e92[_0x7ed6('0x26')]){delete _0x442e92['name'];}_0x2f1d87['status'](_0x105a12)['send'](_0x442e92);};}exports[_0x7ed6('0x27')]=function(_0x440f33,_0x2d4d82){var _0x1c99b7={},_0x58a008={},_0x3bec38={'count':0x0,'rows':[]};var _0x5dc7c9=_[_0x7ed6('0x28')](db[_0x7ed6('0x29')][_0x7ed6('0x2a')],function(_0x2a2816){return{'name':_0x2a2816[_0x7ed6('0x2b')],'type':_0x2a2816[_0x7ed6('0x2c')][_0x7ed6('0x2d')]};});_0x58a008[_0x7ed6('0x2e')]=_[_0x7ed6('0x28')](_0x5dc7c9,'name');_0x58a008['query']=_[_0x7ed6('0x2f')](_0x440f33[_0x7ed6('0x30')]);_0x58a008[_0x7ed6('0x31')]=_['intersection'](_0x58a008[_0x7ed6('0x2e')],_0x58a008[_0x7ed6('0x30')]);_0x1c99b7[_0x7ed6('0x32')]=_[_0x7ed6('0x33')](_0x58a008[_0x7ed6('0x2e')],qs[_0x7ed6('0x34')](_0x440f33[_0x7ed6('0x30')][_0x7ed6('0x34')]));_0x1c99b7[_0x7ed6('0x32')]=_0x1c99b7[_0x7ed6('0x32')]['length']?_0x1c99b7[_0x7ed6('0x32')]:_0x58a008[_0x7ed6('0x2e')];if(!_0x440f33[_0x7ed6('0x30')][_0x7ed6('0x35')]('nolimit')){_0x1c99b7[_0x7ed6('0x1d')]=qs[_0x7ed6('0x1d')](_0x440f33[_0x7ed6('0x30')]['limit']);_0x1c99b7[_0x7ed6('0x1b')]=qs['offset'](_0x440f33[_0x7ed6('0x30')][_0x7ed6('0x1b')]);}_0x1c99b7['order']=qs[_0x7ed6('0x36')](_0x440f33[_0x7ed6('0x30')][_0x7ed6('0x36')]);_0x1c99b7[_0x7ed6('0x37')]=qs[_0x7ed6('0x31')](_[_0x7ed6('0x38')](_0x440f33[_0x7ed6('0x30')],_0x58a008[_0x7ed6('0x31')]),_0x5dc7c9);if(_0x440f33[_0x7ed6('0x30')]['filter']){_0x1c99b7['where']=_[_0x7ed6('0x39')](_0x1c99b7[_0x7ed6('0x37')],{'$or':_[_0x7ed6('0x28')](_0x5dc7c9,function(_0x2e2b7b){if(_0x2e2b7b[_0x7ed6('0x2c')]!==_0x7ed6('0x3a')){var _0x7c6725={};_0x7c6725[_0x2e2b7b[_0x7ed6('0x26')]]={'$like':'%'+_0x440f33['query'][_0x7ed6('0x3b')]+'%'};return _0x7c6725;}})});}_0x1c99b7=_[_0x7ed6('0x39')]({},_0x1c99b7,_0x440f33['options']);var _0x2d388f={'where':_0x1c99b7[_0x7ed6('0x37')]};return db['AnalyticExtractedReport'][_0x7ed6('0x1e')](_0x2d388f)[_0x7ed6('0x22')](function(_0x358355){_0x3bec38[_0x7ed6('0x1e')]=_0x358355;if(_0x440f33[_0x7ed6('0x30')][_0x7ed6('0x3c')]){_0x1c99b7[_0x7ed6('0x3d')]=[{'all':!![]}];}return db[_0x7ed6('0x29')][_0x7ed6('0x3e')](_0x1c99b7);})[_0x7ed6('0x22')](function(_0x4a5d35){_0x3bec38[_0x7ed6('0x3f')]=_0x4a5d35;return _0x3bec38;})[_0x7ed6('0x22')](respondWithFilteredResult(_0x2d4d82,_0x1c99b7))[_0x7ed6('0x40')](handleError(_0x2d4d82,null));};exports[_0x7ed6('0x41')]=function(_0x496f14,_0x253c43){var _0x3ee36b={'raw':!![],'where':{'id':_0x496f14[_0x7ed6('0x42')]['id']}},_0x354556={};_0x354556['model']=_[_0x7ed6('0x2f')](db[_0x7ed6('0x29')][_0x7ed6('0x2a')]);_0x354556[_0x7ed6('0x30')]=_['keys'](_0x496f14[_0x7ed6('0x30')]);_0x354556[_0x7ed6('0x31')]=_[_0x7ed6('0x33')](_0x354556[_0x7ed6('0x2e')],_0x354556[_0x7ed6('0x30')]);_0x3ee36b[_0x7ed6('0x32')]=_[_0x7ed6('0x33')](_0x354556['model'],qs['fields'](_0x496f14[_0x7ed6('0x30')][_0x7ed6('0x34')]));_0x3ee36b['attributes']=_0x3ee36b[_0x7ed6('0x32')][_0x7ed6('0x43')]?_0x3ee36b[_0x7ed6('0x32')]:_0x354556[_0x7ed6('0x2e')];if(_0x496f14[_0x7ed6('0x30')][_0x7ed6('0x3c')]){_0x3ee36b[_0x7ed6('0x3d')]=[{'all':!![]}];}_0x3ee36b=_[_0x7ed6('0x39')]({},_0x3ee36b,_0x496f14['options']);return db[_0x7ed6('0x29')][_0x7ed6('0x44')](_0x3ee36b)[_0x7ed6('0x22')](handleEntityNotFound(_0x253c43,null))[_0x7ed6('0x22')](respondWithResult(_0x253c43,null))[_0x7ed6('0x40')](handleError(_0x253c43,null));};exports[_0x7ed6('0x45')]=function(_0x5411ec,_0x26d74d){return db[_0x7ed6('0x29')][_0x7ed6('0x45')](_0x5411ec[_0x7ed6('0x46')],{})[_0x7ed6('0x22')](function(_0x10ad8f){var _0x42ec13=_0x5411ec[_0x7ed6('0x47')][_0x7ed6('0x23')]({'plain':!![]});if(!_0x42ec13)throw new Error(_0x7ed6('0x48'));if(_0x42ec13['role']==='user'){var _0x161084=_0x10ad8f[_0x7ed6('0x23')]({'plain':!![]});var _0x22a521='ExtractedReports';return db[_0x7ed6('0x49')]['find']({'where':{'name':_0x22a521,'userProfileId':_0x42ec13[_0x7ed6('0x4a')]},'raw':!![]})[_0x7ed6('0x22')](function(_0x4cad40){if(_0x4cad40&&_0x4cad40[_0x7ed6('0x4b')]===0x0){return db['UserProfileResource'][_0x7ed6('0x45')]({'name':_0x161084[_0x7ed6('0x26')],'resourceId':_0x161084['id'],'type':_0x4cad40[_0x7ed6('0x26')],'sectionId':_0x4cad40['id']},{})[_0x7ed6('0x22')](function(){return _0x10ad8f;});}else{return _0x10ad8f;}})[_0x7ed6('0x40')](function(_0x34b428){logger[_0x7ed6('0x4c')](_0x7ed6('0x4d'),_0x34b428);throw _0x34b428;});}return _0x10ad8f;})[_0x7ed6('0x22')](respondWithResult(_0x26d74d,0xc9))[_0x7ed6('0x40')](handleError(_0x26d74d,null));};exports[_0x7ed6('0x4e')]=function(_0x57be40,_0x2ff9ed){if(_0x57be40[_0x7ed6('0x46')]['id']){delete _0x57be40[_0x7ed6('0x46')]['id'];}return db['AnalyticExtractedReport']['find']({'where':{'id':_0x57be40[_0x7ed6('0x42')]['id']}})[_0x7ed6('0x22')](handleEntityNotFound(_0x2ff9ed,null))[_0x7ed6('0x22')](saveUpdates(_0x57be40[_0x7ed6('0x46')],null))[_0x7ed6('0x22')](respondWithResult(_0x2ff9ed,null))[_0x7ed6('0x40')](handleError(_0x2ff9ed,null));};exports['destroy']=function(_0x5228a1,_0x14309d){return db['AnalyticExtractedReport'][_0x7ed6('0x44')]({'where':{'id':_0x5228a1['params']['id']}})[_0x7ed6('0x22')](handleEntityNotFound(_0x14309d,null))[_0x7ed6('0x22')](removeEntity(_0x14309d,null))[_0x7ed6('0x40')](handleError(_0x14309d,null));};exports[_0x7ed6('0x4f')]=function(_0x375bff,_0x481ad1,_0x12ba12){return db[_0x7ed6('0x29')][_0x7ed6('0x44')]({'where':{'id':_0x375bff[_0x7ed6('0x42')]['id']},'attributes':[_0x7ed6('0x26'),'basename','savename',_0x7ed6('0x50')],'raw':!![]})[_0x7ed6('0x22')](handleEntityNotFound(_0x481ad1,null))[_0x7ed6('0x22')](function(_0x2aceac){if(_0x2aceac){if(!fs[_0x7ed6('0x51')](path['join'](config[_0x7ed6('0x52')],_0x7ed6('0x53'),_0x2aceac[_0x7ed6('0x54')]))){throw new db['Sequelize'][(_0x7ed6('0x55'))](_0x7ed6('0x56'));}if(_0x375bff['query'][_0x7ed6('0x57')]){return _0x481ad1[_0x7ed6('0x17')](0xc8);}return _0x481ad1[_0x7ed6('0x4f')](path[_0x7ed6('0x58')](config[_0x7ed6('0x52')],_0x7ed6('0x53'),_0x2aceac[_0x7ed6('0x54')]),util[_0x7ed6('0x59')](_0x7ed6('0x5a'),_0x2aceac[_0x7ed6('0x5b')]||_0x2aceac[_0x7ed6('0x26')],_0x2aceac[_0x7ed6('0x50')][_0x7ed6('0x5c')]()));}})[_0x7ed6('0x40')](handleError(_0x481ad1,null));};
\ No newline at end of file
+var _0xcc0b=['moment','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','update','then','destroy','ExtractedReports','sendStatus','error','stack','name','send','index','map','AnalyticExtractedReport','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','rawAttributes','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','get','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','basename','savename','output','existsSync','join','root','Sequelize','ValidationError','exists','format','eml-format','fast-json-patch','request-promise'];(function(_0x598bdb,_0x4065df){var _0x5b818b=function(_0xfaf9ef){while(--_0xfaf9ef){_0x598bdb['push'](_0x598bdb['shift']());}};_0x5b818b(++_0x4065df);}(_0xcc0b,0x10e));var _0xbcc0=function(_0x4d06fb,_0x55390d){_0x4d06fb=_0x4d06fb-0x0;var _0x2e42fc=_0xcc0b[_0x4d06fb];return _0x2e42fc;};'use strict';var emlformat=require(_0xbcc0('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xbcc0('0x1'));var rp=require(_0xbcc0('0x2'));var moment=require(_0xbcc0('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0xbcc0('0x4'));var sox=require(_0xbcc0('0x5'));var csv=require(_0xbcc0('0x6'));var ejs=require(_0xbcc0('0x7'));var fs=require('fs');var fs_extra=require(_0xbcc0('0x8'));var _=require(_0xbcc0('0x9'));var squel=require(_0xbcc0('0xa'));var crypto=require(_0xbcc0('0xb'));var jsforce=require(_0xbcc0('0xc'));var deskjs=require(_0xbcc0('0xd'));var toCsv=require(_0xbcc0('0x6'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xbcc0('0xe'));var qs=require('../../components/parsers/qs');var as=require(_0xbcc0('0xf'));var hardwareService=require(_0xbcc0('0x10'));var logger=require(_0xbcc0('0x11'))(_0xbcc0('0x12'));var utils=require(_0xbcc0('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0xbcc0('0x14'));var db=require(_0xbcc0('0x15'))['db'];function respondWithStatusCode(_0x217c29,_0x4bc585){_0x4bc585=_0x4bc585||0xcc;return function(_0x1072ce){if(_0x1072ce){return _0x217c29['sendStatus'](_0x4bc585);}return _0x217c29[_0xbcc0('0x16')](_0x4bc585)[_0xbcc0('0x17')]();};}function respondWithResult(_0x1b9816,_0x25d43c){_0x25d43c=_0x25d43c||0xc8;return function(_0x47e162){if(_0x47e162){return _0x1b9816['status'](_0x25d43c)['json'](_0x47e162);}};}function respondWithFilteredResult(_0x54973b,_0x45486a){return function(_0x3a5093){if(_0x3a5093){var _0x137200=typeof _0x45486a[_0xbcc0('0x18')]===_0xbcc0('0x19')&&typeof _0x45486a[_0xbcc0('0x1a')]===_0xbcc0('0x19');var _0x5174eb=_0x3a5093[_0xbcc0('0x1b')];var _0x90c4d6=_0x137200?0x0:_0x45486a[_0xbcc0('0x18')];var _0x37c5cd=_0x137200?_0x3a5093[_0xbcc0('0x1b')]:_0x45486a[_0xbcc0('0x18')]+_0x45486a[_0xbcc0('0x1a')];var _0x133e1d;if(_0x37c5cd>=_0x5174eb){_0x37c5cd=_0x5174eb;_0x133e1d=0xc8;}else{_0x133e1d=0xce;}_0x54973b['status'](_0x133e1d);return _0x54973b['set'](_0xbcc0('0x1c'),_0x90c4d6+'-'+_0x37c5cd+'/'+_0x5174eb)[_0xbcc0('0x1d')](_0x3a5093);}return null;};}function patchUpdates(_0x33a1d6){return function(_0x795bfc){try{jsonpatch[_0xbcc0('0x1e')](_0x795bfc,_0x33a1d6,!![]);}catch(_0x27635a){return BPromise[_0xbcc0('0x1f')](_0x27635a);}return _0x795bfc['save']();};}function saveUpdates(_0x2a127c,_0x19285c){return function(_0xcac76e){if(_0xcac76e){return _0xcac76e[_0xbcc0('0x20')](_0x2a127c)[_0xbcc0('0x21')](function(_0x1db301){return _0x1db301;});}return null;};}function removeEntity(_0x415729,_0xdf3190){return function(_0x1bdc66){if(_0x1bdc66){return _0x1bdc66[_0xbcc0('0x22')]()[_0xbcc0('0x21')](function(){var _0x1b5223=_0x1bdc66['get']({'plain':!![]});var _0x46faec=_0xbcc0('0x23');return db['UserProfileResource'][_0xbcc0('0x22')]({'where':{'type':_0x46faec,'resourceId':_0x1b5223['id']}})[_0xbcc0('0x21')](function(){return _0x1bdc66;});})['then'](function(){_0x415729[_0xbcc0('0x16')](0xcc)[_0xbcc0('0x17')]();});}};}function handleEntityNotFound(_0x31b61f,_0x3fee36){return function(_0x407ade){if(!_0x407ade){_0x31b61f[_0xbcc0('0x24')](0x194);}return _0x407ade;};}function handleError(_0x52217d,_0x1fe350){_0x1fe350=_0x1fe350||0x1f4;return function(_0x194a9c){logger[_0xbcc0('0x25')](_0x194a9c[_0xbcc0('0x26')]);if(_0x194a9c['name']){delete _0x194a9c[_0xbcc0('0x27')];}_0x52217d[_0xbcc0('0x16')](_0x1fe350)[_0xbcc0('0x28')](_0x194a9c);};}exports[_0xbcc0('0x29')]=function(_0x3590f9,_0x1596a5){var _0x56dc9c={},_0x4ec02e={},_0x163c17={'count':0x0,'rows':[]};var _0xfdde1f=_[_0xbcc0('0x2a')](db[_0xbcc0('0x2b')]['rawAttributes'],function(_0x47095f){return{'name':_0x47095f[_0xbcc0('0x2c')],'type':_0x47095f[_0xbcc0('0x2d')]['key']};});_0x4ec02e[_0xbcc0('0x2e')]=_[_0xbcc0('0x2a')](_0xfdde1f,_0xbcc0('0x27'));_0x4ec02e[_0xbcc0('0x2f')]=_[_0xbcc0('0x30')](_0x3590f9[_0xbcc0('0x2f')]);_0x4ec02e[_0xbcc0('0x31')]=_[_0xbcc0('0x32')](_0x4ec02e[_0xbcc0('0x2e')],_0x4ec02e[_0xbcc0('0x2f')]);_0x56dc9c[_0xbcc0('0x33')]=_['intersection'](_0x4ec02e[_0xbcc0('0x2e')],qs[_0xbcc0('0x34')](_0x3590f9[_0xbcc0('0x2f')][_0xbcc0('0x34')]));_0x56dc9c[_0xbcc0('0x33')]=_0x56dc9c['attributes'][_0xbcc0('0x35')]?_0x56dc9c[_0xbcc0('0x33')]:_0x4ec02e['model'];if(!_0x3590f9[_0xbcc0('0x2f')][_0xbcc0('0x36')](_0xbcc0('0x37'))){_0x56dc9c[_0xbcc0('0x1a')]=qs['limit'](_0x3590f9['query'][_0xbcc0('0x1a')]);_0x56dc9c[_0xbcc0('0x18')]=qs['offset'](_0x3590f9['query'][_0xbcc0('0x18')]);}_0x56dc9c['order']=qs[_0xbcc0('0x38')](_0x3590f9[_0xbcc0('0x2f')][_0xbcc0('0x38')]);_0x56dc9c[_0xbcc0('0x39')]=qs[_0xbcc0('0x31')](_['pick'](_0x3590f9[_0xbcc0('0x2f')],_0x4ec02e[_0xbcc0('0x31')]),_0xfdde1f);if(_0x3590f9[_0xbcc0('0x2f')][_0xbcc0('0x3a')]){_0x56dc9c['where']=_[_0xbcc0('0x3b')](_0x56dc9c['where'],{'$or':_[_0xbcc0('0x2a')](_0xfdde1f,function(_0xaa37e2){if(_0xaa37e2['type']!==_0xbcc0('0x3c')){var _0x375b1d={};_0x375b1d[_0xaa37e2[_0xbcc0('0x27')]]={'$like':'%'+_0x3590f9[_0xbcc0('0x2f')][_0xbcc0('0x3a')]+'%'};return _0x375b1d;}})});}_0x56dc9c=_[_0xbcc0('0x3b')]({},_0x56dc9c,_0x3590f9[_0xbcc0('0x3d')]);var _0x351d51={'where':_0x56dc9c['where']};return db[_0xbcc0('0x2b')]['count'](_0x351d51)[_0xbcc0('0x21')](function(_0x4796aa){_0x163c17[_0xbcc0('0x1b')]=_0x4796aa;if(_0x3590f9[_0xbcc0('0x2f')][_0xbcc0('0x3e')]){_0x56dc9c[_0xbcc0('0x3f')]=[{'all':!![]}];}return db[_0xbcc0('0x2b')][_0xbcc0('0x40')](_0x56dc9c);})[_0xbcc0('0x21')](function(_0x7ff841){_0x163c17[_0xbcc0('0x41')]=_0x7ff841;return _0x163c17;})[_0xbcc0('0x21')](respondWithFilteredResult(_0x1596a5,_0x56dc9c))[_0xbcc0('0x42')](handleError(_0x1596a5,null));};exports[_0xbcc0('0x43')]=function(_0xe82cd7,_0x47c5b7){var _0x52544e={'raw':!![],'where':{'id':_0xe82cd7['params']['id']}},_0x274ffb={};_0x274ffb[_0xbcc0('0x2e')]=_['keys'](db['AnalyticExtractedReport'][_0xbcc0('0x44')]);_0x274ffb[_0xbcc0('0x2f')]=_['keys'](_0xe82cd7[_0xbcc0('0x2f')]);_0x274ffb[_0xbcc0('0x31')]=_['intersection'](_0x274ffb[_0xbcc0('0x2e')],_0x274ffb[_0xbcc0('0x2f')]);_0x52544e[_0xbcc0('0x33')]=_[_0xbcc0('0x32')](_0x274ffb[_0xbcc0('0x2e')],qs[_0xbcc0('0x34')](_0xe82cd7['query'][_0xbcc0('0x34')]));_0x52544e['attributes']=_0x52544e[_0xbcc0('0x33')][_0xbcc0('0x35')]?_0x52544e[_0xbcc0('0x33')]:_0x274ffb[_0xbcc0('0x2e')];if(_0xe82cd7[_0xbcc0('0x2f')][_0xbcc0('0x3e')]){_0x52544e[_0xbcc0('0x3f')]=[{'all':!![]}];}_0x52544e=_['merge']({},_0x52544e,_0xe82cd7[_0xbcc0('0x3d')]);return db[_0xbcc0('0x2b')][_0xbcc0('0x45')](_0x52544e)[_0xbcc0('0x21')](handleEntityNotFound(_0x47c5b7,null))[_0xbcc0('0x21')](respondWithResult(_0x47c5b7,null))[_0xbcc0('0x42')](handleError(_0x47c5b7,null));};exports[_0xbcc0('0x46')]=function(_0xd6c377,_0x1cca57){return db['AnalyticExtractedReport'][_0xbcc0('0x46')](_0xd6c377[_0xbcc0('0x47')],{})[_0xbcc0('0x21')](function(_0x5aef4b){var _0x1ceee9=_0xd6c377[_0xbcc0('0x48')]['get']({'plain':!![]});if(!_0x1ceee9)throw new Error(_0xbcc0('0x49'));if(_0x1ceee9['role']===_0xbcc0('0x48')){var _0x31bb61=_0x5aef4b[_0xbcc0('0x4a')]({'plain':!![]});var _0x4245b9=_0xbcc0('0x23');return db[_0xbcc0('0x4b')]['find']({'where':{'name':_0x4245b9,'userProfileId':_0x1ceee9[_0xbcc0('0x4c')]},'raw':!![]})[_0xbcc0('0x21')](function(_0x5331aa){if(_0x5331aa&&_0x5331aa[_0xbcc0('0x4d')]===0x0){return db[_0xbcc0('0x4e')][_0xbcc0('0x46')]({'name':_0x31bb61[_0xbcc0('0x27')],'resourceId':_0x31bb61['id'],'type':_0x5331aa[_0xbcc0('0x27')],'sectionId':_0x5331aa['id']},{})[_0xbcc0('0x21')](function(){return _0x5aef4b;});}else{return _0x5aef4b;}})[_0xbcc0('0x42')](function(_0xf6e33f){logger['error'](_0xbcc0('0x4f'),_0xf6e33f);throw _0xf6e33f;});}return _0x5aef4b;})[_0xbcc0('0x21')](respondWithResult(_0x1cca57,0xc9))[_0xbcc0('0x42')](handleError(_0x1cca57,null));};exports[_0xbcc0('0x20')]=function(_0x15dbb8,_0x16ac53){if(_0x15dbb8[_0xbcc0('0x47')]['id']){delete _0x15dbb8['body']['id'];}return db['AnalyticExtractedReport'][_0xbcc0('0x45')]({'where':{'id':_0x15dbb8[_0xbcc0('0x50')]['id']}})[_0xbcc0('0x21')](handleEntityNotFound(_0x16ac53,null))['then'](saveUpdates(_0x15dbb8['body'],null))[_0xbcc0('0x21')](respondWithResult(_0x16ac53,null))['catch'](handleError(_0x16ac53,null));};exports[_0xbcc0('0x22')]=function(_0x3b7ccf,_0x54d93b){return db[_0xbcc0('0x2b')][_0xbcc0('0x45')]({'where':{'id':_0x3b7ccf[_0xbcc0('0x50')]['id']}})[_0xbcc0('0x21')](handleEntityNotFound(_0x54d93b,null))[_0xbcc0('0x21')](removeEntity(_0x54d93b,null))[_0xbcc0('0x42')](handleError(_0x54d93b,null));};exports['download']=function(_0x249ff4,_0x23f47c,_0x105311){return db[_0xbcc0('0x2b')][_0xbcc0('0x45')]({'where':{'id':_0x249ff4[_0xbcc0('0x50')]['id']},'attributes':[_0xbcc0('0x27'),_0xbcc0('0x51'),_0xbcc0('0x52'),_0xbcc0('0x53')],'raw':!![]})[_0xbcc0('0x21')](handleEntityNotFound(_0x23f47c,null))['then'](function(_0x26c73e){if(_0x26c73e){if(!fs[_0xbcc0('0x54')](path[_0xbcc0('0x55')](config[_0xbcc0('0x56')],'server/files/reports',_0x26c73e['savename']))){throw new db[(_0xbcc0('0x57'))][(_0xbcc0('0x58'))]('Report\x20not\x20found\x20or\x20empty');}if(_0x249ff4[_0xbcc0('0x2f')][_0xbcc0('0x59')]){return _0x23f47c[_0xbcc0('0x24')](0xc8);}return _0x23f47c['download'](path[_0xbcc0('0x55')](config['root'],'server/files/reports',_0x26c73e[_0xbcc0('0x52')]),util[_0xbcc0('0x5a')]('%s.%s',_0x26c73e[_0xbcc0('0x51')]||_0x26c73e[_0xbcc0('0x27')],_0x26c73e['output']['toLowerCase']()));}})[_0xbcc0('0x42')](handleError(_0x23f47c,null));};
\ No newline at end of file