Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / dashboard / dashboard.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xf89f=['papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./dashboard.socket','register','end','json','count','offset','limit','set','apply','reject','save','update','then','get','CustomDashboards','sendStatus','error','name','status','send','index','Dashboard','rawAttributes','fieldName','type','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','findAll','rows','catch','show','params','include','create','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','destroy','iframe','attrUrl','attrs','value','attrPath','clock','attrHourFormat','attrTimezone','attrFontSize','attrMetric','total','attrVoiceQueues','attrSerie1','attrSerie2','attrSerie3','web-report','attrReport','reportType','stringify','addItem','DashboardId','DashboardItem','getItems','findOne','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0xf89f,0x158));var _0xff89=function(_0x17a2b5,_0x239133){_0x17a2b5=_0x17a2b5-0x0;var _0x1be2a0=_0xf89f[_0x17a2b5];return _0x1be2a0;};'use strict';var pdf=require(_0xff89('0x0'));var emlformat=require(_0xff89('0x1'));var rimraf=require(_0xff89('0x2'));var zipdir=require(_0xff89('0x3'));var jsonpatch=require(_0xff89('0x4'));var rp=require(_0xff89('0x5'));var moment=require(_0xff89('0x6'));var BPromise=require(_0xff89('0x7'));var Mustache=require(_0xff89('0x8'));var util=require(_0xff89('0x9'));var path=require(_0xff89('0xa'));var sox=require(_0xff89('0xb'));var csv=require(_0xff89('0xc'));var ejs=require(_0xff89('0xd'));var fs=require('fs');var _=require(_0xff89('0xe'));var squel=require(_0xff89('0xf'));var crypto=require(_0xff89('0x10'));var jsforce=require(_0xff89('0x11'));var deskjs=require(_0xff89('0x12'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xff89('0x13'));var Redis=require(_0xff89('0x14'));var authService=require('../../components/auth/service');var qs=require(_0xff89('0x15'));var as=require(_0xff89('0x16'));var hardwareService=require(_0xff89('0x17'));var logger=require('../../config/logger')(_0xff89('0x18'));var utils=require(_0xff89('0x19'));var config=require('../../config/environment');var db=require(_0xff89('0x1a'))['db'];config[_0xff89('0x1b')]=_[_0xff89('0x1c')](config['redis'],{'host':_0xff89('0x1d'),'port':0x18eb});var socket=require(_0xff89('0x1e'))(new Redis(config[_0xff89('0x1b')]));require(_0xff89('0x1f'))[_0xff89('0x20')](socket);function respondWithStatusCode(_0x2a57c4,_0x4ab415){_0x4ab415=_0x4ab415||0xcc;return function(_0x368a97){if(_0x368a97){return _0x2a57c4['sendStatus'](_0x4ab415);}return _0x2a57c4['status'](_0x4ab415)[_0xff89('0x21')]();};}function respondWithResult(_0x253919,_0x1246e2){_0x1246e2=_0x1246e2||0xc8;return function(_0x52f554){if(_0x52f554){return _0x253919['status'](_0x1246e2)[_0xff89('0x22')](_0x52f554);}};}function respondWithFilteredResult(_0x466213,_0x3988ee){return function(_0x168586){if(_0x168586){var _0x43450b=_0x168586[_0xff89('0x23')],_0x274a00=_0x3988ee[_0xff89('0x24')],_0x21533b=_0x3988ee[_0xff89('0x24')]+_0x3988ee[_0xff89('0x25')],_0x211e63;if(_0x21533b>=_0x43450b){_0x21533b=_0x43450b;_0x211e63=0xc8;}else{_0x211e63=0xce;}_0x466213['status'](_0x211e63);return _0x466213[_0xff89('0x26')]('Content-Range',_0x274a00+'-'+_0x21533b+'/'+_0x43450b)[_0xff89('0x22')](_0x168586);}return null;};}function patchUpdates(_0x126f83){return function(_0xd08dcb){try{jsonpatch[_0xff89('0x27')](_0xd08dcb,_0x126f83,!![]);}catch(_0x1abcb8){return BPromise[_0xff89('0x28')](_0x1abcb8);}return _0xd08dcb[_0xff89('0x29')]();};}function saveUpdates(_0x41b676,_0x151b47){return function(_0x5cfbd6){if(_0x5cfbd6){return _0x5cfbd6[_0xff89('0x2a')](_0x41b676)[_0xff89('0x2b')](function(_0xe0f92e){return _0xe0f92e;});}return null;};}function removeEntity(_0x5e8725,_0xa1355c){return function(_0x3f549f){if(_0x3f549f){return _0x3f549f['destroy']()[_0xff89('0x2b')](function(){var _0x36e852=_0x3f549f[_0xff89('0x2c')]({'plain':!![]});var _0x1395eb=_0xff89('0x2d');return db['UserProfileResource']['destroy']({'where':{'type':_0x1395eb,'resourceId':_0x36e852['id']}})[_0xff89('0x2b')](function(){return _0x3f549f;});})[_0xff89('0x2b')](function(){_0x5e8725['status'](0xcc)[_0xff89('0x21')]();});}};}function handleEntityNotFound(_0x5b3221,_0x802333){return function(_0x15a807){if(!_0x15a807){_0x5b3221[_0xff89('0x2e')](0x194);}return _0x15a807;};}function handleError(_0x543cd3,_0x208d4b){_0x208d4b=_0x208d4b||0x1f4;return function(_0x1bd64f){logger[_0xff89('0x2f')](_0x1bd64f['stack']);if(_0x1bd64f[_0xff89('0x30')]){delete _0x1bd64f[_0xff89('0x30')];}_0x543cd3[_0xff89('0x31')](_0x208d4b)[_0xff89('0x32')](_0x1bd64f);};}exports[_0xff89('0x33')]=function(_0x203161,_0x2e5751){var _0x56bf28={},_0x3389b8={},_0x5f28ca={'count':0x0,'rows':[]};var _0x3d0f01=_['map'](db[_0xff89('0x34')][_0xff89('0x35')],function(_0xbc4aa6){return{'name':_0xbc4aa6[_0xff89('0x36')],'type':_0xbc4aa6[_0xff89('0x37')]['key']};});_0x3389b8[_0xff89('0x38')]=_[_0xff89('0x39')](_0x3d0f01,_0xff89('0x30'));_0x3389b8[_0xff89('0x3a')]=_[_0xff89('0x3b')](_0x203161[_0xff89('0x3a')]);_0x3389b8[_0xff89('0x3c')]=_[_0xff89('0x3d')](_0x3389b8[_0xff89('0x38')],_0x3389b8[_0xff89('0x3a')]);_0x56bf28[_0xff89('0x3e')]=_['intersection'](_0x3389b8[_0xff89('0x38')],qs['fields'](_0x203161[_0xff89('0x3a')][_0xff89('0x3f')]));_0x56bf28[_0xff89('0x3e')]=_0x56bf28[_0xff89('0x3e')][_0xff89('0x40')]?_0x56bf28['attributes']:_0x3389b8['model'];if(!_0x203161[_0xff89('0x3a')][_0xff89('0x41')](_0xff89('0x42'))){_0x56bf28[_0xff89('0x25')]=qs[_0xff89('0x25')](_0x203161[_0xff89('0x3a')][_0xff89('0x25')]);_0x56bf28[_0xff89('0x24')]=qs[_0xff89('0x24')](_0x203161['query'][_0xff89('0x24')]);}_0x56bf28[_0xff89('0x43')]=qs[_0xff89('0x44')](_0x203161[_0xff89('0x3a')][_0xff89('0x44')]);_0x56bf28[_0xff89('0x45')]=qs[_0xff89('0x3c')](_[_0xff89('0x46')](_0x203161['query'],_0x3389b8[_0xff89('0x3c')]),_0x3d0f01);if(_0x203161[_0xff89('0x3a')][_0xff89('0x47')]){_0x56bf28['where']=_['merge'](_0x56bf28['where'],{'$or':_['map'](_0x3d0f01,function(_0x16f50d){if(_0x16f50d['type']!==_0xff89('0x48')){var _0x5605c2={};_0x5605c2[_0x16f50d[_0xff89('0x30')]]={'$like':'%'+_0x203161[_0xff89('0x3a')]['filter']+'%'};return _0x5605c2;}})});}_0x56bf28=_[_0xff89('0x49')]({},_0x56bf28,_0x203161[_0xff89('0x4a')]);var _0x2c18e8={'where':_0x56bf28['where']};return db[_0xff89('0x34')][_0xff89('0x23')](_0x2c18e8)[_0xff89('0x2b')](function(_0xc4b51e){_0x5f28ca[_0xff89('0x23')]=_0xc4b51e;if(_0x203161[_0xff89('0x3a')][_0xff89('0x4b')]){_0x56bf28['include']=[{'all':!![]}];}return db[_0xff89('0x34')][_0xff89('0x4c')](_0x56bf28);})[_0xff89('0x2b')](function(_0x324a4b){_0x5f28ca[_0xff89('0x4d')]=_0x324a4b;return _0x5f28ca;})[_0xff89('0x2b')](respondWithFilteredResult(_0x2e5751,_0x56bf28))[_0xff89('0x4e')](handleError(_0x2e5751,null));};exports[_0xff89('0x4f')]=function(_0x2a2ef4,_0x4445f9){var _0x5edf5e={'raw':![],'where':{'id':_0x2a2ef4[_0xff89('0x50')]['id']}},_0x49d536={};_0x49d536[_0xff89('0x38')]=_[_0xff89('0x3b')](db[_0xff89('0x34')][_0xff89('0x35')]);_0x49d536[_0xff89('0x3a')]=_[_0xff89('0x3b')](_0x2a2ef4['query']);_0x49d536[_0xff89('0x3c')]=_[_0xff89('0x3d')](_0x49d536[_0xff89('0x38')],_0x49d536['query']);_0x5edf5e[_0xff89('0x3e')]=_[_0xff89('0x3d')](_0x49d536[_0xff89('0x38')],qs['fields'](_0x2a2ef4[_0xff89('0x3a')]['fields']));_0x5edf5e[_0xff89('0x3e')]=_0x5edf5e[_0xff89('0x3e')][_0xff89('0x40')]?_0x5edf5e[_0xff89('0x3e')]:_0x49d536['model'];if(_0x2a2ef4[_0xff89('0x3a')]['includeAll']){_0x5edf5e[_0xff89('0x51')]=[{'all':!![]}];}_0x5edf5e=_[_0xff89('0x49')]({},_0x5edf5e,_0x2a2ef4[_0xff89('0x4a')]);return db[_0xff89('0x34')]['find'](_0x5edf5e)[_0xff89('0x2b')](handleEntityNotFound(_0x4445f9,null))[_0xff89('0x2b')](respondWithResult(_0x4445f9,null))[_0xff89('0x4e')](handleError(_0x4445f9,null));};exports[_0xff89('0x52')]=function(_0x2a8f65,_0x14d104){return db[_0xff89('0x34')][_0xff89('0x52')](_0x2a8f65['body'],{})[_0xff89('0x2b')](function(_0x5e3847){var _0x2a40c6=_0x2a8f65['user'][_0xff89('0x2c')]({'plain':!![]});if(!_0x2a40c6)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2a40c6['role']==='user'){var _0x145e3a=_0x5e3847[_0xff89('0x2c')]({'plain':!![]});var _0x3e4339='CustomDashboards';return db[_0xff89('0x53')][_0xff89('0x54')]({'where':{'name':_0x3e4339,'userProfileId':_0x2a40c6[_0xff89('0x55')]},'raw':!![]})['then'](function(_0x18ce52){if(_0x18ce52&&_0x18ce52[_0xff89('0x56')]===0x0){return db[_0xff89('0x57')][_0xff89('0x52')]({'name':_0x145e3a[_0xff89('0x30')],'resourceId':_0x145e3a['id'],'type':_0x18ce52[_0xff89('0x30')],'sectionId':_0x18ce52['id']},{})[_0xff89('0x2b')](function(){return _0x5e3847;});}else{return _0x5e3847;}})[_0xff89('0x4e')](function(_0x170f27){logger[_0xff89('0x2f')](_0xff89('0x58'),_0x170f27);throw _0x170f27;});}return _0x5e3847;})[_0xff89('0x2b')](respondWithResult(_0x14d104,0xc9))[_0xff89('0x4e')](handleError(_0x14d104,null));};exports[_0xff89('0x59')]=function(_0x295bae,_0x53b245){var _0x15255e={'where':{'id':_0x295bae[_0xff89('0x50')]['id']}},_0x17d840={};_0x17d840[_0xff89('0x38')]=_[_0xff89('0x3b')](db[_0xff89('0x34')][_0xff89('0x35')]);_0x15255e['attributes']=_[_0xff89('0x3d')](_0x17d840[_0xff89('0x38')],qs[_0xff89('0x3f')](_0x295bae['query'][_0xff89('0x3f')]));_0x15255e[_0xff89('0x3e')]=_0x15255e[_0xff89('0x3e')]['length']?_0x15255e[_0xff89('0x3e')]:_0x17d840['model'];if(_0x295bae[_0xff89('0x3a')][_0xff89('0x4b')]){_0x15255e[_0xff89('0x51')]=[{'all':!![]}];}_0x15255e=_['merge']({},_0x15255e,_0x295bae[_0xff89('0x4a')]);return db[_0xff89('0x34')][_0xff89('0x54')](_0x15255e)[_0xff89('0x2b')](handleEntityNotFound(_0x53b245,null))[_0xff89('0x2b')](function(_0x50a8bf){if(_0x50a8bf){var _0xa8fd8a=_0x50a8bf['get']({'plain':!![]});_0xa8fd8a=qs[_0xff89('0x5a')](_0xa8fd8a,['id',_0xff89('0x5b'),_0xff89('0x5c')]);_0x295bae[_0xff89('0x5d')]=_[_0xff89('0x5a')](_0x295bae[_0xff89('0x5d')],['id','createdAt',_0xff89('0x5c')]);return db['Dashboard'][_0xff89('0x52')](_[_0xff89('0x49')](_0xa8fd8a,_0x295bae['body']),{'include':_0x295bae[_0xff89('0x3a')][_0xff89('0x4b')]?[{'all':!![]}]:undefined})[_0xff89('0x2b')](function(_0x4b4ceb){var _0x3f9c43=_0x295bae[_0xff89('0x5e')][_0xff89('0x2c')]({'plain':!![]});if(!_0x3f9c43)throw new Error(_0xff89('0x5f'));if(_0x3f9c43['role']==='user'){var _0x58ba2=_0x4b4ceb[_0xff89('0x2c')]({'plain':!![]});var _0x5d18a3=_0xff89('0x2d');return db['UserProfileSection']['find']({'where':{'name':_0x5d18a3,'userProfileId':_0x3f9c43['userProfileId']},'raw':!![]})[_0xff89('0x2b')](function(_0x16ef2a){if(_0x16ef2a&&_0x16ef2a[_0xff89('0x56')]===0x0){return db['UserProfileResource']['create']({'name':_0x58ba2['name'],'resourceId':_0x58ba2['id'],'type':_0x16ef2a[_0xff89('0x30')],'sectionId':_0x16ef2a['id']},{})[_0xff89('0x2b')](function(){return _0x4b4ceb;});}else{return _0x4b4ceb;}})['catch'](function(_0x143a26){logger[_0xff89('0x2f')](_0xff89('0x58'),_0x143a26);throw _0x143a26;});}return _0x4b4ceb;});}})['then'](respondWithResult(_0x53b245,0xc9))[_0xff89('0x4e')](handleError(_0x53b245,null));};exports[_0xff89('0x2a')]=function(_0xa456d0,_0x440ebe){if(_0xa456d0[_0xff89('0x5d')]['id']){delete _0xa456d0[_0xff89('0x5d')]['id'];}return db['Dashboard'][_0xff89('0x54')]({'where':{'id':_0xa456d0[_0xff89('0x50')]['id']}})[_0xff89('0x2b')](handleEntityNotFound(_0x440ebe,null))[_0xff89('0x2b')](saveUpdates(_0xa456d0[_0xff89('0x5d')],null))[_0xff89('0x2b')](respondWithResult(_0x440ebe,null))[_0xff89('0x4e')](handleError(_0x440ebe,null));};exports[_0xff89('0x60')]=function(_0x580bed,_0x1fab20){return db[_0xff89('0x34')][_0xff89('0x54')]({'where':{'id':_0x580bed[_0xff89('0x50')]['id']}})['then'](handleEntityNotFound(_0x1fab20,null))['then'](removeEntity(_0x1fab20,null))[_0xff89('0x4e')](handleError(_0x1fab20,null));};function widgetAttributes(_0x4a7b61){try{switch(_0x4a7b61[_0xff89('0x37')]){case _0xff89('0x61'):return[{'name':_0xff89('0x62'),'value':_0x4a7b61[_0xff89('0x62')]||(_0x4a7b61['attrs']&&_0x4a7b61[_0xff89('0x63')][0x0]?_0x4a7b61[_0xff89('0x63')][0x0][_0xff89('0x64')]:undefined)||'https://'}];case'custom':return[{'name':'attrPath','value':_0x4a7b61[_0xff89('0x65')]||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61[_0xff89('0x63')][0x0]?_0x4a7b61[_0xff89('0x63')][0x0][_0xff89('0x64')]:undefined)||''}];case _0xff89('0x66'):return[{'name':_0xff89('0x67'),'value':_0x4a7b61['attrHourFormat']||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61[_0xff89('0x63')][0x0]?_0x4a7b61['attrs'][0x0][_0xff89('0x64')]:undefined)||'HH:mm:ss'},{'name':_0xff89('0x68'),'value':_0x4a7b61[_0xff89('0x68')]||(_0x4a7b61['attrs']&&_0x4a7b61[_0xff89('0x63')][0x1]?_0x4a7b61[_0xff89('0x63')][0x1][_0xff89('0x64')]:undefined)||'0.00'},{'name':_0xff89('0x69'),'value':_0x4a7b61[_0xff89('0x69')]||(_0x4a7b61['attrs']&&_0x4a7b61[_0xff89('0x63')][0x2]?_0x4a7b61[_0xff89('0x63')][0x2][_0xff89('0x64')]:undefined)||0xc}];case'counter':return[{'name':'attrMetric','value':_0x4a7b61[_0xff89('0x6a')]||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61['attrs'][0x0]?_0x4a7b61[_0xff89('0x63')][0x0][_0xff89('0x64')]:undefined)||_0xff89('0x6b')},{'name':_0xff89('0x6c'),'value':_0x4a7b61[_0xff89('0x6c')]||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61[_0xff89('0x63')][0x1]?_0x4a7b61[_0xff89('0x63')][0x1][_0xff89('0x64')]:undefined)||[]},{'name':_0xff89('0x69'),'value':_0x4a7b61[_0xff89('0x69')]||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61[_0xff89('0x63')][0x2]?_0x4a7b61['attrs'][0x2][_0xff89('0x64')]:undefined)||0x14}];case'multibar-chart':case'pie-chart':return[{'name':_0xff89('0x6d'),'value':_0x4a7b61['attrSerie1']||(_0x4a7b61['attrs']&&_0x4a7b61[_0xff89('0x63')][0x0]?_0x4a7b61['attrs'][0x0][_0xff89('0x64')]:undefined)||_0xff89('0x6b')},{'name':_0xff89('0x6e'),'value':_0x4a7b61[_0xff89('0x6e')]||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61[_0xff89('0x63')][0x1]?_0x4a7b61[_0xff89('0x63')][0x1][_0xff89('0x64')]:undefined)||null},{'name':'attrSerie3','value':_0x4a7b61[_0xff89('0x6f')]||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61[_0xff89('0x63')][0x2]?_0x4a7b61['attrs'][0x2][_0xff89('0x64')]:undefined)||null},{'name':_0xff89('0x6c'),'value':_0x4a7b61[_0xff89('0x6c')]||(_0x4a7b61['attrs']&&_0x4a7b61[_0xff89('0x63')][0x3]?_0x4a7b61[_0xff89('0x63')][0x3][_0xff89('0x64')]:undefined)||[]}];case _0xff89('0x70'):return[{'name':_0xff89('0x71'),'type':_0x4a7b61[_0xff89('0x72')]||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61['attrs'][0x0]?_0x4a7b61[_0xff89('0x63')][0x0][_0xff89('0x37')]:undefined)||null,'value':_0x4a7b61[_0xff89('0x71')]||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61[_0xff89('0x63')][0x0]?_0x4a7b61[_0xff89('0x63')][0x0]['value']:undefined)||null},{'name':'attrRefresh','value':_0x4a7b61['attrRefresh']||(_0x4a7b61[_0xff89('0x63')]&&_0x4a7b61[_0xff89('0x63')][0x1]?_0x4a7b61[_0xff89('0x63')][0x1][_0xff89('0x64')]:undefined)||0x0}];default:return[];}}catch(_0x49b1fc){logger[_0xff89('0x2f')]('widgetAttributes:\x20%s',JSON[_0xff89('0x73')](_0x49b1fc));return[];}}exports[_0xff89('0x74')]=function(_0x5e0fcb,_0x2d6e8b,_0x3af718){if(_0x5e0fcb[_0xff89('0x5d')]['id']){delete _0x5e0fcb[_0xff89('0x5d')]['id'];}return db[_0xff89('0x34')][_0xff89('0x54')]({'where':{'id':_0x5e0fcb[_0xff89('0x50')]['id']}})[_0xff89('0x2b')](handleEntityNotFound(_0x2d6e8b,null))[_0xff89('0x2b')](function(_0x1862b8){if(_0x1862b8){_0x5e0fcb[_0xff89('0x5d')][_0xff89('0x75')]=_0x1862b8['id'];_0x5e0fcb[_0xff89('0x5d')][_0xff89('0x63')]=widgetAttributes(_0x5e0fcb[_0xff89('0x5d')]);return db[_0xff89('0x76')]['create'](_0x5e0fcb[_0xff89('0x5d')]);}})[_0xff89('0x2b')](respondWithResult(_0x2d6e8b,null))[_0xff89('0x4e')](handleError(_0x2d6e8b,null));};exports[_0xff89('0x77')]=function(_0x3c7b23,_0x38f4ec,_0x14ff23){var _0x3c6f99={};var _0x2a6397={};var _0x46313c;var _0x3099bf;return db['Dashboard'][_0xff89('0x78')]({'where':{'id':_0x3c7b23[_0xff89('0x50')]['id']}})[_0xff89('0x2b')](handleEntityNotFound(_0x38f4ec,null))[_0xff89('0x2b')](function(_0x355bd5){if(_0x355bd5){_0x46313c=_0x355bd5;_0x2a6397['model']=_['keys'](db[_0xff89('0x76')][_0xff89('0x35')]);_0x2a6397['query']=_[_0xff89('0x3b')](_0x3c7b23[_0xff89('0x3a')]);_0x2a6397['filters']=_['intersection'](_0x2a6397['model'],_0x2a6397[_0xff89('0x3a')]);_0x3c6f99[_0xff89('0x3e')]=_[_0xff89('0x3d')](_0x2a6397[_0xff89('0x38')],qs[_0xff89('0x3f')](_0x3c7b23[_0xff89('0x3a')][_0xff89('0x3f')]));_0x3c6f99[_0xff89('0x3e')]=_0x3c6f99[_0xff89('0x3e')][_0xff89('0x40')]?_0x3c6f99[_0xff89('0x3e')]:_0x2a6397[_0xff89('0x38')];_0x3c6f99[_0xff89('0x43')]=qs[_0xff89('0x44')](_0x3c7b23['query'][_0xff89('0x44')]);_0x3c6f99[_0xff89('0x45')]=qs[_0xff89('0x3c')](_[_0xff89('0x46')](_0x3c7b23[_0xff89('0x3a')],_0x2a6397[_0xff89('0x3c')]));if(_0x3c7b23[_0xff89('0x3a')][_0xff89('0x47')]){_0x3c6f99[_0xff89('0x45')]=_['merge'](_0x3c6f99[_0xff89('0x45')],{'$or':_['map'](_0x3c6f99[_0xff89('0x3e')],function(_0x42b3bf){var _0x17ee38={};_0x17ee38[_0x42b3bf]={'$like':'%'+_0x3c7b23[_0xff89('0x3a')][_0xff89('0x47')]+'%'};return _0x17ee38;})});}_0x3c6f99=_[_0xff89('0x49')]({},_0x3c6f99,_0x3c7b23['options']);return _0x46313c[_0xff89('0x77')](_0x3c6f99);}})[_0xff89('0x2b')](function(_0x2152a7){if(_0x2152a7){_0x3099bf=_0x2152a7[_0xff89('0x40')];if(!_0x3c7b23[_0xff89('0x3a')][_0xff89('0x41')](_0xff89('0x42'))){_0x3c6f99[_0xff89('0x25')]=qs[_0xff89('0x25')](_0x3c7b23['query'][_0xff89('0x25')]);_0x3c6f99[_0xff89('0x24')]=qs['offset'](_0x3c7b23[_0xff89('0x3a')][_0xff89('0x24')]);}return _0x46313c['getItems'](_0x3c6f99);}})[_0xff89('0x2b')](function(_0x306a8c){if(_0x306a8c){return _0x306a8c?{'count':_0x3099bf,'rows':_0x306a8c}:null;}})[_0xff89('0x2b')](respondWithResult(_0x38f4ec,null))[_0xff89('0x4e')](handleError(_0x38f4ec,null));};