Built motion from commit (unavailable).|2.4.4
[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 _0x05b6=['catch','CreateCmHopperHistory','CmHopperHistory','body','options','debug','AvgHandleTime','findAll','sequelize','col','literal','`state`\x20=\x204,\x201,\x20null','predictiveIntervalAnsweredCalls','COUNT','predictiveIntervalDroppedCallsTimeout','`state`\x20=\x2011,\x201,\x20null','predictiveIntervalDroppedCallsCallersExit','AVG','predictiveIntervalAvgHoldtime','`state`\x20=\x204,\x20`talktime`,\x20null','predictiveIntervalAvgTalktime','GetVoiceQueueHopperHistory','raw','name','`state`\x20=\x200,\x201,\x20null','outboundNoSuchCallsDay','outboundNoAnswerCallsDay','outboundAnswerCallsDay','`state`\x20=\x205,\x201,\x20null','outboundBusyCallsDay','outboundCongestionCallsDay','`state`\x20=\x2010\x20,\x201,\x20null','outboundDropCallsDayTimeout','`state`\x20=\x2012,\x201,\x20null','`state`\x20=\x2013,\x201,\x20null','outboundBlacklistCallsDay','`state`\x20=\x2014,\x201,\x20null','outboundOriginateFailureCallsDay','outboundRejectCallsDay','`state`\x20=\x2016,\x201,\x20null','outboundAnswerAgiCallsDay','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','GetCampaignHopperHistory','where','campaign','ivrAnswerCallsDay','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','CmHopperHistory,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','CmHopperHistory,\x20%s,\x20%s','message','result'];(function(_0x38eb23,_0x196e8b){var _0x48506a=function(_0x36edb0){while(--_0x36edb0){_0x38eb23['push'](_0x38eb23['shift']());}};_0x48506a(++_0x196e8b);}(_0x05b6,0x74));var _0x605b=function(_0x24f862,_0x4b645a){_0x24f862=_0x24f862-0x0;var _0x198aa4=_0x05b6[_0x24f862];return _0x198aa4;};'use strict';var _=require(_0x605b('0x0'));var util=require('util');var moment=require(_0x605b('0x1'));var BPromise=require(_0x605b('0x2'));var rs=require(_0x605b('0x3'));var fs=require('fs');var Redis=require(_0x605b('0x4'));var db=require(_0x605b('0x5'))['db'];var utils=require(_0x605b('0x6'));var logger=require(_0x605b('0x7'))(_0x605b('0x8'));var config=require(_0x605b('0x9'));var jayson=require(_0x605b('0xa'));var client=jayson[_0x605b('0xb')][_0x605b('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x2c2138,_0x2a81ca,_0x37b8b1){return new BPromise(function(_0x275ed3,_0xb5dd63){return client[_0x605b('0xd')](_0x2c2138,_0x37b8b1)[_0x605b('0xe')](function(_0x49936a){logger[_0x605b('0xf')]('CmHopperHistory,\x20%s,\x20%s',_0x2a81ca,'request\x20sent');logger['debug'](_0x605b('0x10'),_0x2a81ca,_0x605b('0x11'),JSON[_0x605b('0x12')](_0x49936a));if(_0x49936a[_0x605b('0x13')]){if(_0x49936a[_0x605b('0x13')][_0x605b('0x14')]===0x1f4){logger[_0x605b('0x13')](_0x605b('0x15'),_0x2a81ca,_0x49936a[_0x605b('0x13')][_0x605b('0x16')]);return _0xb5dd63(_0x49936a[_0x605b('0x13')][_0x605b('0x16')]);}logger[_0x605b('0x13')](_0x605b('0x15'),_0x2a81ca,_0x49936a['error'][_0x605b('0x16')]);return _0x275ed3(_0x49936a[_0x605b('0x13')]['message']);}else{logger['info']('CmHopperHistory,\x20%s,\x20%s',_0x2a81ca,_0x605b('0x11'));_0x275ed3(_0x49936a[_0x605b('0x17')]['message']);}})[_0x605b('0x18')](function(_0x262f2a){logger[_0x605b('0x13')](_0x605b('0x15'),_0x2a81ca,_0x262f2a);_0xb5dd63(_0x262f2a);});});}exports[_0x605b('0x19')]=function(_0x5974f8){var _0xc383d2=this;return new Promise(function(_0x1233a5,_0x54c1a1){return db[_0x605b('0x1a')]['create'](_0x5974f8[_0x605b('0x1b')],{'raw':_0x5974f8[_0x605b('0x1c')]?_0x5974f8[_0x605b('0x1c')]['raw']===undefined?!![]:![]:!![]})[_0x605b('0xe')](function(_0x33db86){logger[_0x605b('0xf')](_0x605b('0x19'),_0x5974f8);logger[_0x605b('0x1d')](_0x605b('0x19'),_0x5974f8,JSON[_0x605b('0x12')](_0x33db86));_0x1233a5(_0x33db86);})['catch'](function(_0x20fcf9){logger[_0x605b('0x13')](_0x605b('0x19'),_0x20fcf9[_0x605b('0x16')],_0x5974f8);_0x54c1a1(_0xc383d2[_0x605b('0x13')](0x1f4,_0x20fcf9[_0x605b('0x16')]));});});};exports[_0x605b('0x1e')]=function(_0x5245b7){var _0x5de6f3=this;return new Promise(function(_0x4114a5,_0x4996da){return db['CmHopperHistory'][_0x605b('0x1f')]({'raw':_0x5245b7[_0x605b('0x1c')]?_0x5245b7[_0x605b('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x5245b7['options']?_0x5245b7[_0x605b('0x1c')]['where']||null:null,'attributes':[[db[_0x605b('0x20')]['fn']('COUNT',db[_0x605b('0x20')][_0x605b('0x21')]('id')),'predictiveIntervalTotalCalls'],[db[_0x605b('0x20')]['fn']('COUNT',db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')](_0x605b('0x23')))),_0x605b('0x24')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')]('`state`\x20=\x2010,\x201,\x20null'))),_0x605b('0x26')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db['sequelize'][_0x605b('0x22')](_0x605b('0x27')))),_0x605b('0x28')],[db['sequelize']['fn'](_0x605b('0x29'),db[_0x605b('0x20')]['fn']('IF',db['sequelize'][_0x605b('0x22')]('`state`\x20=\x204,\x20`holdtime`,\x20null'))),_0x605b('0x2a')],[db['sequelize']['fn'](_0x605b('0x29'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')]['literal'](_0x605b('0x2b')))),_0x605b('0x2c')]]})[_0x605b('0xe')](function(_0x29317d){logger[_0x605b('0xf')](_0x605b('0x1e'),_0x5245b7);logger[_0x605b('0x1d')](_0x605b('0x1e'),_0x5245b7,JSON['stringify'](_0x29317d));_0x4114a5(_0x29317d);})[_0x605b('0x18')](function(_0x1e853){logger['error']('AvgHandleTime',_0x1e853['message'],_0x5245b7);_0x4996da(_0x5de6f3[_0x605b('0x13')](0x1f4,_0x1e853[_0x605b('0x16')]));});});};exports[_0x605b('0x2d')]=function(_0x1bb4e8){var _0x38d726=this;return new Promise(function(_0x17428e,_0x4ce170){return db[_0x605b('0x1a')][_0x605b('0x1f')]({'raw':_0x1bb4e8[_0x605b('0x1c')]?_0x1bb4e8[_0x605b('0x1c')][_0x605b('0x2e')]===undefined?!![]:![]:!![],'where':_0x1bb4e8[_0x605b('0x1c')]?_0x1bb4e8[_0x605b('0x1c')]['where']||null:null,'attributes':[['campaign',_0x605b('0x2f')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db['sequelize'][_0x605b('0x22')](_0x605b('0x30')))),_0x605b('0x31')],[db['sequelize']['fn']('COUNT',db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')]['literal']('`state`\x20=\x203,\x201,\x20null'))),_0x605b('0x32')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')](_0x605b('0x23')))),_0x605b('0x33')],[db['sequelize']['fn'](_0x605b('0x25'),db['sequelize']['fn']('IF',db[_0x605b('0x20')]['literal'](_0x605b('0x34')))),_0x605b('0x35')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')]('`state`\x20=\x208,\x201,\x20null'))),_0x605b('0x36')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')](_0x605b('0x37')))),_0x605b('0x38')],[db['sequelize']['fn'](_0x605b('0x25'),db['sequelize']['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')]('`state`\x20=\x2011\x20,\x201,\x20null'))),'outboundDropCallsDayCallersExit'],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')](_0x605b('0x39')))),'outboundUnknownCallsDay'],[db['sequelize']['fn']('COUNT',db[_0x605b('0x20')]['fn']('IF',db['sequelize']['literal'](_0x605b('0x3a')))),_0x605b('0x3b')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')](_0x605b('0x3c')))),_0x605b('0x3d')],[db['sequelize']['fn'](_0x605b('0x25'),db['sequelize']['fn']('IF',db['sequelize'][_0x605b('0x22')]('`state`\x20=\x2018,\x201,\x20null'))),_0x605b('0x3e')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')](_0x605b('0x3f')))),_0x605b('0x40')],[db['sequelize']['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')]('`state`\x20=\x2020,\x201,\x20null'))),_0x605b('0x3e')],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')](_0x605b('0x41')))),'outboundReCallsDay']],'group':['campaign']})[_0x605b('0xe')](function(_0x10b95d){logger['info'](_0x605b('0x2d'),_0x1bb4e8);logger['debug'](_0x605b('0x2d'),_0x1bb4e8,JSON[_0x605b('0x12')](_0x10b95d));_0x17428e(_0x10b95d);})['catch'](function(_0x504922){logger[_0x605b('0x13')](_0x605b('0x2d'),_0x504922['message'],_0x1bb4e8);_0x4ce170(_0x38d726[_0x605b('0x13')](0x1f4,_0x504922[_0x605b('0x16')]));});});};exports[_0x605b('0x42')]=function(_0x1f75bf){var _0x51e939=this;return new Promise(function(_0x4b0753,_0x1ce7e7){return db['CmHopperHistory'][_0x605b('0x1f')]({'raw':_0x1f75bf[_0x605b('0x1c')]?_0x1f75bf['options'][_0x605b('0x2e')]===undefined?!![]:![]:!![],'where':_0x1f75bf['options']?_0x1f75bf['options'][_0x605b('0x43')]||null:null,'attributes':[[_0x605b('0x44'),'name'],[db['sequelize']['fn']('COUNT',db[_0x605b('0x20')][_0x605b('0x21')]('id')),'ivrTotalCallsDays'],[db[_0x605b('0x20')]['fn'](_0x605b('0x25'),db[_0x605b('0x20')]['fn']('IF',db[_0x605b('0x20')][_0x605b('0x22')]('`state`\x20=\x204,\x201,\x20null'))),_0x605b('0x45')]],'group':['campaign']})[_0x605b('0xe')](function(_0x2da80d){logger[_0x605b('0xf')](_0x605b('0x42'),_0x1f75bf);logger[_0x605b('0x1d')]('GetCampaignHopperHistory',_0x1f75bf,JSON[_0x605b('0x12')](_0x2da80d));_0x4b0753(_0x2da80d);})[_0x605b('0x18')](function(_0x30fd40){logger[_0x605b('0x13')](_0x605b('0x42'),_0x30fd40[_0x605b('0x16')],_0x1f75bf);_0x1ce7e7(_0x51e939[_0x605b('0x13')](0x1f4,_0x30fd40['message']));});});};