c013226a10fcf826a1d82aa6b6f95fd7590d7c61
[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 _0x0971=['catch','CreateCmHopperHistory','CmHopperHistory','body','options','raw','then','findAll','COUNT','col','predictiveIntervalTotalCalls','sequelize','literal','`state`\x20=\x204,\x201,\x20null','predictiveIntervalAnsweredCalls','`state`\x20=\x2011,\x201,\x20null','predictiveIntervalDroppedCallsCallersExit','AVG','`state`\x20=\x204,\x20`holdtime`,\x20null','predictiveIntervalAvgTalktime','AvgHandleTime','where','campaign','name','`state`\x20=\x200,\x201,\x20null','outboundNoSuchCallsDay','`state`\x20=\x203,\x201,\x20null','outboundNoAnswerCallsDay','outboundAnswerCallsDay','`state`\x20=\x205,\x201,\x20null','outboundBusyCallsDay','`state`\x20=\x208,\x201,\x20null','outboundCongestionCallsDay','`state`\x20=\x2010\x20,\x201,\x20null','outboundDropCallsDayTimeout','`state`\x20=\x2012,\x201,\x20null','outboundUnknownCallsDay','`state`\x20=\x2013,\x201,\x20null','outboundBlacklistCallsDay','`state`\x20=\x2014,\x201,\x20null','outboundOriginateFailureCallsDay','`state`\x20=\x2018,\x201,\x20null','outboundAnswerAgiCallsDay','`state`\x20=\x2020,\x201,\x20null','outboundRejectCallsDay','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','outboundReCallsDay','GetVoiceQueueHopperHistory','GetCampaignHopperHistory','ivrTotalCallsDays','ivrAnswerCallsDay','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','request','info','CmHopperHistory,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message'];(function(_0x483ab9,_0x419148){var _0x35043b=function(_0x3453a3){while(--_0x3453a3){_0x483ab9['push'](_0x483ab9['shift']());}};_0x35043b(++_0x419148);}(_0x0971,0xc3));var _0x1097=function(_0x3e0dc4,_0x13971b){_0x3e0dc4=_0x3e0dc4-0x0;var _0x586111=_0x0971[_0x3e0dc4];return _0x586111;};'use strict';var _=require(_0x1097('0x0'));var util=require(_0x1097('0x1'));var moment=require(_0x1097('0x2'));var BPromise=require(_0x1097('0x3'));var rs=require(_0x1097('0x4'));var fs=require('fs');var Redis=require(_0x1097('0x5'));var db=require(_0x1097('0x6'))['db'];var utils=require(_0x1097('0x7'));var logger=require('../../config/logger')('rpc');var config=require(_0x1097('0x8'));var jayson=require(_0x1097('0x9'));var client=jayson[_0x1097('0xa')][_0x1097('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x24726c,_0x111e0c,_0x35741d){return new BPromise(function(_0x5a1204,_0x1cd7a1){return client[_0x1097('0xc')](_0x24726c,_0x35741d)['then'](function(_0x1fa804){logger[_0x1097('0xd')](_0x1097('0xe'),_0x111e0c,'request\x20sent');logger[_0x1097('0xf')]('CmHopperHistory,\x20%s,\x20%s,\x20%s',_0x111e0c,_0x1097('0x10'),JSON[_0x1097('0x11')](_0x1fa804));if(_0x1fa804[_0x1097('0x12')]){if(_0x1fa804[_0x1097('0x12')][_0x1097('0x13')]===0x1f4){logger[_0x1097('0x12')](_0x1097('0xe'),_0x111e0c,_0x1fa804['error']['message']);return _0x1cd7a1(_0x1fa804['error'][_0x1097('0x14')]);}logger['error'](_0x1097('0xe'),_0x111e0c,_0x1fa804[_0x1097('0x12')][_0x1097('0x14')]);return _0x5a1204(_0x1fa804[_0x1097('0x12')][_0x1097('0x14')]);}else{logger[_0x1097('0xd')](_0x1097('0xe'),_0x111e0c,_0x1097('0x10'));_0x5a1204(_0x1fa804['result']['message']);}})[_0x1097('0x15')](function(_0x2c05f1){logger[_0x1097('0x12')](_0x1097('0xe'),_0x111e0c,_0x2c05f1);_0x1cd7a1(_0x2c05f1);});});}exports[_0x1097('0x16')]=function(_0x563040){var _0x13da30=this;return new Promise(function(_0x1aa2b1,_0x516cfb){return db[_0x1097('0x17')]['create'](_0x563040[_0x1097('0x18')],{'raw':_0x563040[_0x1097('0x19')]?_0x563040[_0x1097('0x19')][_0x1097('0x1a')]===undefined?!![]:![]:!![]})[_0x1097('0x1b')](function(_0x18a5ae){logger['info'](_0x1097('0x16'),_0x563040);logger[_0x1097('0xf')](_0x1097('0x16'),_0x563040,JSON['stringify'](_0x18a5ae));_0x1aa2b1(_0x18a5ae);})[_0x1097('0x15')](function(_0x89cb7c){logger[_0x1097('0x12')](_0x1097('0x16'),_0x89cb7c[_0x1097('0x14')],_0x563040);_0x516cfb(_0x13da30[_0x1097('0x12')](0x1f4,_0x89cb7c[_0x1097('0x14')]));});});};exports['AvgHandleTime']=function(_0x4b7ca7){var _0x50b9f6=this;return new Promise(function(_0x311e57,_0x36ba42){return db[_0x1097('0x17')][_0x1097('0x1c')]({'raw':_0x4b7ca7[_0x1097('0x19')]?_0x4b7ca7['options'][_0x1097('0x1a')]===undefined?!![]:![]:!![],'where':_0x4b7ca7[_0x1097('0x19')]?_0x4b7ca7['options']['where']||null:null,'attributes':[[db['sequelize']['fn'](_0x1097('0x1d'),db['sequelize'][_0x1097('0x1e')]('id')),_0x1097('0x1f')],[db[_0x1097('0x20')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x1097('0x20')][_0x1097('0x21')](_0x1097('0x22')))),_0x1097('0x23')],[db['sequelize']['fn']('COUNT',db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')][_0x1097('0x21')]('`state`\x20=\x2010,\x201,\x20null'))),'predictiveIntervalDroppedCallsTimeout'],[db[_0x1097('0x20')]['fn'](_0x1097('0x1d'),db['sequelize']['fn']('IF',db['sequelize']['literal'](_0x1097('0x24')))),_0x1097('0x25')],[db[_0x1097('0x20')]['fn'](_0x1097('0x26'),db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')][_0x1097('0x21')](_0x1097('0x27')))),'predictiveIntervalAvgHoldtime'],[db['sequelize']['fn'](_0x1097('0x26'),db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')]['literal']('`state`\x20=\x204,\x20`talktime`,\x20null'))),_0x1097('0x28')]]})[_0x1097('0x1b')](function(_0x3dbb9a){logger[_0x1097('0xd')](_0x1097('0x29'),_0x4b7ca7);logger[_0x1097('0xf')](_0x1097('0x29'),_0x4b7ca7,JSON[_0x1097('0x11')](_0x3dbb9a));_0x311e57(_0x3dbb9a);})[_0x1097('0x15')](function(_0x16b984){logger[_0x1097('0x12')](_0x1097('0x29'),_0x16b984['message'],_0x4b7ca7);_0x36ba42(_0x50b9f6[_0x1097('0x12')](0x1f4,_0x16b984[_0x1097('0x14')]));});});};exports['GetVoiceQueueHopperHistory']=function(_0x44f77a){var _0x52be67=this;return new Promise(function(_0x10a3c2,_0x5f1696){return db[_0x1097('0x17')][_0x1097('0x1c')]({'raw':_0x44f77a[_0x1097('0x19')]?_0x44f77a[_0x1097('0x19')][_0x1097('0x1a')]===undefined?!![]:![]:!![],'where':_0x44f77a[_0x1097('0x19')]?_0x44f77a[_0x1097('0x19')][_0x1097('0x2a')]||null:null,'attributes':[[_0x1097('0x2b'),_0x1097('0x2c')],[db[_0x1097('0x20')]['fn'](_0x1097('0x1d'),db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')][_0x1097('0x21')](_0x1097('0x2d')))),_0x1097('0x2e')],[db['sequelize']['fn'](_0x1097('0x1d'),db[_0x1097('0x20')]['fn']('IF',db['sequelize']['literal'](_0x1097('0x2f')))),_0x1097('0x30')],[db[_0x1097('0x20')]['fn'](_0x1097('0x1d'),db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')][_0x1097('0x21')](_0x1097('0x22')))),_0x1097('0x31')],[db[_0x1097('0x20')]['fn'](_0x1097('0x1d'),db[_0x1097('0x20')]['fn']('IF',db['sequelize'][_0x1097('0x21')](_0x1097('0x32')))),_0x1097('0x33')],[db[_0x1097('0x20')]['fn']('COUNT',db[_0x1097('0x20')]['fn']('IF',db['sequelize'][_0x1097('0x21')](_0x1097('0x34')))),_0x1097('0x35')],[db['sequelize']['fn'](_0x1097('0x1d'),db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')]['literal'](_0x1097('0x36')))),_0x1097('0x37')],[db['sequelize']['fn']('COUNT',db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')]['literal']('`state`\x20=\x2011\x20,\x201,\x20null'))),'outboundDropCallsDayCallersExit'],[db[_0x1097('0x20')]['fn']('COUNT',db['sequelize']['fn']('IF',db['sequelize'][_0x1097('0x21')](_0x1097('0x38')))),_0x1097('0x39')],[db[_0x1097('0x20')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x1097('0x20')][_0x1097('0x21')](_0x1097('0x3a')))),_0x1097('0x3b')],[db[_0x1097('0x20')]['fn']('COUNT',db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')][_0x1097('0x21')](_0x1097('0x3c')))),_0x1097('0x3d')],[db[_0x1097('0x20')]['fn'](_0x1097('0x1d'),db[_0x1097('0x20')]['fn']('IF',db[_0x1097('0x20')][_0x1097('0x21')](_0x1097('0x3e')))),'outboundRejectCallsDay'],[db[_0x1097('0x20')]['fn'](_0x1097('0x1d'),db[_0x1097('0x20')]['fn']('IF',db['sequelize'][_0x1097('0x21')]('`state`\x20=\x2016,\x201,\x20null'))),_0x1097('0x3f')],[db[_0x1097('0x20')]['fn'](_0x1097('0x1d'),db[_0x1097('0x20')]['fn']('IF',db['sequelize'][_0x1097('0x21')](_0x1097('0x40')))),_0x1097('0x41')],[db[_0x1097('0x20')]['fn'](_0x1097('0x1d'),db['sequelize']['fn']('IF',db[_0x1097('0x20')]['literal'](_0x1097('0x42')))),_0x1097('0x43')]],'group':['campaign']})['then'](function(_0x4e56e7){logger[_0x1097('0xd')]('GetVoiceQueueHopperHistory',_0x44f77a);logger['debug'](_0x1097('0x44'),_0x44f77a,JSON[_0x1097('0x11')](_0x4e56e7));_0x10a3c2(_0x4e56e7);})['catch'](function(_0x116769){logger[_0x1097('0x12')](_0x1097('0x44'),_0x116769['message'],_0x44f77a);_0x5f1696(_0x52be67[_0x1097('0x12')](0x1f4,_0x116769[_0x1097('0x14')]));});});};exports[_0x1097('0x45')]=function(_0xab70af){var _0x3f4dc8=this;return new Promise(function(_0x30d7fe,_0x58d250){return db[_0x1097('0x17')]['findAll']({'raw':_0xab70af[_0x1097('0x19')]?_0xab70af['options'][_0x1097('0x1a')]===undefined?!![]:![]:!![],'where':_0xab70af['options']?_0xab70af['options'][_0x1097('0x2a')]||null:null,'attributes':[[_0x1097('0x2b'),'name'],[db['sequelize']['fn'](_0x1097('0x1d'),db[_0x1097('0x20')][_0x1097('0x1e')]('id')),_0x1097('0x46')],[db[_0x1097('0x20')]['fn']('COUNT',db[_0x1097('0x20')]['fn']('IF',db['sequelize'][_0x1097('0x21')](_0x1097('0x22')))),_0x1097('0x47')]],'group':[_0x1097('0x2b')]})['then'](function(_0x3830dc){logger[_0x1097('0xd')](_0x1097('0x45'),_0xab70af);logger[_0x1097('0xf')](_0x1097('0x45'),_0xab70af,JSON[_0x1097('0x11')](_0x3830dc));_0x30d7fe(_0x3830dc);})['catch'](function(_0x37262f){logger[_0x1097('0x12')]('GetCampaignHopperHistory',_0x37262f[_0x1097('0x14')],_0xab70af);_0x58d250(_0x3f4dc8[_0x1097('0x12')](0x1f4,_0x37262f[_0x1097('0x14')]));});});};