4bf89c8dde27323732cc09c32461c943b549cab2
[motion-next.git] / server / api / voiceQueueReport / voiceQueueReport.controller.js
1 const a760_0x4231=['index','error','length','describe','VIRTUAL','params','then','../../components/parsers/qs','filter','api','include','key','query','keys','sort','sequelize','update','body','model','catch','includeAll','destroy','json','getVoiceQueuesReport','register','lodash','create','order','offset','./voiceQueueReport.socket','findOne','set','pick','rawAttributes','where','send','stack','limit','undefined','VoiceQueueReport','like','count','sendStatus','nolimit','show','rows','findAll','name','fields','map','../../mysqldb','options','Content-Range','status','type','intersection','merge','filters','attributes'];(function(_0x185477,_0x4231b8){const _0x1e33db=function(_0x233e0c){while(--_0x233e0c){_0x185477['push'](_0x185477['shift']());}};_0x1e33db(++_0x4231b8);}(a760_0x4231,0x1de));const a760_0x1e33=function(_0x185477,_0x4231b8){_0x185477=_0x185477-0x0;let _0x1e33db=a760_0x4231[_0x185477];return _0x1e33db;};const _0x9ed270=a760_0x1e33;'use strict';const _=require(_0x9ed270('0x13')),qs=require(_0x9ed270('0x1')),logger=require('../../config/logger')(_0x9ed270('0x3')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require(_0x9ed270('0x2c'))['db'],{Op}=require(_0x9ed270('0x9'));require(_0x9ed270('0x17'))[_0x9ed270('0x12')](socket);function respondWithResult(_0x233e0c,_0x367ee4){return _0x367ee4=_0x367ee4||0xc8,function(_0x4b7904){const _0x54a184=a760_0x1e33;if(_0x4b7904)return _0x233e0c[_0x54a184('0x2f')](_0x367ee4)[_0x54a184('0x10')](_0x4b7904);};}function respondWithFilteredResult(_0x4e9b6d,_0x52437c){return function(_0x4977f4){const _0x269811=a760_0x1e33;if(_0x4977f4){const _0x94925e=_0x4977f4[_0x269811('0x23')],_0x59db46=_0x52437c[_0x269811('0x16')];let _0x39488c=_0x52437c['offset']+_0x52437c[_0x269811('0x1f')],_0x2bf821;return _0x39488c>=_0x94925e?(_0x39488c=_0x94925e,_0x2bf821=0xc8):_0x2bf821=0xce,_0x4e9b6d[_0x269811('0x2f')](_0x2bf821),_0x4e9b6d[_0x269811('0x19')](_0x269811('0x2e'),_0x59db46+'-'+_0x39488c+'/'+_0x94925e)['json'](_0x4977f4);}return null;};}function saveUpdates(_0x146574){return function(_0x441b33){const _0x3fa0f1=a760_0x1e33;if(_0x441b33)return _0x441b33[_0x3fa0f1('0xa')](_0x146574)['then'](function(_0xa01905){return _0xa01905;});return null;};}function removeEntity(_0x277e10){return function(_0x545496){const _0x1958dd=a760_0x1e33;if(_0x545496)return _0x545496[_0x1958dd('0xf')]()[_0x1958dd('0x0')](function(){_0x277e10['status'](0xcc)['end']();});};}function handleEntityNotFound(_0x385715){return function(_0x42ecb2){const _0x3b38bd=a760_0x1e33;return!_0x42ecb2&&_0x385715[_0x3b38bd('0x24')](0x194),_0x42ecb2;};}function handleError(_0x431b6f,_0xe1a7d8){return _0xe1a7d8=_0xe1a7d8||0x1f4,function(_0x8b5513){const _0x9365b0=a760_0x1e33;logger[_0x9365b0('0x36')](_0x8b5513[_0x9365b0('0x1e')]),_0x8b5513[_0x9365b0('0x29')]&&delete _0x8b5513['name'],_0x431b6f[_0x9365b0('0x2f')](_0xe1a7d8)[_0x9365b0('0x1d')](_0x8b5513);};}exports[_0x9ed270('0x35')]=function(_0x5c531f,_0x2ac8e7){const _0x4a697a=_0x9ed270;let _0x4c2af2={};const _0x7698ef={},_0x3b93a7={'count':0x0,'rows':[]},_0x7563d4=_['map'](db['VoiceQueueReport']['rawAttributes'],function(_0x519ec1){const _0x5d2dd7=a760_0x1e33;return{'name':_0x519ec1['fieldName'],'type':_0x519ec1[_0x5d2dd7('0x30')][_0x5d2dd7('0x5')]};});_0x7698ef[_0x4a697a('0xc')]=_[_0x4a697a('0x2b')](_0x7563d4,'name'),_0x7698ef[_0x4a697a('0x6')]=_[_0x4a697a('0x7')](_0x5c531f[_0x4a697a('0x6')]),_0x7698ef[_0x4a697a('0x33')]=_[_0x4a697a('0x31')](_0x7698ef[_0x4a697a('0xc')],_0x7698ef[_0x4a697a('0x6')]),_0x4c2af2['attributes']=_['intersection'](_0x7698ef['model'],qs[_0x4a697a('0x2a')](_0x5c531f[_0x4a697a('0x6')][_0x4a697a('0x2a')])),_0x4c2af2['attributes']=_0x4c2af2[_0x4a697a('0x34')][_0x4a697a('0x37')]?_0x4c2af2[_0x4a697a('0x34')]:_0x7698ef['model'];typeof _0x5c531f[_0x4a697a('0x6')][_0x4a697a('0x25')]===_0x4a697a('0x20')&&(_0x4c2af2[_0x4a697a('0x1f')]=qs[_0x4a697a('0x1f')](_0x5c531f['query'][_0x4a697a('0x1f')]),_0x4c2af2[_0x4a697a('0x16')]=qs[_0x4a697a('0x16')](_0x5c531f[_0x4a697a('0x6')]['offset']));_0x4c2af2['order']=qs[_0x4a697a('0x8')](_0x5c531f[_0x4a697a('0x6')][_0x4a697a('0x8')]),_0x4c2af2[_0x4a697a('0x1c')]=qs[_0x4a697a('0x33')](_[_0x4a697a('0x1a')](_0x5c531f['query'],_0x7698ef[_0x4a697a('0x33')]),_0x7563d4);_0x5c531f[_0x4a697a('0x6')]['filter']&&(_0x4c2af2[_0x4a697a('0x1c')]=_[_0x4a697a('0x32')](_0x4c2af2[_0x4a697a('0x1c')],{[Op['or']]:_[_0x4a697a('0x2b')](_0x7563d4,function(_0x309e57){const _0x1147e5=_0x4a697a;if(_0x309e57['type']!==_0x1147e5('0x39')){const _0x58c0fe={};return _0x58c0fe[_0x309e57['name']]={[Op['like']]:'%'+_0x5c531f[_0x1147e5('0x6')][_0x1147e5('0x2')]+'%'},_0x58c0fe;}})}));_0x4c2af2=_[_0x4a697a('0x32')]({},_0x4c2af2,_0x5c531f[_0x4a697a('0x2d')]);const _0x3d4218={'where':_0x4c2af2[_0x4a697a('0x1c')]};return db['VoiceQueueReport']['count'](_0x3d4218)[_0x4a697a('0x0')](function(_0x3a2dcf){const _0x366873=_0x4a697a;return _0x3b93a7[_0x366873('0x23')]=_0x3a2dcf,_0x5c531f[_0x366873('0x6')]['includeAll']&&(_0x4c2af2[_0x366873('0x4')]=[{'all':!![]}]),db[_0x366873('0x21')][_0x366873('0x28')](_0x4c2af2);})['then'](function(_0x235e5e){const _0x25360c=_0x4a697a;return _0x3b93a7[_0x25360c('0x27')]=_0x235e5e,_0x3b93a7;})[_0x4a697a('0x0')](respondWithFilteredResult(_0x2ac8e7,_0x4c2af2))[_0x4a697a('0xd')](handleError(_0x2ac8e7,null));},exports[_0x9ed270('0x26')]=function(_0x36ff90,_0x378bc9){const _0x22b3dc=_0x9ed270;let _0x89f595={'raw':![],'where':{'id':_0x36ff90['params']['id']}};const _0x5c7433={};return _0x5c7433[_0x22b3dc('0xc')]=_[_0x22b3dc('0x7')](db[_0x22b3dc('0x21')][_0x22b3dc('0x1b')]),_0x5c7433[_0x22b3dc('0x6')]=_[_0x22b3dc('0x7')](_0x36ff90[_0x22b3dc('0x6')]),_0x5c7433['filters']=_[_0x22b3dc('0x31')](_0x5c7433['model'],_0x5c7433[_0x22b3dc('0x6')]),_0x89f595['attributes']=_[_0x22b3dc('0x31')](_0x5c7433[_0x22b3dc('0xc')],qs[_0x22b3dc('0x2a')](_0x36ff90[_0x22b3dc('0x6')][_0x22b3dc('0x2a')])),_0x89f595['attributes']=_0x89f595['attributes'][_0x22b3dc('0x37')]?_0x89f595[_0x22b3dc('0x34')]:_0x5c7433['model'],_0x36ff90[_0x22b3dc('0x6')][_0x22b3dc('0xe')]&&(_0x89f595['include']=[{'all':!![]}]),_0x89f595=_[_0x22b3dc('0x32')]({},_0x89f595,_0x36ff90[_0x22b3dc('0x2d')]),db[_0x22b3dc('0x21')][_0x22b3dc('0x18')](_0x89f595)[_0x22b3dc('0x0')](handleEntityNotFound(_0x378bc9,null))[_0x22b3dc('0x0')](respondWithResult(_0x378bc9,null))[_0x22b3dc('0xd')](handleError(_0x378bc9,null));},exports[_0x9ed270('0x14')]=function(_0xe3f894,_0x231421){const _0x47efd6=_0x9ed270;return db[_0x47efd6('0x21')][_0x47efd6('0x14')](_0xe3f894[_0x47efd6('0xb')],{})[_0x47efd6('0x0')](respondWithResult(_0x231421,0xc9))[_0x47efd6('0xd')](handleError(_0x231421,null));},exports['update']=function(_0x518d7f,_0x2080d4){const _0x49bc93=_0x9ed270;return _0x518d7f['body']['id']&&delete _0x518d7f['body']['id'],db['VoiceQueueReport']['findOne']({'where':{'id':_0x518d7f[_0x49bc93('0x3a')]['id']}})[_0x49bc93('0x0')](handleEntityNotFound(_0x2080d4,null))[_0x49bc93('0x0')](saveUpdates(_0x518d7f[_0x49bc93('0xb')],null))[_0x49bc93('0x0')](respondWithResult(_0x2080d4,null))['catch'](handleError(_0x2080d4,null));},exports[_0x9ed270('0xf')]=function(_0x217546,_0x49fb02){const _0x5eddfd=_0x9ed270;return db[_0x5eddfd('0x21')][_0x5eddfd('0x18')]({'where':{'id':_0x217546['params']['id']}})['then'](handleEntityNotFound(_0x49fb02,null))[_0x5eddfd('0x0')](removeEntity(_0x49fb02,null))[_0x5eddfd('0xd')](handleError(_0x49fb02,null));},exports[_0x9ed270('0x38')]=function(_0xd049fc,_0x5e8525){const _0x2c7151=_0x9ed270;return db['VoiceQueueReport'][_0x2c7151('0x38')]()[_0x2c7151('0x0')](respondWithResult(_0x5e8525,null))[_0x2c7151('0xd')](handleError(_0x5e8525,null));},exports[_0x9ed270('0x11')]=function(_0x5ad010,_0x2d65a8){const _0x9f567f=_0x9ed270;let _0x30e0a8={};const _0x45c755={},_0x53accb={'count':0x0,'rows':[]};_0x45c755['model']=_[_0x9f567f('0x7')](db[_0x9f567f('0x21')][_0x9f567f('0x1b')]),_0x45c755[_0x9f567f('0x6')]=_['keys'](_0x5ad010['query']),_0x45c755['filters']=_[_0x9f567f('0x31')](_0x45c755[_0x9f567f('0xc')],_0x45c755[_0x9f567f('0x6')]),_0x30e0a8[_0x9f567f('0x34')]=_[_0x9f567f('0x31')](_0x45c755['model'],qs[_0x9f567f('0x2a')](_0x5ad010[_0x9f567f('0x6')][_0x9f567f('0x2a')])),_0x30e0a8['attributes']=_0x30e0a8[_0x9f567f('0x34')][_0x9f567f('0x37')]?_0x30e0a8[_0x9f567f('0x34')]:_0x45c755[_0x9f567f('0xc')];typeof _0x5ad010[_0x9f567f('0x6')][_0x9f567f('0x25')]==='undefined'&&(_0x30e0a8[_0x9f567f('0x1f')]=qs[_0x9f567f('0x1f')](_0x5ad010[_0x9f567f('0x6')]['limit']),_0x30e0a8['offset']=qs[_0x9f567f('0x16')](_0x5ad010[_0x9f567f('0x6')]['offset']));_0x30e0a8[_0x9f567f('0x15')]=qs['sort'](_0x5ad010[_0x9f567f('0x6')][_0x9f567f('0x8')]),_0x30e0a8['where']=qs[_0x9f567f('0x33')](_[_0x9f567f('0x1a')](_0x5ad010[_0x9f567f('0x6')],_0x45c755[_0x9f567f('0x33')]));_0x5ad010[_0x9f567f('0x6')][_0x9f567f('0x2')]&&(_0x30e0a8[_0x9f567f('0x1c')]=_[_0x9f567f('0x32')](_0x30e0a8[_0x9f567f('0x1c')],{[Op['or']]:_[_0x9f567f('0x2b')](_0x30e0a8[_0x9f567f('0x34')],function(_0x254b12){const _0x3716b8=_0x9f567f,_0x1c44e5={};return _0x1c44e5[_0x254b12]={[Op[_0x3716b8('0x22')]]:'%'+_0x5ad010[_0x3716b8('0x6')][_0x3716b8('0x2')]+'%'},_0x1c44e5;})}));_0x30e0a8=_[_0x9f567f('0x32')]({},_0x30e0a8,_0x5ad010[_0x9f567f('0x2d')]);const _0x50b694={'where':_0x30e0a8[_0x9f567f('0x1c')]};return db[_0x9f567f('0x21')]['count'](_0x50b694)['then'](function(_0x5398dd){const _0x30811a=_0x9f567f;return _0x53accb[_0x30811a('0x23')]=_0x5398dd,_0x5ad010[_0x30811a('0x6')][_0x30811a('0xe')]&&(_0x30e0a8[_0x30811a('0x4')]=[{'all':!![]}]),db[_0x30811a('0x21')]['findAll'](_0x30e0a8);})[_0x9f567f('0x0')](function(_0x62c30a){const _0x4949b5=_0x9f567f;return _0x53accb[_0x4949b5('0x27')]=_0x62c30a,_0x53accb;})[_0x9f567f('0x0')](respondWithFilteredResult(_0x2d65a8,_0x30e0a8,'getVoiceQueuesReport'))[_0x9f567f('0xd')](handleError(_0x2d65a8,null,'getVoiceQueuesReport'));};