Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / analyticMetric / analyticMetric.controller.js
index b0eb428..c9de0a8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf021=['crypto','jsforce','desk.js','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','undefined','offset','limit','reject','save','update','then','Metrics','end','error','stack','send','render','merge','body','contact','message','agent','account','rawAttributes','type','model','name','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','map','options','count','includeAll','include','AnalyticMetric','findAll','catch','params','keys','find','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','ejs','lodash','squel'];(function(_0x1fed62,_0x226377){var _0x17a4b3=function(_0x5df534){while(--_0x5df534){_0x1fed62['push'](_0x1fed62['shift']());}};_0x17a4b3(++_0x226377);}(_0xf021,0x18f));var _0x1f02=function(_0x305a6e,_0x1f4a40){_0x305a6e=_0x305a6e-0x0;var _0xd23128=_0xf021[_0x305a6e];return _0xd23128;};'use strict';var emlformat=require(_0x1f02('0x0'));var rimraf=require(_0x1f02('0x1'));var zipdir=require(_0x1f02('0x2'));var jsonpatch=require(_0x1f02('0x3'));var rp=require(_0x1f02('0x4'));var moment=require('moment');var BPromise=require(_0x1f02('0x5'));var Mustache=require('mustache');var util=require(_0x1f02('0x6'));var path=require(_0x1f02('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x1f02('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x1f02('0x9'));var squel=require(_0x1f02('0xa'));var crypto=require(_0x1f02('0xb'));var jsforce=require(_0x1f02('0xc'));var deskjs=require(_0x1f02('0xd'));var toCsv=require('to-csv');var querystring=require(_0x1f02('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x1f02('0xf'));var as=require(_0x1f02('0x10'));var hardwareService=require(_0x1f02('0x11'));var logger=require(_0x1f02('0x12'))(_0x1f02('0x13'));var utils=require('../../config/utils');var config=require(_0x1f02('0x14'));var licenseUtil=require(_0x1f02('0x15'));var db=require(_0x1f02('0x16'))['db'];function respondWithStatusCode(_0x56a2c2,_0x24e9b8){_0x24e9b8=_0x24e9b8||0xcc;return function(_0x1ac6eb){if(_0x1ac6eb){return _0x56a2c2[_0x1f02('0x17')](_0x24e9b8);}return _0x56a2c2['status'](_0x24e9b8)['end']();};}function respondWithResult(_0x4974bd,_0x11ba7e){_0x11ba7e=_0x11ba7e||0xc8;return function(_0x2c08ad){if(_0x2c08ad){return _0x4974bd[_0x1f02('0x18')](_0x11ba7e)[_0x1f02('0x19')](_0x2c08ad);}};}function respondWithFilteredResult(_0x1c16ce,_0x45bae1){return function(_0x440328){if(_0x440328){var _0x3b0a3d=typeof _0x45bae1['offset']===_0x1f02('0x1a')&&typeof _0x45bae1['limit']==='undefined';var _0x4a66a5=_0x440328['count'];var _0x4d1e4f=_0x3b0a3d?0x0:_0x45bae1[_0x1f02('0x1b')];var _0x3033a2=_0x3b0a3d?_0x440328['count']:_0x45bae1[_0x1f02('0x1b')]+_0x45bae1[_0x1f02('0x1c')];var _0x356444;if(_0x3033a2>=_0x4a66a5){_0x3033a2=_0x4a66a5;_0x356444=0xc8;}else{_0x356444=0xce;}_0x1c16ce[_0x1f02('0x18')](_0x356444);return _0x1c16ce['set']('Content-Range',_0x4d1e4f+'-'+_0x3033a2+'/'+_0x4a66a5)[_0x1f02('0x19')](_0x440328);}return null;};}function patchUpdates(_0x37393a){return function(_0x5e78c2){try{jsonpatch['apply'](_0x5e78c2,_0x37393a,!![]);}catch(_0x339c29){return BPromise[_0x1f02('0x1d')](_0x339c29);}return _0x5e78c2[_0x1f02('0x1e')]();};}function saveUpdates(_0xbabbd7,_0x480297){return function(_0x12c4af){if(_0x12c4af){return _0x12c4af[_0x1f02('0x1f')](_0xbabbd7)[_0x1f02('0x20')](function(_0x2f422c){return _0x2f422c;});}return null;};}function removeEntity(_0x43b3e7,_0x134398){return function(_0x1328ea){if(_0x1328ea){return _0x1328ea['destroy']()[_0x1f02('0x20')](function(){var _0x3a8c57=_0x1328ea['get']({'plain':!![]});var _0x25a8d1=_0x1f02('0x21');return db['UserProfileResource']['destroy']({'where':{'type':_0x25a8d1,'resourceId':_0x3a8c57['id']}})[_0x1f02('0x20')](function(){return _0x1328ea;});})[_0x1f02('0x20')](function(){_0x43b3e7[_0x1f02('0x18')](0xcc)[_0x1f02('0x22')]();});}};}function handleEntityNotFound(_0x3f5c5e,_0x3f5577){return function(_0x297cf4){if(!_0x297cf4){_0x3f5c5e['sendStatus'](0x194);}return _0x297cf4;};}function handleError(_0x4d5f7e,_0x4e04f2){_0x4e04f2=_0x4e04f2||0x1f4;return function(_0x3ef4bf){logger[_0x1f02('0x23')](_0x3ef4bf[_0x1f02('0x24')]);if(_0x3ef4bf['name']){delete _0x3ef4bf['name'];}_0x4d5f7e[_0x1f02('0x18')](_0x4e04f2)[_0x1f02('0x25')](_0x3ef4bf);};}function getMustacheRender(_0x1605cf,_0x433a1e){return Mustache[_0x1f02('0x26')](_0x1605cf,_[_0x1f02('0x27')](_0x433a1e[_0x1f02('0x28')],{'contact':_0x433a1e[_0x1f02('0x29')],'message':_0x433a1e[_0x1f02('0x2a')],'agent':_0x433a1e[_0x1f02('0x2b')],'interaction':_0x433a1e['interaction'],'account':_0x433a1e[_0x1f02('0x2c')]}))||'';}exports['index']=function(_0xa61d8f,_0x3b3b57){var _0x8a3f1e={},_0x2bf78e={},_0x28a572={'count':0x0,'rows':[]};var _0x194c85=_['map'](db['AnalyticMetric'][_0x1f02('0x2d')],function(_0x15e655){return{'name':_0x15e655['fieldName'],'type':_0x15e655[_0x1f02('0x2e')]['key']};});_0x2bf78e[_0x1f02('0x2f')]=_['map'](_0x194c85,_0x1f02('0x30'));_0x2bf78e['query']=_['keys'](_0xa61d8f[_0x1f02('0x31')]);_0x2bf78e[_0x1f02('0x32')]=_[_0x1f02('0x33')](_0x2bf78e[_0x1f02('0x2f')],_0x2bf78e['query']);_0x8a3f1e[_0x1f02('0x34')]=_[_0x1f02('0x33')](_0x2bf78e[_0x1f02('0x2f')],qs['fields'](_0xa61d8f[_0x1f02('0x31')][_0x1f02('0x35')]));_0x8a3f1e[_0x1f02('0x34')]=_0x8a3f1e[_0x1f02('0x34')][_0x1f02('0x36')]?_0x8a3f1e[_0x1f02('0x34')]:_0x2bf78e['model'];if(!_0xa61d8f[_0x1f02('0x31')][_0x1f02('0x37')](_0x1f02('0x38'))){_0x8a3f1e['limit']=qs[_0x1f02('0x1c')](_0xa61d8f['query'][_0x1f02('0x1c')]);_0x8a3f1e['offset']=qs['offset'](_0xa61d8f[_0x1f02('0x31')]['offset']);}_0x8a3f1e['order']=qs[_0x1f02('0x39')](_0xa61d8f[_0x1f02('0x31')][_0x1f02('0x39')]);_0x8a3f1e[_0x1f02('0x3a')]=qs['filters'](_[_0x1f02('0x3b')](_0xa61d8f['query'],_0x2bf78e[_0x1f02('0x32')]),_0x194c85);if(_0xa61d8f[_0x1f02('0x31')][_0x1f02('0x3c')]){_0x8a3f1e[_0x1f02('0x3a')]=_[_0x1f02('0x27')](_0x8a3f1e[_0x1f02('0x3a')],{'$or':_[_0x1f02('0x3d')](_0x194c85,function(_0xffa05b){if(_0xffa05b[_0x1f02('0x2e')]!=='VIRTUAL'){var _0x31ca4d={};_0x31ca4d[_0xffa05b['name']]={'$like':'%'+_0xa61d8f[_0x1f02('0x31')]['filter']+'%'};return _0x31ca4d;}})});}_0x8a3f1e=_[_0x1f02('0x27')]({},_0x8a3f1e,_0xa61d8f[_0x1f02('0x3e')]);var _0x1c7182={'where':_0x8a3f1e['where']};return db['AnalyticMetric'][_0x1f02('0x3f')](_0x1c7182)[_0x1f02('0x20')](function(_0x37d6b5){_0x28a572[_0x1f02('0x3f')]=_0x37d6b5;if(_0xa61d8f[_0x1f02('0x31')][_0x1f02('0x40')]){_0x8a3f1e[_0x1f02('0x41')]=[{'all':!![]}];}return db[_0x1f02('0x42')][_0x1f02('0x43')](_0x8a3f1e);})['then'](function(_0x3202d8){_0x28a572['rows']=_0x3202d8;return _0x28a572;})['then'](respondWithFilteredResult(_0x3b3b57,_0x8a3f1e))[_0x1f02('0x44')](handleError(_0x3b3b57,null));};exports['show']=function(_0x584d9c,_0xe61000){var _0x55ad2b={'raw':!![],'where':{'id':_0x584d9c[_0x1f02('0x45')]['id']}},_0x4be37b={};_0x4be37b[_0x1f02('0x2f')]=_['keys'](db[_0x1f02('0x42')][_0x1f02('0x2d')]);_0x4be37b[_0x1f02('0x31')]=_[_0x1f02('0x46')](_0x584d9c['query']);_0x4be37b[_0x1f02('0x32')]=_[_0x1f02('0x33')](_0x4be37b[_0x1f02('0x2f')],_0x4be37b[_0x1f02('0x31')]);_0x55ad2b[_0x1f02('0x34')]=_[_0x1f02('0x33')](_0x4be37b[_0x1f02('0x2f')],qs[_0x1f02('0x35')](_0x584d9c[_0x1f02('0x31')][_0x1f02('0x35')]));_0x55ad2b[_0x1f02('0x34')]=_0x55ad2b[_0x1f02('0x34')][_0x1f02('0x36')]?_0x55ad2b[_0x1f02('0x34')]:_0x4be37b['model'];if(_0x584d9c[_0x1f02('0x31')]['includeAll']){_0x55ad2b[_0x1f02('0x41')]=[{'all':!![]}];}_0x55ad2b=_['merge']({},_0x55ad2b,_0x584d9c[_0x1f02('0x3e')]);return db[_0x1f02('0x42')][_0x1f02('0x47')](_0x55ad2b)[_0x1f02('0x20')](handleEntityNotFound(_0xe61000,null))[_0x1f02('0x20')](respondWithResult(_0xe61000,null))[_0x1f02('0x44')](handleError(_0xe61000,null));};exports[_0x1f02('0x48')]=function(_0x2178b2,_0x8eae3){return db[_0x1f02('0x42')][_0x1f02('0x48')](_0x2178b2['body'],{})[_0x1f02('0x20')](function(_0x297957){var _0x3f3e7c=_0x2178b2[_0x1f02('0x49')][_0x1f02('0x4a')]({'plain':!![]});if(!_0x3f3e7c)throw new Error(_0x1f02('0x4b'));if(_0x3f3e7c[_0x1f02('0x4c')]===_0x1f02('0x49')){var _0x15cd89=_0x297957['get']({'plain':!![]});var _0xa0b579=_0x1f02('0x21');return db[_0x1f02('0x4d')][_0x1f02('0x47')]({'where':{'name':_0xa0b579,'userProfileId':_0x3f3e7c[_0x1f02('0x4e')]},'raw':!![]})['then'](function(_0x12c1fb){if(_0x12c1fb&&_0x12c1fb['autoAssociation']===0x0){return db[_0x1f02('0x4f')][_0x1f02('0x48')]({'name':_0x15cd89[_0x1f02('0x30')],'resourceId':_0x15cd89['id'],'type':_0x12c1fb[_0x1f02('0x30')],'sectionId':_0x12c1fb['id']},{})[_0x1f02('0x20')](function(){return _0x297957;});}else{return _0x297957;}})[_0x1f02('0x44')](function(_0x41b024){logger[_0x1f02('0x23')](_0x1f02('0x50'),_0x41b024);throw _0x41b024;});}return _0x297957;})[_0x1f02('0x20')](respondWithResult(_0x8eae3,0xc9))['catch'](handleError(_0x8eae3,null));};exports['update']=function(_0x4d084c,_0x39dbee){if(_0x4d084c['body']['id']){delete _0x4d084c[_0x1f02('0x28')]['id'];}return db[_0x1f02('0x42')]['find']({'where':{'id':_0x4d084c[_0x1f02('0x45')]['id']}})['then'](handleEntityNotFound(_0x39dbee,null))['then'](saveUpdates(_0x4d084c['body'],null))[_0x1f02('0x20')](respondWithResult(_0x39dbee,null))[_0x1f02('0x44')](handleError(_0x39dbee,null));};exports[_0x1f02('0x51')]=function(_0x390df6,_0xbb603){return db[_0x1f02('0x42')]['find']({'where':{'id':_0x390df6[_0x1f02('0x45')]['id']}})[_0x1f02('0x20')](handleEntityNotFound(_0xbb603,null))['then'](removeEntity(_0xbb603,null))['catch'](handleError(_0xbb603,null));};
\ No newline at end of file
+var _0xbc8b=['params','find','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','status','json','offset','undefined','limit','count','set','apply','reject','save','update','then','destroy','Metrics','UserProfileResource','end','sendStatus','error','name','send','render','merge','body','agent','interaction','account','map','AnalyticMetric','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','where','pick','VIRTUAL','filter','options','includeAll','include','findAll','catch','show'];(function(_0xd57444,_0x571c38){var _0x2ab09f=function(_0x4bf78c){while(--_0x4bf78c){_0xd57444['push'](_0xd57444['shift']());}};_0x2ab09f(++_0x571c38);}(_0xbc8b,0x16b));var _0xbbc8=function(_0x1b5a05,_0x2c80de){_0x1b5a05=_0x1b5a05-0x0;var _0x347931=_0xbc8b[_0x1b5a05];return _0x347931;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xbbc8('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xbbc8('0x1'));var rp=require(_0xbbc8('0x2'));var moment=require(_0xbbc8('0x3'));var BPromise=require(_0xbbc8('0x4'));var Mustache=require(_0xbbc8('0x5'));var util=require(_0xbbc8('0x6'));var path=require('path');var sox=require(_0xbbc8('0x7'));var csv=require(_0xbbc8('0x8'));var ejs=require(_0xbbc8('0x9'));var fs=require('fs');var fs_extra=require(_0xbbc8('0xa'));var _=require(_0xbbc8('0xb'));var squel=require('squel');var crypto=require(_0xbbc8('0xc'));var jsforce=require(_0xbbc8('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xbbc8('0x8'));var querystring=require(_0xbbc8('0xe'));var Papa=require(_0xbbc8('0xf'));var Redis=require(_0xbbc8('0x10'));var authService=require(_0xbbc8('0x11'));var qs=require(_0xbbc8('0x12'));var as=require(_0xbbc8('0x13'));var hardwareService=require(_0xbbc8('0x14'));var logger=require(_0xbbc8('0x15'))(_0xbbc8('0x16'));var utils=require(_0xbbc8('0x17'));var config=require(_0xbbc8('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xbbc8('0x19'))['db'];function respondWithStatusCode(_0xc702ca,_0x1c4b00){_0x1c4b00=_0x1c4b00||0xcc;return function(_0x55b386){if(_0x55b386){return _0xc702ca['sendStatus'](_0x1c4b00);}return _0xc702ca[_0xbbc8('0x1a')](_0x1c4b00)['end']();};}function respondWithResult(_0x290045,_0x2add43){_0x2add43=_0x2add43||0xc8;return function(_0x1c76df){if(_0x1c76df){return _0x290045[_0xbbc8('0x1a')](_0x2add43)[_0xbbc8('0x1b')](_0x1c76df);}};}function respondWithFilteredResult(_0x1e9c27,_0x292cc2){return function(_0x1cd58e){if(_0x1cd58e){var _0x38bf2f=typeof _0x292cc2[_0xbbc8('0x1c')]===_0xbbc8('0x1d')&&typeof _0x292cc2[_0xbbc8('0x1e')]===_0xbbc8('0x1d');var _0x21a44b=_0x1cd58e['count'];var _0xc9a328=_0x38bf2f?0x0:_0x292cc2[_0xbbc8('0x1c')];var _0x38e642=_0x38bf2f?_0x1cd58e[_0xbbc8('0x1f')]:_0x292cc2['offset']+_0x292cc2[_0xbbc8('0x1e')];var _0x4f754f;if(_0x38e642>=_0x21a44b){_0x38e642=_0x21a44b;_0x4f754f=0xc8;}else{_0x4f754f=0xce;}_0x1e9c27[_0xbbc8('0x1a')](_0x4f754f);return _0x1e9c27[_0xbbc8('0x20')]('Content-Range',_0xc9a328+'-'+_0x38e642+'/'+_0x21a44b)[_0xbbc8('0x1b')](_0x1cd58e);}return null;};}function patchUpdates(_0x1f7576){return function(_0x14b069){try{jsonpatch[_0xbbc8('0x21')](_0x14b069,_0x1f7576,!![]);}catch(_0x1ec180){return BPromise[_0xbbc8('0x22')](_0x1ec180);}return _0x14b069[_0xbbc8('0x23')]();};}function saveUpdates(_0x58d198,_0x14af5b){return function(_0x5a1e00){if(_0x5a1e00){return _0x5a1e00[_0xbbc8('0x24')](_0x58d198)[_0xbbc8('0x25')](function(_0x3f22f2){return _0x3f22f2;});}return null;};}function removeEntity(_0x37acb1,_0x354312){return function(_0x521c11){if(_0x521c11){return _0x521c11[_0xbbc8('0x26')]()[_0xbbc8('0x25')](function(){var _0x572940=_0x521c11['get']({'plain':!![]});var _0x4fba6e=_0xbbc8('0x27');return db[_0xbbc8('0x28')][_0xbbc8('0x26')]({'where':{'type':_0x4fba6e,'resourceId':_0x572940['id']}})[_0xbbc8('0x25')](function(){return _0x521c11;});})[_0xbbc8('0x25')](function(){_0x37acb1[_0xbbc8('0x1a')](0xcc)[_0xbbc8('0x29')]();});}};}function handleEntityNotFound(_0xb8bea0,_0x5bf78e){return function(_0x226028){if(!_0x226028){_0xb8bea0[_0xbbc8('0x2a')](0x194);}return _0x226028;};}function handleError(_0x2e7060,_0x50f61d){_0x50f61d=_0x50f61d||0x1f4;return function(_0x186572){logger[_0xbbc8('0x2b')](_0x186572['stack']);if(_0x186572[_0xbbc8('0x2c')]){delete _0x186572['name'];}_0x2e7060['status'](_0x50f61d)[_0xbbc8('0x2d')](_0x186572);};}function getMustacheRender(_0x34a8f1,_0xec7e05){return Mustache[_0xbbc8('0x2e')](_0x34a8f1,_[_0xbbc8('0x2f')](_0xec7e05[_0xbbc8('0x30')],{'contact':_0xec7e05['contact'],'message':_0xec7e05['message'],'agent':_0xec7e05[_0xbbc8('0x31')],'interaction':_0xec7e05[_0xbbc8('0x32')],'account':_0xec7e05[_0xbbc8('0x33')]}))||'';}exports['index']=function(_0x296cfc,_0x2db1ea){var _0x42a658={},_0x361d6a={},_0x2a4061={'count':0x0,'rows':[]};var _0x243dad=_[_0xbbc8('0x34')](db[_0xbbc8('0x35')][_0xbbc8('0x36')],function(_0x14eb32){return{'name':_0x14eb32[_0xbbc8('0x37')],'type':_0x14eb32['type'][_0xbbc8('0x38')]};});_0x361d6a[_0xbbc8('0x39')]=_[_0xbbc8('0x34')](_0x243dad,_0xbbc8('0x2c'));_0x361d6a[_0xbbc8('0x3a')]=_[_0xbbc8('0x3b')](_0x296cfc[_0xbbc8('0x3a')]);_0x361d6a[_0xbbc8('0x3c')]=_[_0xbbc8('0x3d')](_0x361d6a[_0xbbc8('0x39')],_0x361d6a['query']);_0x42a658[_0xbbc8('0x3e')]=_[_0xbbc8('0x3d')](_0x361d6a[_0xbbc8('0x39')],qs[_0xbbc8('0x3f')](_0x296cfc[_0xbbc8('0x3a')][_0xbbc8('0x3f')]));_0x42a658['attributes']=_0x42a658[_0xbbc8('0x3e')][_0xbbc8('0x40')]?_0x42a658[_0xbbc8('0x3e')]:_0x361d6a[_0xbbc8('0x39')];if(!_0x296cfc['query'][_0xbbc8('0x41')](_0xbbc8('0x42'))){_0x42a658[_0xbbc8('0x1e')]=qs[_0xbbc8('0x1e')](_0x296cfc[_0xbbc8('0x3a')]['limit']);_0x42a658[_0xbbc8('0x1c')]=qs[_0xbbc8('0x1c')](_0x296cfc[_0xbbc8('0x3a')][_0xbbc8('0x1c')]);}_0x42a658['order']=qs['sort'](_0x296cfc[_0xbbc8('0x3a')]['sort']);_0x42a658[_0xbbc8('0x43')]=qs[_0xbbc8('0x3c')](_[_0xbbc8('0x44')](_0x296cfc['query'],_0x361d6a[_0xbbc8('0x3c')]),_0x243dad);if(_0x296cfc['query']['filter']){_0x42a658[_0xbbc8('0x43')]=_[_0xbbc8('0x2f')](_0x42a658['where'],{'$or':_[_0xbbc8('0x34')](_0x243dad,function(_0x19580a){if(_0x19580a['type']!==_0xbbc8('0x45')){var _0x2abe67={};_0x2abe67[_0x19580a[_0xbbc8('0x2c')]]={'$like':'%'+_0x296cfc['query'][_0xbbc8('0x46')]+'%'};return _0x2abe67;}})});}_0x42a658=_[_0xbbc8('0x2f')]({},_0x42a658,_0x296cfc[_0xbbc8('0x47')]);var _0x4852a4={'where':_0x42a658[_0xbbc8('0x43')]};return db[_0xbbc8('0x35')][_0xbbc8('0x1f')](_0x4852a4)[_0xbbc8('0x25')](function(_0xdf92){_0x2a4061[_0xbbc8('0x1f')]=_0xdf92;if(_0x296cfc['query'][_0xbbc8('0x48')]){_0x42a658[_0xbbc8('0x49')]=[{'all':!![]}];}return db['AnalyticMetric'][_0xbbc8('0x4a')](_0x42a658);})[_0xbbc8('0x25')](function(_0x243321){_0x2a4061['rows']=_0x243321;return _0x2a4061;})[_0xbbc8('0x25')](respondWithFilteredResult(_0x2db1ea,_0x42a658))[_0xbbc8('0x4b')](handleError(_0x2db1ea,null));};exports[_0xbbc8('0x4c')]=function(_0x5a89be,_0x1ae7db){var _0x5763f7={'raw':!![],'where':{'id':_0x5a89be[_0xbbc8('0x4d')]['id']}},_0x38f338={};_0x38f338[_0xbbc8('0x39')]=_['keys'](db[_0xbbc8('0x35')][_0xbbc8('0x36')]);_0x38f338[_0xbbc8('0x3a')]=_['keys'](_0x5a89be[_0xbbc8('0x3a')]);_0x38f338[_0xbbc8('0x3c')]=_[_0xbbc8('0x3d')](_0x38f338[_0xbbc8('0x39')],_0x38f338[_0xbbc8('0x3a')]);_0x5763f7['attributes']=_[_0xbbc8('0x3d')](_0x38f338['model'],qs[_0xbbc8('0x3f')](_0x5a89be[_0xbbc8('0x3a')]['fields']));_0x5763f7['attributes']=_0x5763f7[_0xbbc8('0x3e')]['length']?_0x5763f7[_0xbbc8('0x3e')]:_0x38f338[_0xbbc8('0x39')];if(_0x5a89be[_0xbbc8('0x3a')][_0xbbc8('0x48')]){_0x5763f7[_0xbbc8('0x49')]=[{'all':!![]}];}_0x5763f7=_[_0xbbc8('0x2f')]({},_0x5763f7,_0x5a89be[_0xbbc8('0x47')]);return db['AnalyticMetric'][_0xbbc8('0x4e')](_0x5763f7)[_0xbbc8('0x25')](handleEntityNotFound(_0x1ae7db,null))['then'](respondWithResult(_0x1ae7db,null))['catch'](handleError(_0x1ae7db,null));};exports[_0xbbc8('0x4f')]=function(_0x4bd7dd,_0x1556e){return db[_0xbbc8('0x35')][_0xbbc8('0x4f')](_0x4bd7dd[_0xbbc8('0x30')],{})[_0xbbc8('0x25')](function(_0x1efc2f){var _0xc0feec=_0x4bd7dd[_0xbbc8('0x50')][_0xbbc8('0x51')]({'plain':!![]});if(!_0xc0feec)throw new Error(_0xbbc8('0x52'));if(_0xc0feec[_0xbbc8('0x53')]==='user'){var _0x44510b=_0x1efc2f[_0xbbc8('0x51')]({'plain':!![]});var _0x241b89=_0xbbc8('0x27');return db[_0xbbc8('0x54')][_0xbbc8('0x4e')]({'where':{'name':_0x241b89,'userProfileId':_0xc0feec[_0xbbc8('0x55')]},'raw':!![]})[_0xbbc8('0x25')](function(_0x52d5a2){if(_0x52d5a2&&_0x52d5a2[_0xbbc8('0x56')]===0x0){return db[_0xbbc8('0x28')][_0xbbc8('0x4f')]({'name':_0x44510b[_0xbbc8('0x2c')],'resourceId':_0x44510b['id'],'type':_0x52d5a2[_0xbbc8('0x2c')],'sectionId':_0x52d5a2['id']},{})['then'](function(){return _0x1efc2f;});}else{return _0x1efc2f;}})[_0xbbc8('0x4b')](function(_0x489ad3){logger[_0xbbc8('0x2b')](_0xbbc8('0x57'),_0x489ad3);throw _0x489ad3;});}return _0x1efc2f;})[_0xbbc8('0x25')](respondWithResult(_0x1556e,0xc9))['catch'](handleError(_0x1556e,null));};exports[_0xbbc8('0x24')]=function(_0x56e79f,_0x27dfb0){if(_0x56e79f['body']['id']){delete _0x56e79f[_0xbbc8('0x30')]['id'];}return db[_0xbbc8('0x35')][_0xbbc8('0x4e')]({'where':{'id':_0x56e79f[_0xbbc8('0x4d')]['id']}})[_0xbbc8('0x25')](handleEntityNotFound(_0x27dfb0,null))[_0xbbc8('0x25')](saveUpdates(_0x56e79f[_0xbbc8('0x30')],null))[_0xbbc8('0x25')](respondWithResult(_0x27dfb0,null))[_0xbbc8('0x4b')](handleError(_0x27dfb0,null));};exports[_0xbbc8('0x26')]=function(_0x4a5db5,_0x24add2){return db['AnalyticMetric']['find']({'where':{'id':_0x4a5db5[_0xbbc8('0x4d')]['id']}})[_0xbbc8('0x25')](handleEntityNotFound(_0x24add2,null))[_0xbbc8('0x25')](removeEntity(_0x24add2,null))[_0xbbc8('0x4b')](handleError(_0x24add2,null));};
\ No newline at end of file