Built motion from commit b517aaa2a6638133380e4d135c64a80893061362. Version 3.0.0...
[motion-next.git] / server / api / cmHopperFinal / cmHopperFinal.controller.js
1 const a147_0x1b45=['COUNT','api','createdAt','type','then','where','intersection','VIRTUAL','map','group','index','findAll','state\x20=\x204','CmHopperFinal','updatedAt','stack','merge','count','name','CampaignId','sort','ContactId','fields','keys','ANY_VALUE(calleridnum)','filter','body','query','findOne','params','includeAll','undefined','Campaign','into','cm_hopper','NOW()','from','filters','attributes','VoiceQueueId','calleridnum\x20IS\x20NOT\x20NULL','insert','ANY_VALUE(ListId)','Content-Range','offset','scheduledAt','sequelize','literal','like','`state`\x20=\x2011\x20,\x201,\x20null','include','rows','key','length','../../config/logger','describe','catch','`state`\x20=\x205,\x201,\x20null','ANY_VALUE(VoiceQueueId)','uniqueid','`state`\x20=\x203,\x201,\x20null','rawAttributes','status','model','CmHopper','json','VoiceQueueId\x20=\x20?','state\x20=\x20?','order','update','noAnswerContacts','ANY_VALUE(ContactId)','calleridnum','toString','reCallContacts','cm_hopper_final','select','`state`\x20=\x200,\x201,\x20null','`state`\x20=\x208,\x201,\x20null','congestionContacts','pick','answeringMachine','fieldName','fromQuery','abandonedContacts','show','noSuchContacts','`state`\x20=\x2022,\x201,\x20null','field','moveContactsIvrCampaignHopperFinal','../../mysqldb','dropContacts','CampaignId\x20=\x20?','phone','ListId','calleridnum\x20NOT\x20IN\x20(?)','lodash','limit','`state`\x20=\x2019,\x201,\x20null','`state`\x20=\x2010\x20,\x201,\x20null','ANY_VALUE(CampaignId)','squel'];(function(_0x4c838c,_0x1b45f3){const _0x1d5283=function(_0x2962d5){while(--_0x2962d5){_0x4c838c['push'](_0x4c838c['shift']());}};_0x1d5283(++_0x1b45f3);}(a147_0x1b45,0xba));const a147_0x1d52=function(_0x4c838c,_0x1b45f3){_0x4c838c=_0x4c838c-0x0;let _0x1d5283=a147_0x1b45[_0x4c838c];return _0x1d5283;};const _0x25ea3c=a147_0x1d52;'use strict';const _=require(_0x25ea3c('0xc')),squel=require(_0x25ea3c('0x11')),qs=require('../../components/parsers/qs'),logger=require(_0x25ea3c('0x48'))(_0x25ea3c('0x13')),db=require(_0x25ea3c('0x6'))['db'],{Op}=require('sequelize');function respondWithResult(_0x2962d5,_0x12169a){return _0x12169a=_0x12169a||0xc8,function(_0x183df4){if(_0x183df4)return _0x2962d5['status'](_0x12169a)['json'](_0x183df4);};}function respondWithFilteredResult(_0x2d1027,_0x4ceb7d){return function(_0x298ab3){const _0x311339=a147_0x1d52;if(_0x298ab3){const _0x4c95dd=_0x298ab3[_0x311339('0x23')],_0x206532=_0x4ceb7d['offset'];let _0x3f7657=_0x4ceb7d[_0x311339('0x3e')]+_0x4ceb7d[_0x311339('0xd')],_0x1977a2;return _0x3f7657>=_0x4c95dd?(_0x3f7657=_0x4c95dd,_0x1977a2=0xc8):_0x1977a2=0xce,_0x2d1027[_0x311339('0x50')](_0x1977a2),_0x2d1027['set'](_0x311339('0x3d'),_0x206532+'-'+_0x3f7657+'/'+_0x4c95dd)[_0x311339('0x53')](_0x298ab3);}return null;};}function saveUpdates(_0x2d3a36){return function(_0x322fcf){const _0x5cff5a=a147_0x1d52;if(_0x322fcf)return _0x322fcf['update'](_0x2d3a36)[_0x5cff5a('0x16')](function(_0x526f6c){return _0x526f6c;});return null;};}function handleEntityNotFound(_0x132292){return function(_0x1af997){return!_0x1af997&&_0x132292['sendStatus'](0x194),_0x1af997;};}function handleError(_0x12a1bc,_0x144741){return _0x144741=_0x144741||0x1f4,function(_0x2b7de1){const _0x10c6b5=a147_0x1d52;logger['error'](_0x2b7de1[_0x10c6b5('0x21')]),_0x2b7de1['name']&&delete _0x2b7de1[_0x10c6b5('0x24')],_0x12a1bc[_0x10c6b5('0x50')](_0x144741)['send'](_0x2b7de1);};}exports[_0x25ea3c('0x1c')]=function(_0x1df2b1,_0x2f21c1){const _0x3fbaef=_0x25ea3c;let _0x1a25b6={};const _0x44a85a={},_0x176436={'count':0x0,'rows':[]},_0xfd5276=_[_0x3fbaef('0x1a')](db[_0x3fbaef('0x1f')][_0x3fbaef('0x4f')],function(_0x4a70c9){const _0x4df432=_0x3fbaef;return{'name':_0x4a70c9[_0x4df432('0x64')],'type':_0x4a70c9[_0x4df432('0x15')][_0x4df432('0x46')]};});_0x44a85a['model']=_[_0x3fbaef('0x1a')](_0xfd5276,_0x3fbaef('0x24')),_0x44a85a[_0x3fbaef('0x2d')]=_[_0x3fbaef('0x29')](_0x1df2b1[_0x3fbaef('0x2d')]),_0x44a85a['filters']=_['intersection'](_0x44a85a[_0x3fbaef('0x51')],_0x44a85a[_0x3fbaef('0x2d')]),_0x1a25b6[_0x3fbaef('0x38')]=_[_0x3fbaef('0x18')](_0x44a85a['model'],qs['fields'](_0x1df2b1['query'][_0x3fbaef('0x28')])),_0x1a25b6[_0x3fbaef('0x38')]=_0x1a25b6['attributes'][_0x3fbaef('0x47')]?_0x1a25b6[_0x3fbaef('0x38')]:_0x44a85a[_0x3fbaef('0x51')];typeof _0x1df2b1[_0x3fbaef('0x2d')]['nolimit']===_0x3fbaef('0x31')&&(_0x1a25b6[_0x3fbaef('0xd')]=qs[_0x3fbaef('0xd')](_0x1df2b1['query'][_0x3fbaef('0xd')]),_0x1a25b6['offset']=qs[_0x3fbaef('0x3e')](_0x1df2b1[_0x3fbaef('0x2d')][_0x3fbaef('0x3e')]));_0x1a25b6[_0x3fbaef('0x56')]=qs[_0x3fbaef('0x26')](_0x1df2b1[_0x3fbaef('0x2d')]['sort']),_0x1a25b6[_0x3fbaef('0x17')]=qs[_0x3fbaef('0x37')](_[_0x3fbaef('0x62')](_0x1df2b1[_0x3fbaef('0x2d')],_0x44a85a[_0x3fbaef('0x37')]),_0xfd5276);_0x1df2b1[_0x3fbaef('0x2d')][_0x3fbaef('0x2b')]&&(_0x1a25b6[_0x3fbaef('0x17')]=_[_0x3fbaef('0x22')](_0x1a25b6[_0x3fbaef('0x17')],{[Op['or']]:_[_0x3fbaef('0x1a')](_0xfd5276,function(_0x194447){const _0x34952e=_0x3fbaef;if(_0x194447[_0x34952e('0x15')]!==_0x34952e('0x19')){const _0x59cf54={};return _0x59cf54[_0x194447[_0x34952e('0x24')]]={[Op[_0x34952e('0x42')]]:'%'+_0x1df2b1['query'][_0x34952e('0x2b')]+'%'},_0x59cf54;}})}));_0x1a25b6=_[_0x3fbaef('0x22')]({},_0x1a25b6,_0x1df2b1['options']);const _0x2bcda4={'where':_0x1a25b6[_0x3fbaef('0x17')]};return db[_0x3fbaef('0x1f')][_0x3fbaef('0x23')](_0x2bcda4)[_0x3fbaef('0x16')](function(_0x49968d){const _0x446441=_0x3fbaef;return _0x176436[_0x446441('0x23')]=_0x49968d,_0x1df2b1[_0x446441('0x2d')][_0x446441('0x30')]&&(_0x1a25b6[_0x446441('0x44')]=[{'all':!![]}]),db[_0x446441('0x1f')][_0x446441('0x1d')](_0x1a25b6);})[_0x3fbaef('0x16')](function(_0x302e55){const _0xc5673e=_0x3fbaef;return _0x176436[_0xc5673e('0x45')]=_0x302e55,_0x176436;})[_0x3fbaef('0x16')](respondWithFilteredResult(_0x2f21c1,_0x1a25b6))[_0x3fbaef('0x4a')](handleError(_0x2f21c1,null));},exports[_0x25ea3c('0x1')]=function(_0x2af974,_0x23eac5){const _0x2c6e49=_0x25ea3c;let _0x7a66e8={'raw':!![],'where':{'id':_0x2af974[_0x2c6e49('0x2f')]['id']}};const _0xd50565={};return _0xd50565['model']=_['keys'](db[_0x2c6e49('0x1f')][_0x2c6e49('0x4f')]),_0xd50565[_0x2c6e49('0x2d')]=_[_0x2c6e49('0x29')](_0x2af974[_0x2c6e49('0x2d')]),_0xd50565['filters']=_['intersection'](_0xd50565['model'],_0xd50565[_0x2c6e49('0x2d')]),_0x7a66e8[_0x2c6e49('0x38')]=_[_0x2c6e49('0x18')](_0xd50565[_0x2c6e49('0x51')],qs[_0x2c6e49('0x28')](_0x2af974['query'][_0x2c6e49('0x28')])),_0x7a66e8[_0x2c6e49('0x38')]=_0x7a66e8[_0x2c6e49('0x38')][_0x2c6e49('0x47')]?_0x7a66e8['attributes']:_0xd50565[_0x2c6e49('0x51')],_0x2af974[_0x2c6e49('0x2d')][_0x2c6e49('0x30')]&&(_0x7a66e8[_0x2c6e49('0x44')]=[{'all':!![]}]),_0x7a66e8=_['merge']({},_0x7a66e8,_0x2af974['options']),db['CmHopperFinal'][_0x2c6e49('0x2e')](_0x7a66e8)['then'](handleEntityNotFound(_0x23eac5,null))['then'](respondWithResult(_0x23eac5,null))[_0x2c6e49('0x4a')](handleError(_0x23eac5,null));},exports['describe']=function(_0x16f53b,_0x2d2973){const _0x209d6d=_0x25ea3c;return db[_0x209d6d('0x1f')][_0x209d6d('0x49')]()[_0x209d6d('0x16')](respondWithResult(_0x2d2973,null))[_0x209d6d('0x4a')](handleError(_0x2d2973,null));},exports[_0x25ea3c('0x57')]=function(_0xf3a679,_0x14c135){const _0x581b8f=_0x25ea3c;return _0xf3a679[_0x581b8f('0x2c')][_0x581b8f('0x4d')]&&delete _0xf3a679[_0x581b8f('0x2c')][_0x581b8f('0x4d')],db[_0x581b8f('0x1f')][_0x581b8f('0x2e')]({'where':{'uniqueid':_0xf3a679[_0x581b8f('0x2f')]['id']}})[_0x581b8f('0x16')](handleEntityNotFound(_0x14c135,null))['then'](saveUpdates(_0xf3a679[_0x581b8f('0x2c')],null))[_0x581b8f('0x16')](respondWithResult(_0x14c135,null))['catch'](handleError(_0x14c135,null));},exports['countContactsQueueCampaignHopperFinal']=function(_0x5318b1,_0x5831b5){const _0x5f7e47=_0x25ea3c;return db[_0x5f7e47('0x1f')][_0x5f7e47('0x1d')]({'raw':![],'where':{'VoiceQueueId':_0x5318b1[_0x5f7e47('0x2f')]['id']},'attributes':[[db[_0x5f7e47('0x40')]['fn'](_0x5f7e47('0x12'),db['sequelize']['fn']('IF',db[_0x5f7e47('0x40')][_0x5f7e47('0x41')](_0x5f7e47('0x5f')))),_0x5f7e47('0x2')],[db[_0x5f7e47('0x40')]['fn'](_0x5f7e47('0x12'),db[_0x5f7e47('0x40')]['fn']('IF',db[_0x5f7e47('0x40')][_0x5f7e47('0x41')](_0x5f7e47('0x4e')))),'noAnswerContacts'],[db[_0x5f7e47('0x40')]['fn'](_0x5f7e47('0x12'),db['sequelize']['fn']('IF',db[_0x5f7e47('0x40')][_0x5f7e47('0x41')](_0x5f7e47('0x4b')))),'busyContacts'],[db[_0x5f7e47('0x40')]['fn'](_0x5f7e47('0x12'),db[_0x5f7e47('0x40')]['fn']('IF',db[_0x5f7e47('0x40')]['literal']('`state`\x20=\x208,\x201,\x20null'))),_0x5f7e47('0x61')],[db[_0x5f7e47('0x40')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x5f7e47('0x40')][_0x5f7e47('0x41')]('`state`\x20=\x2010\x20,\x201,\x20null'))),_0x5f7e47('0x7')],[db[_0x5f7e47('0x40')]['fn'](_0x5f7e47('0x12'),db['sequelize']['fn']('IF',db[_0x5f7e47('0x40')]['literal']('`state`\x20=\x2011\x20,\x201,\x20null'))),_0x5f7e47('0x0')],[db[_0x5f7e47('0x40')]['fn'](_0x5f7e47('0x12'),db['sequelize']['fn']('IF',db[_0x5f7e47('0x40')][_0x5f7e47('0x41')]('`state`\x20=\x2022,\x201,\x20null'))),_0x5f7e47('0x5c')],[db['sequelize']['fn'](_0x5f7e47('0x12'),db[_0x5f7e47('0x40')]['fn']('IF',db[_0x5f7e47('0x40')][_0x5f7e47('0x41')](_0x5f7e47('0xe')))),_0x5f7e47('0x63')]]})[_0x5f7e47('0x16')](handleEntityNotFound(_0x5831b5,null))[_0x5f7e47('0x16')](respondWithResult(_0x5831b5,null))['catch'](handleError(_0x5831b5,null));},exports['countContactsIvrCampaignHopperFinal']=function(_0x1aed29,_0x12e86f){const _0x567aa6=_0x25ea3c;return db['CmHopperFinal'][_0x567aa6('0x1d')]({'raw':![],'where':{'CampaignId':_0x1aed29['params']['id']},'attributes':[[db[_0x567aa6('0x40')]['fn'](_0x567aa6('0x12'),db[_0x567aa6('0x40')]['fn']('IF',db[_0x567aa6('0x40')][_0x567aa6('0x41')]('`state`\x20=\x200,\x201,\x20null'))),_0x567aa6('0x2')],[db['sequelize']['fn'](_0x567aa6('0x12'),db[_0x567aa6('0x40')]['fn']('IF',db[_0x567aa6('0x40')][_0x567aa6('0x41')]('`state`\x20=\x203,\x201,\x20null'))),_0x567aa6('0x58')],[db['sequelize']['fn'](_0x567aa6('0x12'),db[_0x567aa6('0x40')]['fn']('IF',db[_0x567aa6('0x40')][_0x567aa6('0x41')](_0x567aa6('0x4b')))),'busyContacts'],[db['sequelize']['fn'](_0x567aa6('0x12'),db[_0x567aa6('0x40')]['fn']('IF',db['sequelize'][_0x567aa6('0x41')](_0x567aa6('0x60')))),_0x567aa6('0x61')],[db[_0x567aa6('0x40')]['fn'](_0x567aa6('0x12'),db['sequelize']['fn']('IF',db[_0x567aa6('0x40')][_0x567aa6('0x41')](_0x567aa6('0xf')))),_0x567aa6('0x7')],[db[_0x567aa6('0x40')]['fn']('COUNT',db[_0x567aa6('0x40')]['fn']('IF',db[_0x567aa6('0x40')]['literal'](_0x567aa6('0x43')))),_0x567aa6('0x0')],[db['sequelize']['fn'](_0x567aa6('0x12'),db[_0x567aa6('0x40')]['fn']('IF',db['sequelize']['literal'](_0x567aa6('0x3')))),_0x567aa6('0x5c')],[db[_0x567aa6('0x40')]['fn'](_0x567aa6('0x12'),db[_0x567aa6('0x40')]['fn']('IF',db[_0x567aa6('0x40')]['literal'](_0x567aa6('0xe')))),'answeringMachine']]})[_0x567aa6('0x16')](handleEntityNotFound(_0x12e86f,null))[_0x567aa6('0x16')](respondWithResult(_0x12e86f,null))['catch'](handleError(_0x12e86f,null));},exports['moveContactsQueueCampaignHopperFinal']=function(_0x466d3b,_0x392da9){const _0x11c27d=_0x25ea3c;return db['VoiceQueue']['findOne']({'where':{'id':_0x466d3b[_0x11c27d('0x2f')]['id']}})[_0x11c27d('0x16')](handleEntityNotFound(_0x392da9,null))['then'](function(_0x42e1b9){const _0x46e219=_0x11c27d;let _0x47ada9;if(_0x42e1b9)return _0x47ada9=squel[_0x46e219('0x3b')]()[_0x46e219('0x33')]('cm_hopper')[_0x46e219('0x65')]([_0x46e219('0x9'),_0x46e219('0x3f'),_0x46e219('0x27'),_0x46e219('0xa'),_0x46e219('0x39'),'createdAt',_0x46e219('0x20')],squel['select']()[_0x46e219('0x4')](_0x46e219('0x2a'),'phone')['field'](_0x46e219('0x35'),_0x46e219('0x3f'))['field'](_0x46e219('0x59'),_0x46e219('0x27'))['field']('ANY_VALUE(ListId)','ListId')[_0x46e219('0x4')](_0x46e219('0x4c'),_0x46e219('0x39'))[_0x46e219('0x4')](_0x46e219('0x35'),'createdAt')[_0x46e219('0x4')](_0x46e219('0x35'),_0x46e219('0x20'))[_0x46e219('0x36')](_0x46e219('0x5d'))[_0x46e219('0x17')](_0x46e219('0x54'),_0x466d3b['params']['id'][_0x46e219('0x5b')]())[_0x46e219('0x17')](_0x46e219('0x55'),_0x466d3b[_0x46e219('0x2c')]['state'][_0x46e219('0x5b')]())[_0x46e219('0x17')]('calleridnum\x20IS\x20NOT\x20NULL')[_0x46e219('0x17')]('calleridnum\x20NOT\x20IN\x20(?)',squel[_0x46e219('0x5e')]()[_0x46e219('0x4')]('phone')[_0x46e219('0x36')](_0x46e219('0x34'))[_0x46e219('0x17')](_0x46e219('0x54'),_0x466d3b['params']['id']['toString']()))[_0x46e219('0x17')](_0x46e219('0xb'),squel['select']()[_0x46e219('0x4')]('calleridnum')[_0x46e219('0x36')](_0x46e219('0x5d'))[_0x46e219('0x17')]('VoiceQueueId\x20=\x20?',_0x466d3b[_0x46e219('0x2f')]['id'][_0x46e219('0x5b')]())['where']('state\x20=\x204'))[_0x46e219('0x1b')](_0x46e219('0x27')))[_0x46e219('0x5b')](),db[_0x46e219('0x40')][_0x46e219('0x2d')](_0x47ada9);return[];})[_0x11c27d('0x16')](respondWithResult(_0x392da9,null))[_0x11c27d('0x4a')](handleError(_0x392da9,null));},exports[_0x25ea3c('0x5')]=function(_0x1dba37,_0x2ea4de){const _0x3e1a92=_0x25ea3c;return db[_0x3e1a92('0x32')]['findOne']({'where':{'id':_0x1dba37[_0x3e1a92('0x2f')]['id']}})[_0x3e1a92('0x16')](handleEntityNotFound(_0x2ea4de,null))[_0x3e1a92('0x16')](function(_0x4c5128){const _0x10ebfe=_0x3e1a92;let _0x39fd08;if(_0x4c5128)return _0x39fd08=squel[_0x10ebfe('0x3b')]()[_0x10ebfe('0x33')](_0x10ebfe('0x34'))[_0x10ebfe('0x65')](['phone',_0x10ebfe('0x3f'),_0x10ebfe('0x27'),_0x10ebfe('0xa'),_0x10ebfe('0x25'),_0x10ebfe('0x14'),_0x10ebfe('0x20')],squel[_0x10ebfe('0x5e')]()['field'](_0x10ebfe('0x2a'),_0x10ebfe('0x9'))[_0x10ebfe('0x4')](_0x10ebfe('0x35'),_0x10ebfe('0x3f'))[_0x10ebfe('0x4')](_0x10ebfe('0x59'),'ContactId')[_0x10ebfe('0x4')](_0x10ebfe('0x3c'),'ListId')[_0x10ebfe('0x4')](_0x10ebfe('0x10'),_0x10ebfe('0x25'))['field'](_0x10ebfe('0x35'),_0x10ebfe('0x14'))[_0x10ebfe('0x4')]('NOW()',_0x10ebfe('0x20'))['from'](_0x10ebfe('0x5d'))[_0x10ebfe('0x17')]('CampaignId\x20=\x20?',_0x1dba37[_0x10ebfe('0x2f')]['id'][_0x10ebfe('0x5b')]())[_0x10ebfe('0x17')](_0x10ebfe('0x55'),_0x1dba37[_0x10ebfe('0x2c')]['state'][_0x10ebfe('0x5b')]())['where'](_0x10ebfe('0x3a'))[_0x10ebfe('0x17')]('calleridnum\x20NOT\x20IN\x20(?)',squel[_0x10ebfe('0x5e')]()['field'](_0x10ebfe('0x9'))[_0x10ebfe('0x36')]('cm_hopper')[_0x10ebfe('0x17')](_0x10ebfe('0x8'),_0x1dba37[_0x10ebfe('0x2f')]['id'][_0x10ebfe('0x5b')]()))[_0x10ebfe('0x17')](_0x10ebfe('0xb'),squel[_0x10ebfe('0x5e')]()[_0x10ebfe('0x4')](_0x10ebfe('0x5a'))['from'](_0x10ebfe('0x5d'))['where'](_0x10ebfe('0x8'),_0x1dba37['params']['id'][_0x10ebfe('0x5b')]())[_0x10ebfe('0x17')](_0x10ebfe('0x1e')))[_0x10ebfe('0x1b')](_0x10ebfe('0x27')))[_0x10ebfe('0x5b')](),db[_0x10ebfe('0x40')]['query'](_0x39fd08);return[];})[_0x3e1a92('0x16')](respondWithResult(_0x2ea4de,null))['catch'](handleError(_0x2ea4de,null));},exports['checkContactHopper']=function(_0x37ddc5,_0x1a99b1){const _0x5e27e1=_0x25ea3c;return db[_0x5e27e1('0x52')][_0x5e27e1('0x2e')]({'where':{'VoiceQueueId':_0x37ddc5[_0x5e27e1('0x2c')][_0x5e27e1('0x39')],'CampaignId':_0x37ddc5['body'][_0x5e27e1('0x25')],'ContactId':_0x37ddc5[_0x5e27e1('0x2c')][_0x5e27e1('0x27')]}})[_0x5e27e1('0x16')](handleEntityNotFound(_0x1a99b1,null))[_0x5e27e1('0x16')](function(_0x2662b0){if(_0x2662b0)return _0x2662b0;return null;})[_0x5e27e1('0x16')](respondWithResult(_0x1a99b1,null))[_0x5e27e1('0x4a')](handleError(_0x1a99b1,null));};