Built motion from commit (unavailable).|2.5.21
[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 _0xf388=['`state`\x20=\x2012,\x201,\x20null','outboundUnknownCallsDay','`state`\x20=\x2013,\x201,\x20null','outboundBlacklistCallsDay','`state`\x20=\x2014,\x201,\x20null','`state`\x20=\x2018,\x201,\x20null','`state`\x20=\x2016,\x201,\x20null','outboundAnswerAgiCallsDay','`state`\x20=\x2020,\x201,\x20null','outboundRejectCallsDay','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','outboundReCallsDay','ivrAnswerCallsDay','GetCampaignHopperHistory','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','request','then','CmHopperHistory,\x20%s,\x20%s','request\x20sent','debug','CmHopperHistory,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','create','body','options','raw','CreateCmHopperHistory','AvgHandleTime','CmHopperHistory','findAll','where','COUNT','sequelize','col','predictiveIntervalTotalCalls','literal','`state`\x20=\x204,\x201,\x20null','`state`\x20=\x2010,\x201,\x20null','`state`\x20=\x2011,\x201,\x20null','predictiveIntervalDroppedCallsCallersExit','AVG','`state`\x20=\x204,\x20`holdtime`,\x20null','predictiveIntervalAvgHoldtime','`state`\x20=\x204,\x20`talktime`,\x20null','predictiveIntervalAvgTalktime','GetVoiceQueueHopperHistory','campaign','name','`state`\x20=\x200,\x201,\x20null','`state`\x20=\x203,\x201,\x20null','outboundAnswerCallsDay','`state`\x20=\x205,\x201,\x20null','outboundBusyCallsDay','`state`\x20=\x208,\x201,\x20null','outboundCongestionCallsDay','outboundDropCallsDayTimeout','outboundDropCallsDayCallersExit'];(function(_0x102323,_0x4d3d95){var _0x234e42=function(_0x2a2f93){while(--_0x2a2f93){_0x102323['push'](_0x102323['shift']());}};_0x234e42(++_0x4d3d95);}(_0xf388,0xe0));var _0x8f38=function(_0xf8b747,_0x146c26){_0xf8b747=_0xf8b747-0x0;var _0xcf0206=_0xf388[_0xf8b747];return _0xcf0206;};'use strict';var _=require('lodash');var util=require(_0x8f38('0x0'));var moment=require(_0x8f38('0x1'));var BPromise=require('bluebird');var rs=require(_0x8f38('0x2'));var fs=require('fs');var Redis=require(_0x8f38('0x3'));var db=require(_0x8f38('0x4'))['db'];var utils=require(_0x8f38('0x5'));var logger=require(_0x8f38('0x6'))('rpc');var config=require('../../config/environment');var jayson=require(_0x8f38('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x34d638,_0x376b82,_0x3aef32){return new BPromise(function(_0x3cfaba,_0x2d285f){return client[_0x8f38('0x8')](_0x34d638,_0x3aef32)[_0x8f38('0x9')](function(_0x5429ae){logger['info'](_0x8f38('0xa'),_0x376b82,_0x8f38('0xb'));logger[_0x8f38('0xc')](_0x8f38('0xd'),_0x376b82,'request\x20sent',JSON[_0x8f38('0xe')](_0x5429ae));if(_0x5429ae['error']){if(_0x5429ae[_0x8f38('0xf')][_0x8f38('0x10')]===0x1f4){logger['error'](_0x8f38('0xa'),_0x376b82,_0x5429ae[_0x8f38('0xf')][_0x8f38('0x11')]);return _0x2d285f(_0x5429ae['error'][_0x8f38('0x11')]);}logger['error']('CmHopperHistory,\x20%s,\x20%s',_0x376b82,_0x5429ae[_0x8f38('0xf')][_0x8f38('0x11')]);return _0x3cfaba(_0x5429ae[_0x8f38('0xf')][_0x8f38('0x11')]);}else{logger[_0x8f38('0x12')](_0x8f38('0xa'),_0x376b82,_0x8f38('0xb'));_0x3cfaba(_0x5429ae[_0x8f38('0x13')][_0x8f38('0x11')]);}})[_0x8f38('0x14')](function(_0x26dd6b){logger['error'](_0x8f38('0xa'),_0x376b82,_0x26dd6b);_0x2d285f(_0x26dd6b);});});}exports['CreateCmHopperHistory']=function(_0x45358e){var _0x27ea67=this;return new Promise(function(_0x1d8958,_0x40e8a9){return db['CmHopperHistory'][_0x8f38('0x15')](_0x45358e[_0x8f38('0x16')],{'raw':_0x45358e[_0x8f38('0x17')]?_0x45358e[_0x8f38('0x17')][_0x8f38('0x18')]===undefined?!![]:![]:!![]})[_0x8f38('0x9')](function(_0x1aef8c){logger['info'](_0x8f38('0x19'),_0x45358e);logger[_0x8f38('0xc')]('CreateCmHopperHistory',_0x45358e,JSON[_0x8f38('0xe')](_0x1aef8c));_0x1d8958(_0x1aef8c);})['catch'](function(_0x5d288d){logger['error'](_0x8f38('0x19'),_0x5d288d[_0x8f38('0x11')],_0x45358e);_0x40e8a9(_0x27ea67['error'](0x1f4,_0x5d288d[_0x8f38('0x11')]));});});};exports[_0x8f38('0x1a')]=function(_0x2c35aa){var _0x3cd2c6=this;return new Promise(function(_0x539685,_0x588200){return db[_0x8f38('0x1b')][_0x8f38('0x1c')]({'raw':_0x2c35aa[_0x8f38('0x17')]?_0x2c35aa[_0x8f38('0x17')][_0x8f38('0x18')]===undefined?!![]:![]:!![],'where':_0x2c35aa[_0x8f38('0x17')]?_0x2c35aa['options'][_0x8f38('0x1d')]||null:null,'attributes':[[db['sequelize']['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')][_0x8f38('0x20')]('id')),_0x8f38('0x21')],[db[_0x8f38('0x1f')]['fn']('COUNT',db[_0x8f38('0x1f')]['fn']('IF',db['sequelize'][_0x8f38('0x22')](_0x8f38('0x23')))),'predictiveIntervalAnsweredCalls'],[db['sequelize']['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')]['literal'](_0x8f38('0x24')))),'predictiveIntervalDroppedCallsTimeout'],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x25')))),_0x8f38('0x26')],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x27'),db[_0x8f38('0x1f')]['fn']('IF',db['sequelize'][_0x8f38('0x22')](_0x8f38('0x28')))),_0x8f38('0x29')],[db[_0x8f38('0x1f')]['fn']('AVG',db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x2a')))),_0x8f38('0x2b')]]})[_0x8f38('0x9')](function(_0x13ae9b){logger[_0x8f38('0x12')]('AvgHandleTime',_0x2c35aa);logger[_0x8f38('0xc')](_0x8f38('0x1a'),_0x2c35aa,JSON[_0x8f38('0xe')](_0x13ae9b));_0x539685(_0x13ae9b);})['catch'](function(_0x31a860){logger[_0x8f38('0xf')]('AvgHandleTime',_0x31a860[_0x8f38('0x11')],_0x2c35aa);_0x588200(_0x3cd2c6[_0x8f38('0xf')](0x1f4,_0x31a860[_0x8f38('0x11')]));});});};exports[_0x8f38('0x2c')]=function(_0x1ef1ab){var _0x2cdb99=this;return new Promise(function(_0x1e8a17,_0x5e4208){return db['CmHopperHistory']['findAll']({'raw':_0x1ef1ab[_0x8f38('0x17')]?_0x1ef1ab[_0x8f38('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x1ef1ab[_0x8f38('0x17')]?_0x1ef1ab[_0x8f38('0x17')]['where']||null:null,'attributes':[[_0x8f38('0x2d'),_0x8f38('0x2e')],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x1e'),db['sequelize']['fn']('IF',db['sequelize'][_0x8f38('0x22')](_0x8f38('0x2f')))),'outboundNoSuchCallsDay'],[db[_0x8f38('0x1f')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x30')))),'outboundNoAnswerCallsDay'],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')]('`state`\x20=\x204,\x201,\x20null'))),_0x8f38('0x31')],[db[_0x8f38('0x1f')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x32')))),_0x8f38('0x33')],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')]['literal'](_0x8f38('0x34')))),_0x8f38('0x35')],[db['sequelize']['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')]('`state`\x20=\x2010\x20,\x201,\x20null'))),_0x8f38('0x36')],[db[_0x8f38('0x1f')]['fn']('COUNT',db[_0x8f38('0x1f')]['fn']('IF',db['sequelize'][_0x8f38('0x22')]('`state`\x20=\x2011\x20,\x201,\x20null'))),_0x8f38('0x37')],[db[_0x8f38('0x1f')]['fn']('COUNT',db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')]['literal'](_0x8f38('0x38')))),_0x8f38('0x39')],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x3a')))),_0x8f38('0x3b')],[db['sequelize']['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x3c')))),'outboundOriginateFailureCallsDay'],[db[_0x8f38('0x1f')]['fn']('COUNT',db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x3d')))),'outboundRejectCallsDay'],[db['sequelize']['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x3e')))),_0x8f38('0x3f')],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x40')))),_0x8f38('0x41')],[db[_0x8f38('0x1f')]['fn']('COUNT',db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')](_0x8f38('0x42')))),_0x8f38('0x43')]],'group':[_0x8f38('0x2d')]})[_0x8f38('0x9')](function(_0x1af0e8){logger[_0x8f38('0x12')](_0x8f38('0x2c'),_0x1ef1ab);logger[_0x8f38('0xc')]('GetVoiceQueueHopperHistory',_0x1ef1ab,JSON[_0x8f38('0xe')](_0x1af0e8));_0x1e8a17(_0x1af0e8);})[_0x8f38('0x14')](function(_0x596456){logger[_0x8f38('0xf')](_0x8f38('0x2c'),_0x596456['message'],_0x1ef1ab);_0x5e4208(_0x2cdb99[_0x8f38('0xf')](0x1f4,_0x596456['message']));});});};exports['GetCampaignHopperHistory']=function(_0x5c223a){var _0x1490c1=this;return new Promise(function(_0x58ead9,_0xeaa5ac){return db[_0x8f38('0x1b')][_0x8f38('0x1c')]({'raw':_0x5c223a['options']?_0x5c223a[_0x8f38('0x17')][_0x8f38('0x18')]===undefined?!![]:![]:!![],'where':_0x5c223a['options']?_0x5c223a[_0x8f38('0x17')][_0x8f38('0x1d')]||null:null,'attributes':[['campaign',_0x8f38('0x2e')],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')][_0x8f38('0x20')]('id')),'ivrTotalCallsDays'],[db[_0x8f38('0x1f')]['fn'](_0x8f38('0x1e'),db[_0x8f38('0x1f')]['fn']('IF',db[_0x8f38('0x1f')][_0x8f38('0x22')]('`state`\x20=\x204,\x201,\x20null'))),_0x8f38('0x44')]],'group':[_0x8f38('0x2d')]})[_0x8f38('0x9')](function(_0x626c8a){logger[_0x8f38('0x12')](_0x8f38('0x45'),_0x5c223a);logger['debug'](_0x8f38('0x45'),_0x5c223a,JSON[_0x8f38('0xe')](_0x626c8a));_0x58ead9(_0x626c8a);})['catch'](function(_0x5c8520){logger[_0x8f38('0xf')]('GetCampaignHopperHistory',_0x5c8520[_0x8f38('0x11')],_0x5c223a);_0xeaa5ac(_0x1490c1[_0x8f38('0xf')](0x1f4,_0x5c8520['message']));});});};