Built motion from commit (unavailable).|2.5.2
[motion2.git] / server / api / analyticMetric / analyticMetric.controller.js
index 72b88ea..3e73262 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x930f=['jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../mysqldb','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','reject','then','UserProfileResource','error','stack','name','send','index','AnalyticMetric','rawAttributes','fieldName','type','model','map','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','where','merge','VIRTUAL','filter','options','include','findAll','rows','catch','show','params','includeAll','create','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','Metrics','UserProfileSection','userProfileId','autoAssociation','update','body','find','destroy','eml-format','zip-dir','fast-json-patch','moment','bluebird','path','to-csv','ejs','lodash','squel'];(function(_0x3ee6cf,_0x22de3a){var _0x5a0ca9=function(_0x4b16f7){while(--_0x4b16f7){_0x3ee6cf['push'](_0x3ee6cf['shift']());}};_0x5a0ca9(++_0x22de3a);}(_0x930f,0x12e));var _0xf930=function(_0x37b595,_0x34b8d3){_0x37b595=_0x37b595-0x0;var _0x56e3d9=_0x930f[_0x37b595];return _0x56e3d9;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xf930('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf930('0x1'));var jsonpatch=require(_0xf930('0x2'));var rp=require('request-promise');var moment=require(_0xf930('0x3'));var BPromise=require(_0xf930('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0xf930('0x5'));var sox=require('sox');var csv=require(_0xf930('0x6'));var ejs=require(_0xf930('0x7'));var fs=require('fs');var _=require(_0xf930('0x8'));var squel=require(_0xf930('0x9'));var crypto=require('crypto');var jsforce=require(_0xf930('0xa'));var deskjs=require(_0xf930('0xb'));var toCsv=require('to-csv');var querystring=require(_0xf930('0xc'));var Papa=require(_0xf930('0xd'));var Redis=require(_0xf930('0xe'));var authService=require(_0xf930('0xf'));var qs=require(_0xf930('0x10'));var as=require(_0xf930('0x11'));var hardwareService=require(_0xf930('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var db=require(_0xf930('0x13'))['db'];function respondWithStatusCode(_0x3508fd,_0xba921a){_0xba921a=_0xba921a||0xcc;return function(_0x39e73d){if(_0x39e73d){return _0x3508fd[_0xf930('0x14')](_0xba921a);}return _0x3508fd[_0xf930('0x15')](_0xba921a)[_0xf930('0x16')]();};}function respondWithResult(_0x29fd22,_0x4d89e6){_0x4d89e6=_0x4d89e6||0xc8;return function(_0x3ac247){if(_0x3ac247){return _0x29fd22[_0xf930('0x15')](_0x4d89e6)[_0xf930('0x17')](_0x3ac247);}};}function respondWithFilteredResult(_0x1e2236,_0x59dba8){return function(_0x174820){if(_0x174820){var _0x59b719=_0x174820[_0xf930('0x18')],_0xa00e0f=_0x59dba8['offset'],_0x2af95b=_0x59dba8[_0xf930('0x19')]+_0x59dba8[_0xf930('0x1a')],_0x394726;if(_0x2af95b>=_0x59b719){_0x2af95b=_0x59b719;_0x394726=0xc8;}else{_0x394726=0xce;}_0x1e2236['status'](_0x394726);return _0x1e2236['set'](_0xf930('0x1b'),_0xa00e0f+'-'+_0x2af95b+'/'+_0x59b719)['json'](_0x174820);}return null;};}function patchUpdates(_0x1cebfc){return function(_0x32f53f){try{jsonpatch[_0xf930('0x1c')](_0x32f53f,_0x1cebfc,!![]);}catch(_0x13e306){return BPromise[_0xf930('0x1d')](_0x13e306);}return _0x32f53f['save']();};}function saveUpdates(_0x6f9d24,_0x30a2a5){return function(_0x5672e5){if(_0x5672e5){return _0x5672e5['update'](_0x6f9d24)['then'](function(_0x1e85f0){return _0x1e85f0;});}return null;};}function removeEntity(_0xddc668,_0x3849bc){return function(_0x5acfb2){if(_0x5acfb2){return _0x5acfb2['destroy']()[_0xf930('0x1e')](function(){var _0x2a2fd9=_0x5acfb2['get']({'plain':!![]});var _0x3daa28='Metrics';return db[_0xf930('0x1f')]['destroy']({'where':{'type':_0x3daa28,'resourceId':_0x2a2fd9['id']}})['then'](function(){return _0x5acfb2;});})[_0xf930('0x1e')](function(){_0xddc668['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x15ed93,_0x53fea6){return function(_0x536a33){if(!_0x536a33){_0x15ed93[_0xf930('0x14')](0x194);}return _0x536a33;};}function handleError(_0x31bd20,_0x434601){_0x434601=_0x434601||0x1f4;return function(_0x5b8f0e){logger[_0xf930('0x20')](_0x5b8f0e[_0xf930('0x21')]);if(_0x5b8f0e[_0xf930('0x22')]){delete _0x5b8f0e[_0xf930('0x22')];}_0x31bd20[_0xf930('0x15')](_0x434601)[_0xf930('0x23')](_0x5b8f0e);};}exports[_0xf930('0x24')]=function(_0x2ee7b6,_0x504bf4){var _0x2925e1={},_0x39943f={},_0xe92c16={'count':0x0,'rows':[]};var _0x28bdac=_['map'](db[_0xf930('0x25')][_0xf930('0x26')],function(_0x284210){return{'name':_0x284210[_0xf930('0x27')],'type':_0x284210[_0xf930('0x28')]['key']};});_0x39943f[_0xf930('0x29')]=_[_0xf930('0x2a')](_0x28bdac,_0xf930('0x22'));_0x39943f[_0xf930('0x2b')]=_[_0xf930('0x2c')](_0x2ee7b6[_0xf930('0x2b')]);_0x39943f[_0xf930('0x2d')]=_[_0xf930('0x2e')](_0x39943f['model'],_0x39943f[_0xf930('0x2b')]);_0x2925e1[_0xf930('0x2f')]=_[_0xf930('0x2e')](_0x39943f['model'],qs['fields'](_0x2ee7b6['query'][_0xf930('0x30')]));_0x2925e1[_0xf930('0x2f')]=_0x2925e1[_0xf930('0x2f')][_0xf930('0x31')]?_0x2925e1['attributes']:_0x39943f[_0xf930('0x29')];if(!_0x2ee7b6[_0xf930('0x2b')]['hasOwnProperty'](_0xf930('0x32'))){_0x2925e1[_0xf930('0x1a')]=qs[_0xf930('0x1a')](_0x2ee7b6['query'][_0xf930('0x1a')]);_0x2925e1[_0xf930('0x19')]=qs[_0xf930('0x19')](_0x2ee7b6[_0xf930('0x2b')]['offset']);}_0x2925e1[_0xf930('0x33')]=qs[_0xf930('0x34')](_0x2ee7b6[_0xf930('0x2b')][_0xf930('0x34')]);_0x2925e1[_0xf930('0x35')]=qs['filters'](_['pick'](_0x2ee7b6['query'],_0x39943f['filters']));if(_0x2ee7b6[_0xf930('0x2b')]['filter']){_0x2925e1[_0xf930('0x35')]=_[_0xf930('0x36')](_0x2925e1[_0xf930('0x35')],{'$or':_[_0xf930('0x2a')](_0x28bdac,function(_0x5e3a4f){if(_0x5e3a4f[_0xf930('0x28')]!==_0xf930('0x37')){var _0x2ea6d6={};_0x2ea6d6[_0x5e3a4f['name']]={'$like':'%'+_0x2ee7b6[_0xf930('0x2b')][_0xf930('0x38')]+'%'};return _0x2ea6d6;}})});}_0x2925e1=_[_0xf930('0x36')]({},_0x2925e1,_0x2ee7b6[_0xf930('0x39')]);var _0x1c5378={'where':_0x2925e1[_0xf930('0x35')]};return db[_0xf930('0x25')][_0xf930('0x18')](_0x1c5378)[_0xf930('0x1e')](function(_0x2e5328){_0xe92c16[_0xf930('0x18')]=_0x2e5328;if(_0x2ee7b6[_0xf930('0x2b')]['includeAll']){_0x2925e1[_0xf930('0x3a')]=[{'all':!![]}];}return db[_0xf930('0x25')][_0xf930('0x3b')](_0x2925e1);})[_0xf930('0x1e')](function(_0x5726bb){_0xe92c16[_0xf930('0x3c')]=_0x5726bb;return _0xe92c16;})[_0xf930('0x1e')](respondWithFilteredResult(_0x504bf4,_0x2925e1))[_0xf930('0x3d')](handleError(_0x504bf4,null));};exports[_0xf930('0x3e')]=function(_0x27b829,_0x314bea){var _0x1dff74={'raw':!![],'where':{'id':_0x27b829[_0xf930('0x3f')]['id']}},_0x2ef89a={};_0x2ef89a['model']=_['keys'](db[_0xf930('0x25')]['rawAttributes']);_0x2ef89a[_0xf930('0x2b')]=_[_0xf930('0x2c')](_0x27b829[_0xf930('0x2b')]);_0x2ef89a[_0xf930('0x2d')]=_['intersection'](_0x2ef89a[_0xf930('0x29')],_0x2ef89a[_0xf930('0x2b')]);_0x1dff74['attributes']=_[_0xf930('0x2e')](_0x2ef89a['model'],qs[_0xf930('0x30')](_0x27b829['query'][_0xf930('0x30')]));_0x1dff74['attributes']=_0x1dff74[_0xf930('0x2f')][_0xf930('0x31')]?_0x1dff74[_0xf930('0x2f')]:_0x2ef89a[_0xf930('0x29')];if(_0x27b829[_0xf930('0x2b')][_0xf930('0x40')]){_0x1dff74['include']=[{'all':!![]}];}_0x1dff74=_[_0xf930('0x36')]({},_0x1dff74,_0x27b829['options']);return db['AnalyticMetric']['find'](_0x1dff74)['then'](handleEntityNotFound(_0x314bea,null))['then'](respondWithResult(_0x314bea,null))[_0xf930('0x3d')](handleError(_0x314bea,null));};exports[_0xf930('0x41')]=function(_0x4d2112,_0xfbdb1){return db[_0xf930('0x25')][_0xf930('0x41')](_0x4d2112['body'],{})[_0xf930('0x1e')](function(_0x41084f){var _0x3a0832=_0x4d2112['user'][_0xf930('0x42')]({'plain':!![]});if(!_0x3a0832)throw new Error(_0xf930('0x43'));if(_0x3a0832[_0xf930('0x44')]===_0xf930('0x45')){var _0xce2acb=_0x41084f[_0xf930('0x42')]({'plain':!![]});var _0x5021cd=_0xf930('0x46');return db[_0xf930('0x47')]['find']({'where':{'name':_0x5021cd,'userProfileId':_0x3a0832[_0xf930('0x48')]},'raw':!![]})[_0xf930('0x1e')](function(_0x214352){if(_0x214352&&_0x214352[_0xf930('0x49')]===0x0){return db[_0xf930('0x1f')][_0xf930('0x41')]({'name':_0xce2acb[_0xf930('0x22')],'resourceId':_0xce2acb['id'],'type':_0x214352[_0xf930('0x22')],'sectionId':_0x214352['id']},{})[_0xf930('0x1e')](function(){return _0x41084f;});}else{return _0x41084f;}})['catch'](function(_0x4d4894){logger[_0xf930('0x20')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4d4894);throw _0x4d4894;});}return _0x41084f;})[_0xf930('0x1e')](respondWithResult(_0xfbdb1,0xc9))[_0xf930('0x3d')](handleError(_0xfbdb1,null));};exports[_0xf930('0x4a')]=function(_0x36c76c,_0x1e0ffc){if(_0x36c76c[_0xf930('0x4b')]['id']){delete _0x36c76c[_0xf930('0x4b')]['id'];}return db[_0xf930('0x25')][_0xf930('0x4c')]({'where':{'id':_0x36c76c[_0xf930('0x3f')]['id']}})[_0xf930('0x1e')](handleEntityNotFound(_0x1e0ffc,null))[_0xf930('0x1e')](saveUpdates(_0x36c76c[_0xf930('0x4b')],null))[_0xf930('0x1e')](respondWithResult(_0x1e0ffc,null))[_0xf930('0x3d')](handleError(_0x1e0ffc,null));};exports[_0xf930('0x4d')]=function(_0x13bda4,_0xc80979){return db[_0xf930('0x25')][_0xf930('0x4c')]({'where':{'id':_0x13bda4['params']['id']}})[_0xf930('0x1e')](handleEntityNotFound(_0xc80979,null))[_0xf930('0x1e')](removeEntity(_0xc80979,null))['catch'](handleError(_0xc80979,null));};
\ No newline at end of file
+var _0x757a=['desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','end','status','json','offset','limit','Content-Range','apply','save','update','then','destroy','get','Metrics','UserProfileResource','error','name','AnalyticMetric','rawAttributes','fieldName','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','filter','where','merge','type','VIRTUAL','options','count','includeAll','findAll','rows','catch','params','include','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','eml-format','rimraf','moment','bluebird','mustache','util','path','sox','ejs','lodash','crypto','jsforce'];(function(_0x39096d,_0x51f8a0){var _0x13da4f=function(_0x11e6b2){while(--_0x11e6b2){_0x39096d['push'](_0x39096d['shift']());}};_0x13da4f(++_0x51f8a0);}(_0x757a,0xde));var _0xa757=function(_0x3e52ef,_0x1d3cf8){_0x3e52ef=_0x3e52ef-0x0;var _0x381742=_0x757a[_0x3e52ef];return _0x381742;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xa757('0x0'));var rimraf=require(_0xa757('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xa757('0x2'));var BPromise=require(_0xa757('0x3'));var Mustache=require(_0xa757('0x4'));var util=require(_0xa757('0x5'));var path=require(_0xa757('0x6'));var sox=require(_0xa757('0x7'));var csv=require('to-csv');var ejs=require(_0xa757('0x8'));var fs=require('fs');var _=require(_0xa757('0x9'));var squel=require('squel');var crypto=require(_0xa757('0xa'));var jsforce=require(_0xa757('0xb'));var deskjs=require(_0xa757('0xc'));var toCsv=require(_0xa757('0xd'));var querystring=require(_0xa757('0xe'));var Papa=require('papaparse');var Redis=require(_0xa757('0xf'));var authService=require(_0xa757('0x10'));var qs=require(_0xa757('0x11'));var as=require(_0xa757('0x12'));var hardwareService=require(_0xa757('0x13'));var logger=require(_0xa757('0x14'))(_0xa757('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x56acfb,_0x4db68e){_0x4db68e=_0x4db68e||0xcc;return function(_0x421040){if(_0x421040){return _0x56acfb['sendStatus'](_0x4db68e);}return _0x56acfb['status'](_0x4db68e)[_0xa757('0x16')]();};}function respondWithResult(_0x513b1f,_0x481508){_0x481508=_0x481508||0xc8;return function(_0x32112b){if(_0x32112b){return _0x513b1f[_0xa757('0x17')](_0x481508)[_0xa757('0x18')](_0x32112b);}};}function respondWithFilteredResult(_0x4a0c38,_0x86abd){return function(_0x31cfd2){if(_0x31cfd2){var _0xf12b68=_0x31cfd2['count'],_0x2f7947=_0x86abd[_0xa757('0x19')],_0x185011=_0x86abd[_0xa757('0x19')]+_0x86abd[_0xa757('0x1a')],_0x3df1f9;if(_0x185011>=_0xf12b68){_0x185011=_0xf12b68;_0x3df1f9=0xc8;}else{_0x3df1f9=0xce;}_0x4a0c38['status'](_0x3df1f9);return _0x4a0c38['set'](_0xa757('0x1b'),_0x2f7947+'-'+_0x185011+'/'+_0xf12b68)[_0xa757('0x18')](_0x31cfd2);}return null;};}function patchUpdates(_0x1bd14c){return function(_0x340599){try{jsonpatch[_0xa757('0x1c')](_0x340599,_0x1bd14c,!![]);}catch(_0xe2d567){return BPromise['reject'](_0xe2d567);}return _0x340599[_0xa757('0x1d')]();};}function saveUpdates(_0x4fec52,_0x32c2a1){return function(_0x167640){if(_0x167640){return _0x167640[_0xa757('0x1e')](_0x4fec52)[_0xa757('0x1f')](function(_0x4d598c){return _0x4d598c;});}return null;};}function removeEntity(_0x5638c7,_0x40ec48){return function(_0x2159cf){if(_0x2159cf){return _0x2159cf[_0xa757('0x20')]()[_0xa757('0x1f')](function(){var _0x1d6e2=_0x2159cf[_0xa757('0x21')]({'plain':!![]});var _0x2ca10d=_0xa757('0x22');return db[_0xa757('0x23')]['destroy']({'where':{'type':_0x2ca10d,'resourceId':_0x1d6e2['id']}})[_0xa757('0x1f')](function(){return _0x2159cf;});})['then'](function(){_0x5638c7[_0xa757('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x40551d,_0x3859ce){return function(_0x37c7e6){if(!_0x37c7e6){_0x40551d['sendStatus'](0x194);}return _0x37c7e6;};}function handleError(_0x2b19d5,_0xcd98bd){_0xcd98bd=_0xcd98bd||0x1f4;return function(_0x471e84){logger[_0xa757('0x24')](_0x471e84['stack']);if(_0x471e84[_0xa757('0x25')]){delete _0x471e84['name'];}_0x2b19d5['status'](_0xcd98bd)['send'](_0x471e84);};}exports['index']=function(_0xfdf69d,_0x596ae2){var _0x2208f9={},_0x3bc24c={},_0x55c5f8={'count':0x0,'rows':[]};var _0x2a0c9a=_['map'](db[_0xa757('0x26')][_0xa757('0x27')],function(_0x5307c3){return{'name':_0x5307c3[_0xa757('0x28')],'type':_0x5307c3['type'][_0xa757('0x29')]};});_0x3bc24c[_0xa757('0x2a')]=_[_0xa757('0x2b')](_0x2a0c9a,_0xa757('0x25'));_0x3bc24c[_0xa757('0x2c')]=_[_0xa757('0x2d')](_0xfdf69d[_0xa757('0x2c')]);_0x3bc24c[_0xa757('0x2e')]=_[_0xa757('0x2f')](_0x3bc24c[_0xa757('0x2a')],_0x3bc24c[_0xa757('0x2c')]);_0x2208f9[_0xa757('0x30')]=_[_0xa757('0x2f')](_0x3bc24c[_0xa757('0x2a')],qs[_0xa757('0x31')](_0xfdf69d[_0xa757('0x2c')][_0xa757('0x31')]));_0x2208f9[_0xa757('0x30')]=_0x2208f9[_0xa757('0x30')][_0xa757('0x32')]?_0x2208f9[_0xa757('0x30')]:_0x3bc24c[_0xa757('0x2a')];if(!_0xfdf69d[_0xa757('0x2c')][_0xa757('0x33')]('nolimit')){_0x2208f9[_0xa757('0x1a')]=qs[_0xa757('0x1a')](_0xfdf69d[_0xa757('0x2c')][_0xa757('0x1a')]);_0x2208f9[_0xa757('0x19')]=qs['offset'](_0xfdf69d[_0xa757('0x2c')][_0xa757('0x19')]);}_0x2208f9[_0xa757('0x34')]=qs[_0xa757('0x35')](_0xfdf69d[_0xa757('0x2c')][_0xa757('0x35')]);_0x2208f9['where']=qs[_0xa757('0x2e')](_[_0xa757('0x36')](_0xfdf69d[_0xa757('0x2c')],_0x3bc24c[_0xa757('0x2e')]),_0x2a0c9a);if(_0xfdf69d[_0xa757('0x2c')][_0xa757('0x37')]){_0x2208f9[_0xa757('0x38')]=_[_0xa757('0x39')](_0x2208f9[_0xa757('0x38')],{'$or':_['map'](_0x2a0c9a,function(_0x300be4){if(_0x300be4[_0xa757('0x3a')]!==_0xa757('0x3b')){var _0x35c15a={};_0x35c15a[_0x300be4[_0xa757('0x25')]]={'$like':'%'+_0xfdf69d[_0xa757('0x2c')]['filter']+'%'};return _0x35c15a;}})});}_0x2208f9=_[_0xa757('0x39')]({},_0x2208f9,_0xfdf69d[_0xa757('0x3c')]);var _0x48cde9={'where':_0x2208f9['where']};return db[_0xa757('0x26')][_0xa757('0x3d')](_0x48cde9)['then'](function(_0x51c3d1){_0x55c5f8[_0xa757('0x3d')]=_0x51c3d1;if(_0xfdf69d[_0xa757('0x2c')][_0xa757('0x3e')]){_0x2208f9['include']=[{'all':!![]}];}return db[_0xa757('0x26')][_0xa757('0x3f')](_0x2208f9);})[_0xa757('0x1f')](function(_0x1ba399){_0x55c5f8[_0xa757('0x40')]=_0x1ba399;return _0x55c5f8;})['then'](respondWithFilteredResult(_0x596ae2,_0x2208f9))[_0xa757('0x41')](handleError(_0x596ae2,null));};exports['show']=function(_0x564d40,_0x43329c){var _0x57298b={'raw':!![],'where':{'id':_0x564d40[_0xa757('0x42')]['id']}},_0x373747={};_0x373747[_0xa757('0x2a')]=_['keys'](db['AnalyticMetric'][_0xa757('0x27')]);_0x373747[_0xa757('0x2c')]=_[_0xa757('0x2d')](_0x564d40[_0xa757('0x2c')]);_0x373747[_0xa757('0x2e')]=_[_0xa757('0x2f')](_0x373747['model'],_0x373747[_0xa757('0x2c')]);_0x57298b[_0xa757('0x30')]=_['intersection'](_0x373747[_0xa757('0x2a')],qs['fields'](_0x564d40[_0xa757('0x2c')][_0xa757('0x31')]));_0x57298b['attributes']=_0x57298b[_0xa757('0x30')][_0xa757('0x32')]?_0x57298b['attributes']:_0x373747[_0xa757('0x2a')];if(_0x564d40[_0xa757('0x2c')][_0xa757('0x3e')]){_0x57298b[_0xa757('0x43')]=[{'all':!![]}];}_0x57298b=_['merge']({},_0x57298b,_0x564d40[_0xa757('0x3c')]);return db[_0xa757('0x26')][_0xa757('0x44')](_0x57298b)[_0xa757('0x1f')](handleEntityNotFound(_0x43329c,null))['then'](respondWithResult(_0x43329c,null))[_0xa757('0x41')](handleError(_0x43329c,null));};exports['create']=function(_0x50c131,_0x2acf88){return db[_0xa757('0x26')][_0xa757('0x45')](_0x50c131['body'],{})[_0xa757('0x1f')](function(_0x560c6c){var _0x2ed63f=_0x50c131[_0xa757('0x46')][_0xa757('0x21')]({'plain':!![]});if(!_0x2ed63f)throw new Error(_0xa757('0x47'));if(_0x2ed63f[_0xa757('0x48')]===_0xa757('0x46')){var _0x57bf73=_0x560c6c[_0xa757('0x21')]({'plain':!![]});var _0x581e95=_0xa757('0x22');return db[_0xa757('0x49')][_0xa757('0x44')]({'where':{'name':_0x581e95,'userProfileId':_0x2ed63f[_0xa757('0x4a')]},'raw':!![]})[_0xa757('0x1f')](function(_0x1f10cf){if(_0x1f10cf&&_0x1f10cf[_0xa757('0x4b')]===0x0){return db[_0xa757('0x23')][_0xa757('0x45')]({'name':_0x57bf73[_0xa757('0x25')],'resourceId':_0x57bf73['id'],'type':_0x1f10cf[_0xa757('0x25')],'sectionId':_0x1f10cf['id']},{})[_0xa757('0x1f')](function(){return _0x560c6c;});}else{return _0x560c6c;}})[_0xa757('0x41')](function(_0x354ad5){logger[_0xa757('0x24')](_0xa757('0x4c'),_0x354ad5);throw _0x354ad5;});}return _0x560c6c;})['then'](respondWithResult(_0x2acf88,0xc9))[_0xa757('0x41')](handleError(_0x2acf88,null));};exports['update']=function(_0x48af6e,_0x311c25){if(_0x48af6e[_0xa757('0x4d')]['id']){delete _0x48af6e[_0xa757('0x4d')]['id'];}return db['AnalyticMetric'][_0xa757('0x44')]({'where':{'id':_0x48af6e[_0xa757('0x42')]['id']}})[_0xa757('0x1f')](handleEntityNotFound(_0x311c25,null))[_0xa757('0x1f')](saveUpdates(_0x48af6e['body'],null))[_0xa757('0x1f')](respondWithResult(_0x311c25,null))[_0xa757('0x41')](handleError(_0x311c25,null));};exports[_0xa757('0x20')]=function(_0x1c9f1e,_0x33666d){return db[_0xa757('0x26')]['find']({'where':{'id':_0x1c9f1e['params']['id']}})['then'](handleEntityNotFound(_0x33666d,null))['then'](removeEntity(_0x33666d,null))[_0xa757('0x41')](handleError(_0x33666d,null));};
\ No newline at end of file