cede2e1f624c837dd53af211c0bc51c028c61161
[motion2.git] / server / api / cmHopperHistory / cmHopperHistory.rpc.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 _0x8164=['body','options','raw','AvgHandleTime','findAll','sequelize','col','predictiveIntervalTotalCalls','literal','`state`\x20=\x204,\x201,\x20null','COUNT','`state`\x20=\x2010,\x201,\x20null','predictiveIntervalDroppedCallsTimeout','AVG','`state`\x20=\x204,\x20`talktime`,\x20null','predictiveIntervalAvgTalktime','where','name','`state`\x20=\x200,\x201,\x20null','outboundNoSuchCallsDay','outboundNoAnswerCallsDay','outboundBusyCallsDay','`state`\x20=\x208,\x201,\x20null','outboundCongestionCallsDay','`state`\x20=\x2011\x20,\x201,\x20null','outboundDropCallsDayCallersExit','`state`\x20=\x2012,\x201,\x20null','outboundUnknownCallsDay','`state`\x20=\x2013,\x201,\x20null','`state`\x20=\x2014,\x201,\x20null','outboundOriginateFailureCallsDay','`state`\x20=\x2018,\x201,\x20null','outboundRejectCallsDay','`state`\x20=\x2016,\x201,\x20null','outboundAnswerAgiCallsDay','`state`\x20=\x2020,\x201,\x20null','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','outboundReCallsDay','campaign','GetVoiceQueueHopperHistory','GetCampaignHopperHistory','ivrTotalCallsDays','ivrAnswerCallsDay','lodash','util','moment','randomstring','ioredis','../../config/utils','rpc','client','request','then','info','CmHopperHistory,\x20%s,\x20%s','debug','request\x20sent','stringify','error','message','result','catch','CreateCmHopperHistory','CmHopperHistory','create'];(function(_0x4cba68,_0x2303e6){var _0x55dbfe=function(_0x5cfd9c){while(--_0x5cfd9c){_0x4cba68['push'](_0x4cba68['shift']());}};_0x55dbfe(++_0x2303e6);}(_0x8164,0x170));var _0x4816=function(_0x8343ba,_0x217a01){_0x8343ba=_0x8343ba-0x0;var _0x3b10ff=_0x8164[_0x8343ba];return _0x3b10ff;};'use strict';var _=require(_0x4816('0x0'));var util=require(_0x4816('0x1'));var moment=require(_0x4816('0x2'));var BPromise=require('bluebird');var rs=require(_0x4816('0x3'));var fs=require('fs');var Redis=require(_0x4816('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x4816('0x5'));var logger=require('../../config/logger')(_0x4816('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x4816('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x51ab08,_0x2ddb3b,_0x437b8b){return new BPromise(function(_0x170e7a,_0x383974){return client[_0x4816('0x8')](_0x51ab08,_0x437b8b)[_0x4816('0x9')](function(_0x285cab){logger[_0x4816('0xa')](_0x4816('0xb'),_0x2ddb3b,'request\x20sent');logger[_0x4816('0xc')]('CmHopperHistory,\x20%s,\x20%s,\x20%s',_0x2ddb3b,_0x4816('0xd'),JSON[_0x4816('0xe')](_0x285cab));if(_0x285cab['error']){if(_0x285cab[_0x4816('0xf')]['code']===0x1f4){logger['error'](_0x4816('0xb'),_0x2ddb3b,_0x285cab['error']['message']);return _0x383974(_0x285cab[_0x4816('0xf')]['message']);}logger[_0x4816('0xf')](_0x4816('0xb'),_0x2ddb3b,_0x285cab[_0x4816('0xf')][_0x4816('0x10')]);return _0x170e7a(_0x285cab[_0x4816('0xf')][_0x4816('0x10')]);}else{logger[_0x4816('0xa')](_0x4816('0xb'),_0x2ddb3b,_0x4816('0xd'));_0x170e7a(_0x285cab[_0x4816('0x11')][_0x4816('0x10')]);}})[_0x4816('0x12')](function(_0x6119f){logger[_0x4816('0xf')](_0x4816('0xb'),_0x2ddb3b,_0x6119f);_0x383974(_0x6119f);});});}exports[_0x4816('0x13')]=function(_0x4803d0){var _0x5b54d4=this;return new Promise(function(_0x8d4393,_0x354fdd){return db[_0x4816('0x14')][_0x4816('0x15')](_0x4803d0[_0x4816('0x16')],{'raw':_0x4803d0[_0x4816('0x17')]?_0x4803d0[_0x4816('0x17')][_0x4816('0x18')]===undefined?!![]:![]:!![]})[_0x4816('0x9')](function(_0x53189e){logger[_0x4816('0xa')]('CreateCmHopperHistory',_0x4803d0);logger['debug'](_0x4816('0x13'),_0x4803d0,JSON[_0x4816('0xe')](_0x53189e));_0x8d4393(_0x53189e);})['catch'](function(_0x2bbaf4){logger['error'](_0x4816('0x13'),_0x2bbaf4[_0x4816('0x10')],_0x4803d0);_0x354fdd(_0x5b54d4['error'](0x1f4,_0x2bbaf4['message']));});});};exports[_0x4816('0x19')]=function(_0x2c8dc4){var _0x394ecd=this;return new Promise(function(_0x47fd5d,_0x9b1a4c){return db[_0x4816('0x14')][_0x4816('0x1a')]({'raw':_0x2c8dc4[_0x4816('0x17')]?_0x2c8dc4['options']['raw']===undefined?!![]:![]:!![],'where':_0x2c8dc4[_0x4816('0x17')]?_0x2c8dc4[_0x4816('0x17')]['where']||null:null,'attributes':[[db[_0x4816('0x1b')]['fn']('COUNT',db['sequelize'][_0x4816('0x1c')]('id')),_0x4816('0x1d')],[db[_0x4816('0x1b')]['fn']('COUNT',db[_0x4816('0x1b')]['fn']('IF',db['sequelize'][_0x4816('0x1e')](_0x4816('0x1f')))),'predictiveIntervalAnsweredCalls'],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x21')))),_0x4816('0x22')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db['sequelize']['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')]('`state`\x20=\x2011,\x201,\x20null'))),'predictiveIntervalDroppedCallsCallersExit'],[db[_0x4816('0x1b')]['fn'](_0x4816('0x23'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')]('`state`\x20=\x204,\x20`holdtime`,\x20null'))),'predictiveIntervalAvgHoldtime'],[db['sequelize']['fn'](_0x4816('0x23'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x24')))),_0x4816('0x25')]]})['then'](function(_0x1b929f){logger['info'](_0x4816('0x19'),_0x2c8dc4);logger[_0x4816('0xc')](_0x4816('0x19'),_0x2c8dc4,JSON[_0x4816('0xe')](_0x1b929f));_0x47fd5d(_0x1b929f);})[_0x4816('0x12')](function(_0x5af3f5){logger[_0x4816('0xf')]('AvgHandleTime',_0x5af3f5['message'],_0x2c8dc4);_0x9b1a4c(_0x394ecd[_0x4816('0xf')](0x1f4,_0x5af3f5['message']));});});};exports['GetVoiceQueueHopperHistory']=function(_0x55032c){var _0x543db3=this;return new Promise(function(_0x428370,_0x3e6a11){return db['CmHopperHistory'][_0x4816('0x1a')]({'raw':_0x55032c[_0x4816('0x17')]?_0x55032c['options'][_0x4816('0x18')]===undefined?!![]:![]:!![],'where':_0x55032c[_0x4816('0x17')]?_0x55032c[_0x4816('0x17')][_0x4816('0x26')]||null:null,'attributes':[['campaign',_0x4816('0x27')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x28')))),_0x4816('0x29')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')]('`state`\x20=\x203,\x201,\x20null'))),_0x4816('0x2a')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x1f')))),'outboundAnswerCallsDay'],[db[_0x4816('0x1b')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')]('`state`\x20=\x205,\x201,\x20null'))),_0x4816('0x2b')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db['sequelize']['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x2c')))),_0x4816('0x2d')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db['sequelize']['fn']('IF',db[_0x4816('0x1b')]['literal']('`state`\x20=\x2010\x20,\x201,\x20null'))),'outboundDropCallsDayTimeout'],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x2e')))),_0x4816('0x2f')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db['sequelize']['literal'](_0x4816('0x30')))),_0x4816('0x31')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x32')))),'outboundBlacklistCallsDay'],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db['sequelize']['literal'](_0x4816('0x33')))),_0x4816('0x34')],[db[_0x4816('0x1b')]['fn']('COUNT',db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x35')))),_0x4816('0x36')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db['sequelize']['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x37')))),_0x4816('0x38')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x39')))),_0x4816('0x36')],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')](_0x4816('0x3a')))),_0x4816('0x3b')]],'group':[_0x4816('0x3c')]})[_0x4816('0x9')](function(_0x1702bf){logger[_0x4816('0xa')]('GetVoiceQueueHopperHistory',_0x55032c);logger[_0x4816('0xc')](_0x4816('0x3d'),_0x55032c,JSON['stringify'](_0x1702bf));_0x428370(_0x1702bf);})[_0x4816('0x12')](function(_0xa2a654){logger[_0x4816('0xf')](_0x4816('0x3d'),_0xa2a654[_0x4816('0x10')],_0x55032c);_0x3e6a11(_0x543db3[_0x4816('0xf')](0x1f4,_0xa2a654[_0x4816('0x10')]));});});};exports[_0x4816('0x3e')]=function(_0x13739f){var _0x3cff8a=this;return new Promise(function(_0x5bbd6f,_0x11b703){return db['CmHopperHistory'][_0x4816('0x1a')]({'raw':_0x13739f[_0x4816('0x17')]?_0x13739f['options'][_0x4816('0x18')]===undefined?!![]:![]:!![],'where':_0x13739f[_0x4816('0x17')]?_0x13739f[_0x4816('0x17')][_0x4816('0x26')]||null:null,'attributes':[[_0x4816('0x3c'),'name'],[db[_0x4816('0x1b')]['fn'](_0x4816('0x20'),db[_0x4816('0x1b')][_0x4816('0x1c')]('id')),_0x4816('0x3f')],[db[_0x4816('0x1b')]['fn']('COUNT',db[_0x4816('0x1b')]['fn']('IF',db[_0x4816('0x1b')][_0x4816('0x1e')]('`state`\x20=\x204,\x201,\x20null'))),_0x4816('0x40')]],'group':[_0x4816('0x3c')]})[_0x4816('0x9')](function(_0x56cf25){logger[_0x4816('0xa')](_0x4816('0x3e'),_0x13739f);logger[_0x4816('0xc')](_0x4816('0x3e'),_0x13739f,JSON['stringify'](_0x56cf25));_0x5bbd6f(_0x56cf25);})[_0x4816('0x12')](function(_0x1f92b4){logger[_0x4816('0xf')]('GetCampaignHopperHistory',_0x1f92b4['message'],_0x13739f);_0x11b703(_0x3cff8a[_0x4816('0xf')](0x1f4,_0x1f92b4[_0x4816('0x10')]));});});};