Built motion from commit bab6f49e.|2.6.17
[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 _0x4e09=['GetVoiceQueueHopperHistory','findAll','campaign','name','`state`\x20=\x200,\x201,\x20null','outboundNoSuchCallsDay','`state`\x20=\x203,\x201,\x20null','outboundAnswerCallsDay','outboundBusyCallsDay','`state`\x20=\x208,\x201,\x20null','`state`\x20=\x2010\x20,\x201,\x20null','`state`\x20=\x2011\x20,\x201,\x20null','outboundDropCallsDayCallersExit','`state`\x20=\x2012,\x201,\x20null','outboundUnknownCallsDay','`state`\x20=\x2014,\x201,\x20null','outboundOriginateFailureCallsDay','`state`\x20=\x2018,\x201,\x20null','outboundRejectCallsDay','`state`\x20=\x2016,\x201,\x20null','outboundAnswerAgiCallsDay','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','outboundReCallsDay','ivrTotalCallsDays','ivrAnswerCallsDay','GetCampaignHopperHistory','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','CmHopperHistory,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','CreateCmHopperHistory','CmHopperHistory','body','options','raw','info','debug','AvgHandleTime','where','sequelize','COUNT','col','predictiveIntervalTotalCalls','literal','`state`\x20=\x204,\x201,\x20null','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsCallersExit','`state`\x20=\x204,\x20`holdtime`,\x20null','predictiveIntervalAvgHoldtime','AVG','`state`\x20=\x204,\x20`talktime`,\x20null','predictiveIntervalAvgTalktime'];(function(_0x3ad57a,_0x12ee6c){var _0xf60ddc=function(_0x2360dd){while(--_0x2360dd){_0x3ad57a['push'](_0x3ad57a['shift']());}};_0xf60ddc(++_0x12ee6c);}(_0x4e09,0xa2));var _0x94e0=function(_0x413feb,_0x10477f){_0x413feb=_0x413feb-0x0;var _0x40ee88=_0x4e09[_0x413feb];return _0x40ee88;};'use strict';var _=require(_0x94e0('0x0'));var util=require('util');var moment=require(_0x94e0('0x1'));var BPromise=require('bluebird');var rs=require(_0x94e0('0x2'));var fs=require('fs');var Redis=require(_0x94e0('0x3'));var db=require(_0x94e0('0x4'))['db'];var utils=require(_0x94e0('0x5'));var logger=require(_0x94e0('0x6'))(_0x94e0('0x7'));var config=require(_0x94e0('0x8'));var jayson=require(_0x94e0('0x9'));var client=jayson[_0x94e0('0xa')][_0x94e0('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x198399,_0x4ead23,_0xa0620){return new BPromise(function(_0x45350e,_0x27a12c){return client['request'](_0x198399,_0xa0620)[_0x94e0('0xc')](function(_0x2536f0){logger['info'](_0x94e0('0xd'),_0x4ead23,_0x94e0('0xe'));logger['debug']('CmHopperHistory,\x20%s,\x20%s,\x20%s',_0x4ead23,_0x94e0('0xe'),JSON[_0x94e0('0xf')](_0x2536f0));if(_0x2536f0[_0x94e0('0x10')]){if(_0x2536f0[_0x94e0('0x10')]['code']===0x1f4){logger[_0x94e0('0x10')]('CmHopperHistory,\x20%s,\x20%s',_0x4ead23,_0x2536f0[_0x94e0('0x10')][_0x94e0('0x11')]);return _0x27a12c(_0x2536f0[_0x94e0('0x10')]['message']);}logger['error'](_0x94e0('0xd'),_0x4ead23,_0x2536f0[_0x94e0('0x10')][_0x94e0('0x11')]);return _0x45350e(_0x2536f0[_0x94e0('0x10')][_0x94e0('0x11')]);}else{logger['info'](_0x94e0('0xd'),_0x4ead23,_0x94e0('0xe'));_0x45350e(_0x2536f0[_0x94e0('0x12')][_0x94e0('0x11')]);}})[_0x94e0('0x13')](function(_0x3480bb){logger[_0x94e0('0x10')](_0x94e0('0xd'),_0x4ead23,_0x3480bb);_0x27a12c(_0x3480bb);});});}exports[_0x94e0('0x14')]=function(_0x2341a4){var _0x4143c3=this;return new Promise(function(_0x2b3004,_0x8071c5){return db[_0x94e0('0x15')]['create'](_0x2341a4[_0x94e0('0x16')],{'raw':_0x2341a4['options']?_0x2341a4[_0x94e0('0x17')][_0x94e0('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x44921d){logger[_0x94e0('0x19')](_0x94e0('0x14'),_0x2341a4);logger[_0x94e0('0x1a')]('CreateCmHopperHistory',_0x2341a4,JSON[_0x94e0('0xf')](_0x44921d));_0x2b3004(_0x44921d);})[_0x94e0('0x13')](function(_0x3db0b4){logger[_0x94e0('0x10')](_0x94e0('0x14'),_0x3db0b4[_0x94e0('0x11')],_0x2341a4);_0x8071c5(_0x4143c3[_0x94e0('0x10')](0x1f4,_0x3db0b4[_0x94e0('0x11')]));});});};exports[_0x94e0('0x1b')]=function(_0x3729ec){var _0x2c0b4c=this;return new Promise(function(_0x1f1892,_0x2aa2ae){return db[_0x94e0('0x15')]['findAll']({'raw':_0x3729ec['options']?_0x3729ec[_0x94e0('0x17')][_0x94e0('0x18')]===undefined?!![]:![]:!![],'where':_0x3729ec[_0x94e0('0x17')]?_0x3729ec[_0x94e0('0x17')][_0x94e0('0x1c')]||null:null,'attributes':[[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')][_0x94e0('0x1f')]('id')),_0x94e0('0x20')],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db['sequelize'][_0x94e0('0x21')](_0x94e0('0x22')))),_0x94e0('0x23')],[db[_0x94e0('0x1d')]['fn']('COUNT',db[_0x94e0('0x1d')]['fn']('IF',db['sequelize'][_0x94e0('0x21')]('`state`\x20=\x2010,\x201,\x20null'))),'predictiveIntervalDroppedCallsTimeout'],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')]('`state`\x20=\x2011,\x201,\x20null'))),_0x94e0('0x24')],[db['sequelize']['fn']('AVG',db['sequelize']['fn']('IF',db[_0x94e0('0x1d')]['literal'](_0x94e0('0x25')))),_0x94e0('0x26')],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x27'),db['sequelize']['fn']('IF',db[_0x94e0('0x1d')]['literal'](_0x94e0('0x28')))),_0x94e0('0x29')]]})[_0x94e0('0xc')](function(_0x1b57f1){logger[_0x94e0('0x19')](_0x94e0('0x1b'),_0x3729ec);logger['debug']('AvgHandleTime',_0x3729ec,JSON[_0x94e0('0xf')](_0x1b57f1));_0x1f1892(_0x1b57f1);})['catch'](function(_0x13e1e9){logger[_0x94e0('0x10')](_0x94e0('0x1b'),_0x13e1e9[_0x94e0('0x11')],_0x3729ec);_0x2aa2ae(_0x2c0b4c['error'](0x1f4,_0x13e1e9['message']));});});};exports[_0x94e0('0x2a')]=function(_0x521db4){var _0x15f481=this;return new Promise(function(_0x4b4821,_0x1845c4){return db[_0x94e0('0x15')][_0x94e0('0x2b')]({'raw':_0x521db4[_0x94e0('0x17')]?_0x521db4[_0x94e0('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x521db4['options']?_0x521db4[_0x94e0('0x17')]['where']||null:null,'attributes':[[_0x94e0('0x2c'),_0x94e0('0x2d')],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db['sequelize']['fn']('IF',db[_0x94e0('0x1d')]['literal'](_0x94e0('0x2e')))),_0x94e0('0x2f')],[db['sequelize']['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')](_0x94e0('0x30')))),'outboundNoAnswerCallsDay'],[db[_0x94e0('0x1d')]['fn']('COUNT',db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')]('`state`\x20=\x204,\x201,\x20null'))),_0x94e0('0x31')],[db['sequelize']['fn']('COUNT',db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')]('`state`\x20=\x205,\x201,\x20null'))),_0x94e0('0x32')],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db['sequelize']['fn']('IF',db[_0x94e0('0x1d')]['literal'](_0x94e0('0x33')))),'outboundCongestionCallsDay'],[db['sequelize']['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')](_0x94e0('0x34')))),'outboundDropCallsDayTimeout'],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db['sequelize']['fn']('IF',db[_0x94e0('0x1d')]['literal'](_0x94e0('0x35')))),_0x94e0('0x36')],[db['sequelize']['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')](_0x94e0('0x37')))),_0x94e0('0x38')],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')]('`state`\x20=\x2013,\x201,\x20null'))),'outboundBlacklistCallsDay'],[db['sequelize']['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db['sequelize'][_0x94e0('0x21')](_0x94e0('0x39')))),_0x94e0('0x3a')],[db['sequelize']['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db['sequelize'][_0x94e0('0x21')](_0x94e0('0x3b')))),_0x94e0('0x3c')],[db['sequelize']['fn'](_0x94e0('0x1e'),db['sequelize']['fn']('IF',db[_0x94e0('0x1d')]['literal'](_0x94e0('0x3d')))),_0x94e0('0x3e')],[db['sequelize']['fn']('COUNT',db[_0x94e0('0x1d')]['fn']('IF',db['sequelize']['literal']('`state`\x20=\x2020,\x201,\x20null'))),'outboundRejectCallsDay'],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')](_0x94e0('0x3f')))),_0x94e0('0x40')]],'group':[_0x94e0('0x2c')]})[_0x94e0('0xc')](function(_0x353fb8){logger[_0x94e0('0x19')](_0x94e0('0x2a'),_0x521db4);logger[_0x94e0('0x1a')]('GetVoiceQueueHopperHistory',_0x521db4,JSON[_0x94e0('0xf')](_0x353fb8));_0x4b4821(_0x353fb8);})[_0x94e0('0x13')](function(_0x459fc0){logger[_0x94e0('0x10')](_0x94e0('0x2a'),_0x459fc0[_0x94e0('0x11')],_0x521db4);_0x1845c4(_0x15f481[_0x94e0('0x10')](0x1f4,_0x459fc0['message']));});});};exports['GetCampaignHopperHistory']=function(_0x1790d8){var _0xb2cd80=this;return new Promise(function(_0x5cd44e,_0x595b38){return db[_0x94e0('0x15')][_0x94e0('0x2b')]({'raw':_0x1790d8[_0x94e0('0x17')]?_0x1790d8[_0x94e0('0x17')][_0x94e0('0x18')]===undefined?!![]:![]:!![],'where':_0x1790d8['options']?_0x1790d8[_0x94e0('0x17')][_0x94e0('0x1c')]||null:null,'attributes':[[_0x94e0('0x2c'),_0x94e0('0x2d')],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')][_0x94e0('0x1f')]('id')),_0x94e0('0x41')],[db[_0x94e0('0x1d')]['fn'](_0x94e0('0x1e'),db[_0x94e0('0x1d')]['fn']('IF',db[_0x94e0('0x1d')][_0x94e0('0x21')](_0x94e0('0x22')))),_0x94e0('0x42')]],'group':[_0x94e0('0x2c')]})[_0x94e0('0xc')](function(_0x245f67){logger[_0x94e0('0x19')](_0x94e0('0x43'),_0x1790d8);logger[_0x94e0('0x1a')]('GetCampaignHopperHistory',_0x1790d8,JSON[_0x94e0('0xf')](_0x245f67));_0x5cd44e(_0x245f67);})[_0x94e0('0x13')](function(_0x1a424a){logger[_0x94e0('0x10')]('GetCampaignHopperHistory',_0x1a424a[_0x94e0('0x11')],_0x1790d8);_0x595b38(_0xb2cd80['error'](0x1f4,_0x1a424a[_0x94e0('0x11')]));});});};