Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / analyticMetric / analyticMetric.controller.js
index 3254bd8..73dfe0f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x74be=['../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','json','count','set','Content-Range','apply','reject','save','update','destroy','Metrics','then','error','stack','name','status','send','map','rawAttributes','type','query','keys','filters','intersection','model','attributes','fields','length','nolimit','limit','offset','sort','pick','merge','where','VIRTUAL','filter','AnalyticMetric','includeAll','include','findAll','rows','catch','show','options','find','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','UserProfileResource','body','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','to-csv','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware'];(function(_0x3ca1fa,_0x44c6b6){var _0x359b9a=function(_0x14dee6){while(--_0x14dee6){_0x3ca1fa['push'](_0x3ca1fa['shift']());}};_0x359b9a(++_0x44c6b6);}(_0x74be,0x8d));var _0xe74b=function(_0x3e1e81,_0x5516f7){_0x3e1e81=_0x3e1e81-0x0;var _0x53fe04=_0x74be[_0x3e1e81];return _0x53fe04;};'use strict';var pdf=require(_0xe74b('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xe74b('0x1'));var zipdir=require(_0xe74b('0x2'));var jsonpatch=require(_0xe74b('0x3'));var rp=require(_0xe74b('0x4'));var moment=require(_0xe74b('0x5'));var BPromise=require(_0xe74b('0x6'));var Mustache=require('mustache');var util=require(_0xe74b('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0xe74b('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xe74b('0x9'));var squel=require(_0xe74b('0xa'));var crypto=require('crypto');var jsforce=require(_0xe74b('0xb'));var deskjs=require(_0xe74b('0xc'));var toCsv=require(_0xe74b('0x8'));var querystring=require(_0xe74b('0xd'));var Papa=require(_0xe74b('0xe'));var Redis=require('ioredis');var authService=require(_0xe74b('0xf'));var qs=require(_0xe74b('0x10'));var as=require(_0xe74b('0x11'));var hardwareService=require(_0xe74b('0x12'));var logger=require(_0xe74b('0x13'))(_0xe74b('0x14'));var utils=require(_0xe74b('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xe74b('0x16'));var db=require(_0xe74b('0x17'))['db'];function respondWithStatusCode(_0x4ccd66,_0x3ece67){_0x3ece67=_0x3ece67||0xcc;return function(_0x5356aa){if(_0x5356aa){return _0x4ccd66[_0xe74b('0x18')](_0x3ece67);}return _0x4ccd66['status'](_0x3ece67)[_0xe74b('0x19')]();};}function respondWithResult(_0x622867,_0x1bfb53){_0x1bfb53=_0x1bfb53||0xc8;return function(_0x4d50cc){if(_0x4d50cc){return _0x622867['status'](_0x1bfb53)[_0xe74b('0x1a')](_0x4d50cc);}};}function respondWithFilteredResult(_0x358e31,_0x5c31e1){return function(_0x626b84){if(_0x626b84){var _0x29f16a=_0x626b84[_0xe74b('0x1b')],_0x213c5d=_0x5c31e1['offset'],_0x491c30=_0x5c31e1['offset']+_0x5c31e1['limit'],_0x590baa;if(_0x491c30>=_0x29f16a){_0x491c30=_0x29f16a;_0x590baa=0xc8;}else{_0x590baa=0xce;}_0x358e31['status'](_0x590baa);return _0x358e31[_0xe74b('0x1c')](_0xe74b('0x1d'),_0x213c5d+'-'+_0x491c30+'/'+_0x29f16a)[_0xe74b('0x1a')](_0x626b84);}return null;};}function patchUpdates(_0xff5dd7){return function(_0xb2a2f5){try{jsonpatch[_0xe74b('0x1e')](_0xb2a2f5,_0xff5dd7,!![]);}catch(_0x3f7187){return BPromise[_0xe74b('0x1f')](_0x3f7187);}return _0xb2a2f5[_0xe74b('0x20')]();};}function saveUpdates(_0x49e1e4,_0x492788){return function(_0x315ba7){if(_0x315ba7){return _0x315ba7[_0xe74b('0x21')](_0x49e1e4)['then'](function(_0x4b357b){return _0x4b357b;});}return null;};}function removeEntity(_0x1de835,_0x519187){return function(_0x17df19){if(_0x17df19){return _0x17df19[_0xe74b('0x22')]()['then'](function(){var _0x58bd8a=_0x17df19['get']({'plain':!![]});var _0x5738e7=_0xe74b('0x23');return db['UserProfileResource'][_0xe74b('0x22')]({'where':{'type':_0x5738e7,'resourceId':_0x58bd8a['id']}})['then'](function(){return _0x17df19;});})[_0xe74b('0x24')](function(){_0x1de835['status'](0xcc)[_0xe74b('0x19')]();});}};}function handleEntityNotFound(_0x56bd65,_0xeb0182){return function(_0x3cbece){if(!_0x3cbece){_0x56bd65[_0xe74b('0x18')](0x194);}return _0x3cbece;};}function handleError(_0x5ae1c5,_0x3057fe){_0x3057fe=_0x3057fe||0x1f4;return function(_0x1a43b7){logger[_0xe74b('0x25')](_0x1a43b7[_0xe74b('0x26')]);if(_0x1a43b7[_0xe74b('0x27')]){delete _0x1a43b7['name'];}_0x5ae1c5[_0xe74b('0x28')](_0x3057fe)[_0xe74b('0x29')](_0x1a43b7);};}exports['index']=function(_0x3133e5,_0x4f675e){var _0x28c1ce={},_0x36652f={},_0x4cdca9={'count':0x0,'rows':[]};var _0x510486=_[_0xe74b('0x2a')](db['AnalyticMetric'][_0xe74b('0x2b')],function(_0x1c24da){return{'name':_0x1c24da['fieldName'],'type':_0x1c24da[_0xe74b('0x2c')]['key']};});_0x36652f['model']=_[_0xe74b('0x2a')](_0x510486,_0xe74b('0x27'));_0x36652f[_0xe74b('0x2d')]=_[_0xe74b('0x2e')](_0x3133e5['query']);_0x36652f[_0xe74b('0x2f')]=_[_0xe74b('0x30')](_0x36652f[_0xe74b('0x31')],_0x36652f[_0xe74b('0x2d')]);_0x28c1ce[_0xe74b('0x32')]=_[_0xe74b('0x30')](_0x36652f['model'],qs[_0xe74b('0x33')](_0x3133e5[_0xe74b('0x2d')][_0xe74b('0x33')]));_0x28c1ce[_0xe74b('0x32')]=_0x28c1ce['attributes'][_0xe74b('0x34')]?_0x28c1ce[_0xe74b('0x32')]:_0x36652f['model'];if(!_0x3133e5[_0xe74b('0x2d')]['hasOwnProperty'](_0xe74b('0x35'))){_0x28c1ce['limit']=qs[_0xe74b('0x36')](_0x3133e5['query'][_0xe74b('0x36')]);_0x28c1ce[_0xe74b('0x37')]=qs[_0xe74b('0x37')](_0x3133e5[_0xe74b('0x2d')][_0xe74b('0x37')]);}_0x28c1ce['order']=qs[_0xe74b('0x38')](_0x3133e5[_0xe74b('0x2d')][_0xe74b('0x38')]);_0x28c1ce['where']=qs['filters'](_[_0xe74b('0x39')](_0x3133e5[_0xe74b('0x2d')],_0x36652f['filters']),_0x510486);if(_0x3133e5[_0xe74b('0x2d')]['filter']){_0x28c1ce['where']=_[_0xe74b('0x3a')](_0x28c1ce[_0xe74b('0x3b')],{'$or':_[_0xe74b('0x2a')](_0x510486,function(_0x189f1f){if(_0x189f1f[_0xe74b('0x2c')]!==_0xe74b('0x3c')){var _0x330232={};_0x330232[_0x189f1f[_0xe74b('0x27')]]={'$like':'%'+_0x3133e5[_0xe74b('0x2d')][_0xe74b('0x3d')]+'%'};return _0x330232;}})});}_0x28c1ce=_[_0xe74b('0x3a')]({},_0x28c1ce,_0x3133e5['options']);var _0x271a80={'where':_0x28c1ce[_0xe74b('0x3b')]};return db[_0xe74b('0x3e')]['count'](_0x271a80)['then'](function(_0x1fec2c){_0x4cdca9[_0xe74b('0x1b')]=_0x1fec2c;if(_0x3133e5['query'][_0xe74b('0x3f')]){_0x28c1ce[_0xe74b('0x40')]=[{'all':!![]}];}return db['AnalyticMetric'][_0xe74b('0x41')](_0x28c1ce);})['then'](function(_0x17b4c0){_0x4cdca9[_0xe74b('0x42')]=_0x17b4c0;return _0x4cdca9;})[_0xe74b('0x24')](respondWithFilteredResult(_0x4f675e,_0x28c1ce))[_0xe74b('0x43')](handleError(_0x4f675e,null));};exports[_0xe74b('0x44')]=function(_0x26c550,_0x51a0c3){var _0x3cafe5={'raw':!![],'where':{'id':_0x26c550['params']['id']}},_0x5d4340={};_0x5d4340[_0xe74b('0x31')]=_[_0xe74b('0x2e')](db['AnalyticMetric']['rawAttributes']);_0x5d4340[_0xe74b('0x2d')]=_['keys'](_0x26c550[_0xe74b('0x2d')]);_0x5d4340['filters']=_[_0xe74b('0x30')](_0x5d4340[_0xe74b('0x31')],_0x5d4340[_0xe74b('0x2d')]);_0x3cafe5[_0xe74b('0x32')]=_[_0xe74b('0x30')](_0x5d4340[_0xe74b('0x31')],qs[_0xe74b('0x33')](_0x26c550[_0xe74b('0x2d')][_0xe74b('0x33')]));_0x3cafe5[_0xe74b('0x32')]=_0x3cafe5[_0xe74b('0x32')][_0xe74b('0x34')]?_0x3cafe5[_0xe74b('0x32')]:_0x5d4340[_0xe74b('0x31')];if(_0x26c550[_0xe74b('0x2d')][_0xe74b('0x3f')]){_0x3cafe5[_0xe74b('0x40')]=[{'all':!![]}];}_0x3cafe5=_[_0xe74b('0x3a')]({},_0x3cafe5,_0x26c550[_0xe74b('0x45')]);return db['AnalyticMetric'][_0xe74b('0x46')](_0x3cafe5)[_0xe74b('0x24')](handleEntityNotFound(_0x51a0c3,null))['then'](respondWithResult(_0x51a0c3,null))[_0xe74b('0x43')](handleError(_0x51a0c3,null));};exports[_0xe74b('0x47')]=function(_0x203e4a,_0x251cd3){return db[_0xe74b('0x3e')][_0xe74b('0x47')](_0x203e4a['body'],{})[_0xe74b('0x24')](function(_0x53e516){var _0x597f14=_0x203e4a[_0xe74b('0x48')][_0xe74b('0x49')]({'plain':!![]});if(!_0x597f14)throw new Error(_0xe74b('0x4a'));if(_0x597f14[_0xe74b('0x4b')]===_0xe74b('0x48')){var _0x58ec19=_0x53e516['get']({'plain':!![]});var _0x287a01=_0xe74b('0x23');return db[_0xe74b('0x4c')]['find']({'where':{'name':_0x287a01,'userProfileId':_0x597f14[_0xe74b('0x4d')]},'raw':!![]})['then'](function(_0x26cb42){if(_0x26cb42&&_0x26cb42['autoAssociation']===0x0){return db[_0xe74b('0x4e')]['create']({'name':_0x58ec19[_0xe74b('0x27')],'resourceId':_0x58ec19['id'],'type':_0x26cb42[_0xe74b('0x27')],'sectionId':_0x26cb42['id']},{})['then'](function(){return _0x53e516;});}else{return _0x53e516;}})['catch'](function(_0x3d5a58){logger[_0xe74b('0x25')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3d5a58);throw _0x3d5a58;});}return _0x53e516;})[_0xe74b('0x24')](respondWithResult(_0x251cd3,0xc9))[_0xe74b('0x43')](handleError(_0x251cd3,null));};exports[_0xe74b('0x21')]=function(_0x4d4fc5,_0x13a29e){if(_0x4d4fc5[_0xe74b('0x4f')]['id']){delete _0x4d4fc5[_0xe74b('0x4f')]['id'];}return db[_0xe74b('0x3e')][_0xe74b('0x46')]({'where':{'id':_0x4d4fc5['params']['id']}})['then'](handleEntityNotFound(_0x13a29e,null))[_0xe74b('0x24')](saveUpdates(_0x4d4fc5[_0xe74b('0x4f')],null))[_0xe74b('0x24')](respondWithResult(_0x13a29e,null))[_0xe74b('0x43')](handleError(_0x13a29e,null));};exports['destroy']=function(_0x100767,_0x20abf2){return db['AnalyticMetric'][_0xe74b('0x46')]({'where':{'id':_0x100767['params']['id']}})[_0xe74b('0x24')](handleEntityNotFound(_0x20abf2,null))[_0xe74b('0x24')](removeEntity(_0x20abf2,null))[_0xe74b('0x43')](handleError(_0x20abf2,null));};
\ No newline at end of file
+var _0xa41a=['attributes','length','hasOwnProperty','order','sort','where','filters','pick','filter','VIRTUAL','merge','options','includeAll','include','rows','catch','show','params','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','Metrics','UserProfileSection','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','sendStatus','status','end','json','undefined','limit','count','offset','set','save','update','destroy','then','error','stack','name','send','map','AnalyticMetric','type','key','model','query','keys','intersection','fields'];(function(_0x3f139e,_0x45097c){var _0x165970=function(_0x4d6884){while(--_0x4d6884){_0x3f139e['push'](_0x3f139e['shift']());}};_0x165970(++_0x45097c);}(_0xa41a,0x6b));var _0xaa41=function(_0x219364,_0x180757){_0x219364=_0x219364-0x0;var _0x7dac47=_0xa41a[_0x219364];return _0x7dac47;};'use strict';var emlformat=require(_0xaa41('0x0'));var rimraf=require(_0xaa41('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xaa41('0x2'));var rp=require(_0xaa41('0x3'));var moment=require(_0xaa41('0x4'));var BPromise=require(_0xaa41('0x5'));var Mustache=require(_0xaa41('0x6'));var util=require(_0xaa41('0x7'));var path=require(_0xaa41('0x8'));var sox=require(_0xaa41('0x9'));var csv=require('to-csv');var ejs=require(_0xaa41('0xa'));var fs=require('fs');var fs_extra=require(_0xaa41('0xb'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xaa41('0xc'));var jsforce=require(_0xaa41('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xaa41('0xe'));var querystring=require(_0xaa41('0xf'));var Papa=require(_0xaa41('0x10'));var Redis=require(_0xaa41('0x11'));var authService=require(_0xaa41('0x12'));var qs=require(_0xaa41('0x13'));var as=require(_0xaa41('0x14'));var hardwareService=require(_0xaa41('0x15'));var logger=require(_0xaa41('0x16'))('api');var utils=require(_0xaa41('0x17'));var config=require(_0xaa41('0x18'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1d0a54,_0x518b5b){_0x518b5b=_0x518b5b||0xcc;return function(_0x19bd69){if(_0x19bd69){return _0x1d0a54[_0xaa41('0x19')](_0x518b5b);}return _0x1d0a54[_0xaa41('0x1a')](_0x518b5b)[_0xaa41('0x1b')]();};}function respondWithResult(_0x6f9ade,_0x4eaf81){_0x4eaf81=_0x4eaf81||0xc8;return function(_0x1e9d7f){if(_0x1e9d7f){return _0x6f9ade[_0xaa41('0x1a')](_0x4eaf81)[_0xaa41('0x1c')](_0x1e9d7f);}};}function respondWithFilteredResult(_0x1ef7d9,_0x2a6988){return function(_0x2005ae){if(_0x2005ae){var _0x1e1e02=typeof _0x2a6988['offset']===_0xaa41('0x1d')&&typeof _0x2a6988[_0xaa41('0x1e')]===_0xaa41('0x1d');var _0x391b01=_0x2005ae[_0xaa41('0x1f')];var _0xd20ddf=_0x1e1e02?0x0:_0x2a6988[_0xaa41('0x20')];var _0x46e6d3=_0x1e1e02?_0x2005ae[_0xaa41('0x1f')]:_0x2a6988['offset']+_0x2a6988['limit'];var _0x1f502a;if(_0x46e6d3>=_0x391b01){_0x46e6d3=_0x391b01;_0x1f502a=0xc8;}else{_0x1f502a=0xce;}_0x1ef7d9[_0xaa41('0x1a')](_0x1f502a);return _0x1ef7d9[_0xaa41('0x21')]('Content-Range',_0xd20ddf+'-'+_0x46e6d3+'/'+_0x391b01)[_0xaa41('0x1c')](_0x2005ae);}return null;};}function patchUpdates(_0x1f692b){return function(_0x4e768e){try{jsonpatch['apply'](_0x4e768e,_0x1f692b,!![]);}catch(_0x1b1910){return BPromise['reject'](_0x1b1910);}return _0x4e768e[_0xaa41('0x22')]();};}function saveUpdates(_0x209c83,_0x3e2175){return function(_0x1f27f3){if(_0x1f27f3){return _0x1f27f3[_0xaa41('0x23')](_0x209c83)['then'](function(_0x43c430){return _0x43c430;});}return null;};}function removeEntity(_0x43a85c,_0x448a21){return function(_0x21f596){if(_0x21f596){return _0x21f596[_0xaa41('0x24')]()[_0xaa41('0x25')](function(){var _0x5c3074=_0x21f596['get']({'plain':!![]});var _0x16aec5='Metrics';return db['UserProfileResource'][_0xaa41('0x24')]({'where':{'type':_0x16aec5,'resourceId':_0x5c3074['id']}})['then'](function(){return _0x21f596;});})['then'](function(){_0x43a85c[_0xaa41('0x1a')](0xcc)[_0xaa41('0x1b')]();});}};}function handleEntityNotFound(_0x392214,_0x632fd2){return function(_0x3f5272){if(!_0x3f5272){_0x392214[_0xaa41('0x19')](0x194);}return _0x3f5272;};}function handleError(_0x57ef96,_0x30a174){_0x30a174=_0x30a174||0x1f4;return function(_0x1f0275){logger[_0xaa41('0x26')](_0x1f0275[_0xaa41('0x27')]);if(_0x1f0275[_0xaa41('0x28')]){delete _0x1f0275[_0xaa41('0x28')];}_0x57ef96[_0xaa41('0x1a')](_0x30a174)[_0xaa41('0x29')](_0x1f0275);};}exports['index']=function(_0x377add,_0x48b48b){var _0x5dad80={},_0x714537={},_0x1176bd={'count':0x0,'rows':[]};var _0x534a85=_[_0xaa41('0x2a')](db[_0xaa41('0x2b')]['rawAttributes'],function(_0x5022fb){return{'name':_0x5022fb['fieldName'],'type':_0x5022fb[_0xaa41('0x2c')][_0xaa41('0x2d')]};});_0x714537[_0xaa41('0x2e')]=_[_0xaa41('0x2a')](_0x534a85,'name');_0x714537[_0xaa41('0x2f')]=_[_0xaa41('0x30')](_0x377add[_0xaa41('0x2f')]);_0x714537['filters']=_[_0xaa41('0x31')](_0x714537[_0xaa41('0x2e')],_0x714537[_0xaa41('0x2f')]);_0x5dad80['attributes']=_[_0xaa41('0x31')](_0x714537[_0xaa41('0x2e')],qs['fields'](_0x377add[_0xaa41('0x2f')][_0xaa41('0x32')]));_0x5dad80[_0xaa41('0x33')]=_0x5dad80['attributes'][_0xaa41('0x34')]?_0x5dad80['attributes']:_0x714537[_0xaa41('0x2e')];if(!_0x377add[_0xaa41('0x2f')][_0xaa41('0x35')]('nolimit')){_0x5dad80['limit']=qs['limit'](_0x377add[_0xaa41('0x2f')][_0xaa41('0x1e')]);_0x5dad80[_0xaa41('0x20')]=qs[_0xaa41('0x20')](_0x377add['query']['offset']);}_0x5dad80[_0xaa41('0x36')]=qs[_0xaa41('0x37')](_0x377add[_0xaa41('0x2f')][_0xaa41('0x37')]);_0x5dad80[_0xaa41('0x38')]=qs[_0xaa41('0x39')](_[_0xaa41('0x3a')](_0x377add['query'],_0x714537[_0xaa41('0x39')]),_0x534a85);if(_0x377add[_0xaa41('0x2f')][_0xaa41('0x3b')]){_0x5dad80[_0xaa41('0x38')]=_['merge'](_0x5dad80['where'],{'$or':_[_0xaa41('0x2a')](_0x534a85,function(_0x275fa3){if(_0x275fa3['type']!==_0xaa41('0x3c')){var _0x563687={};_0x563687[_0x275fa3[_0xaa41('0x28')]]={'$like':'%'+_0x377add[_0xaa41('0x2f')][_0xaa41('0x3b')]+'%'};return _0x563687;}})});}_0x5dad80=_[_0xaa41('0x3d')]({},_0x5dad80,_0x377add[_0xaa41('0x3e')]);var _0x12ba1a={'where':_0x5dad80[_0xaa41('0x38')]};return db[_0xaa41('0x2b')]['count'](_0x12ba1a)[_0xaa41('0x25')](function(_0x2abf39){_0x1176bd[_0xaa41('0x1f')]=_0x2abf39;if(_0x377add[_0xaa41('0x2f')][_0xaa41('0x3f')]){_0x5dad80[_0xaa41('0x40')]=[{'all':!![]}];}return db['AnalyticMetric']['findAll'](_0x5dad80);})[_0xaa41('0x25')](function(_0x4f9086){_0x1176bd[_0xaa41('0x41')]=_0x4f9086;return _0x1176bd;})[_0xaa41('0x25')](respondWithFilteredResult(_0x48b48b,_0x5dad80))[_0xaa41('0x42')](handleError(_0x48b48b,null));};exports[_0xaa41('0x43')]=function(_0x2aac10,_0x10bf09){var _0x2db8d6={'raw':!![],'where':{'id':_0x2aac10[_0xaa41('0x44')]['id']}},_0x5ee74c={};_0x5ee74c['model']=_['keys'](db[_0xaa41('0x2b')]['rawAttributes']);_0x5ee74c['query']=_['keys'](_0x2aac10[_0xaa41('0x2f')]);_0x5ee74c['filters']=_[_0xaa41('0x31')](_0x5ee74c[_0xaa41('0x2e')],_0x5ee74c['query']);_0x2db8d6['attributes']=_[_0xaa41('0x31')](_0x5ee74c[_0xaa41('0x2e')],qs[_0xaa41('0x32')](_0x2aac10[_0xaa41('0x2f')][_0xaa41('0x32')]));_0x2db8d6[_0xaa41('0x33')]=_0x2db8d6[_0xaa41('0x33')][_0xaa41('0x34')]?_0x2db8d6[_0xaa41('0x33')]:_0x5ee74c['model'];if(_0x2aac10[_0xaa41('0x2f')][_0xaa41('0x3f')]){_0x2db8d6[_0xaa41('0x40')]=[{'all':!![]}];}_0x2db8d6=_[_0xaa41('0x3d')]({},_0x2db8d6,_0x2aac10[_0xaa41('0x3e')]);return db[_0xaa41('0x2b')]['find'](_0x2db8d6)[_0xaa41('0x25')](handleEntityNotFound(_0x10bf09,null))[_0xaa41('0x25')](respondWithResult(_0x10bf09,null))[_0xaa41('0x42')](handleError(_0x10bf09,null));};exports[_0xaa41('0x45')]=function(_0x57d1f6,_0x23bc61){return db['AnalyticMetric']['create'](_0x57d1f6[_0xaa41('0x46')],{})[_0xaa41('0x25')](function(_0x3e16ef){var _0x4ca114=_0x57d1f6[_0xaa41('0x47')][_0xaa41('0x48')]({'plain':!![]});if(!_0x4ca114)throw new Error(_0xaa41('0x49'));if(_0x4ca114['role']===_0xaa41('0x47')){var _0x3c4f24=_0x3e16ef[_0xaa41('0x48')]({'plain':!![]});var _0x1378f9=_0xaa41('0x4a');return db[_0xaa41('0x4b')][_0xaa41('0x4c')]({'where':{'name':_0x1378f9,'userProfileId':_0x4ca114[_0xaa41('0x4d')]},'raw':!![]})['then'](function(_0x9f0a81){if(_0x9f0a81&&_0x9f0a81['autoAssociation']===0x0){return db['UserProfileResource'][_0xaa41('0x45')]({'name':_0x3c4f24[_0xaa41('0x28')],'resourceId':_0x3c4f24['id'],'type':_0x9f0a81[_0xaa41('0x28')],'sectionId':_0x9f0a81['id']},{})[_0xaa41('0x25')](function(){return _0x3e16ef;});}else{return _0x3e16ef;}})[_0xaa41('0x42')](function(_0x288db3){logger[_0xaa41('0x26')](_0xaa41('0x4e'),_0x288db3);throw _0x288db3;});}return _0x3e16ef;})['then'](respondWithResult(_0x23bc61,0xc9))[_0xaa41('0x42')](handleError(_0x23bc61,null));};exports[_0xaa41('0x23')]=function(_0x1d518f,_0x4f9e92){if(_0x1d518f[_0xaa41('0x46')]['id']){delete _0x1d518f[_0xaa41('0x46')]['id'];}return db['AnalyticMetric'][_0xaa41('0x4c')]({'where':{'id':_0x1d518f[_0xaa41('0x44')]['id']}})[_0xaa41('0x25')](handleEntityNotFound(_0x4f9e92,null))['then'](saveUpdates(_0x1d518f[_0xaa41('0x46')],null))[_0xaa41('0x25')](respondWithResult(_0x4f9e92,null))['catch'](handleError(_0x4f9e92,null));};exports['destroy']=function(_0x3745ed,_0x3cd14f){return db[_0xaa41('0x2b')]['find']({'where':{'id':_0x3745ed[_0xaa41('0x44')]['id']}})[_0xaa41('0x25')](handleEntityNotFound(_0x3cd14f,null))[_0xaa41('0x25')](removeEntity(_0x3cd14f,null))[_0xaa41('0x42')](handleError(_0x3cd14f,null));};
\ No newline at end of file