Built motion from commit (unavailable).|2.5.14
[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 _0x8080=['ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','request','then','info','CmHopperHistory,\x20%s,\x20%s','debug','CmHopperHistory,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','CmHopperHistory','create','body','options','raw','CreateCmHopperHistory','AvgHandleTime','where','sequelize','COUNT','col','predictiveIntervalTotalCalls','`state`\x20=\x204,\x201,\x20null','`state`\x20=\x2010,\x201,\x20null','predictiveIntervalDroppedCallsTimeout','`state`\x20=\x2011,\x201,\x20null','predictiveIntervalDroppedCallsCallersExit','literal','`state`\x20=\x204,\x20`holdtime`,\x20null','AVG','`state`\x20=\x204,\x20`talktime`,\x20null','predictiveIntervalAvgTalktime','findAll','campaign','name','`state`\x20=\x205,\x201,\x20null','outboundBusyCallsDay','`state`\x20=\x208,\x201,\x20null','`state`\x20=\x2010\x20,\x201,\x20null','outboundDropCallsDayTimeout','`state`\x20=\x2011\x20,\x201,\x20null','outboundDropCallsDayCallersExit','`state`\x20=\x2012,\x201,\x20null','outboundUnknownCallsDay','`state`\x20=\x2013,\x201,\x20null','outboundBlacklistCallsDay','`state`\x20=\x2014,\x201,\x20null','outboundRejectCallsDay','`state`\x20=\x2016,\x201,\x20null','outboundAnswerAgiCallsDay','`state`\x20=\x2020,\x201,\x20null','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','GetVoiceQueueHopperHistory','ivrTotalCallsDays','ivrAnswerCallsDay','GetCampaignHopperHistory','lodash','util','bluebird','randomstring'];(function(_0x13799a,_0x3a5ad){var _0x1dcaac=function(_0x2978b0){while(--_0x2978b0){_0x13799a['push'](_0x13799a['shift']());}};_0x1dcaac(++_0x3a5ad);}(_0x8080,0x155));var _0x0808=function(_0x2870a6,_0xd2d6e3){_0x2870a6=_0x2870a6-0x0;var _0x4114ba=_0x8080[_0x2870a6];return _0x4114ba;};'use strict';var _=require(_0x0808('0x0'));var util=require(_0x0808('0x1'));var moment=require('moment');var BPromise=require(_0x0808('0x2'));var rs=require(_0x0808('0x3'));var fs=require('fs');var Redis=require(_0x0808('0x4'));var db=require(_0x0808('0x5'))['db'];var utils=require(_0x0808('0x6'));var logger=require(_0x0808('0x7'))('rpc');var config=require(_0x0808('0x8'));var jayson=require(_0x0808('0x9'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0xf0735e,_0x4b6f32,_0x2a0fd1){return new BPromise(function(_0xda9f0b,_0x40f096){return client[_0x0808('0xa')](_0xf0735e,_0x2a0fd1)[_0x0808('0xb')](function(_0x54e1cb){logger[_0x0808('0xc')](_0x0808('0xd'),_0x4b6f32,'request\x20sent');logger[_0x0808('0xe')](_0x0808('0xf'),_0x4b6f32,_0x0808('0x10'),JSON[_0x0808('0x11')](_0x54e1cb));if(_0x54e1cb[_0x0808('0x12')]){if(_0x54e1cb[_0x0808('0x12')][_0x0808('0x13')]===0x1f4){logger['error']('CmHopperHistory,\x20%s,\x20%s',_0x4b6f32,_0x54e1cb[_0x0808('0x12')][_0x0808('0x14')]);return _0x40f096(_0x54e1cb[_0x0808('0x12')]['message']);}logger[_0x0808('0x12')](_0x0808('0xd'),_0x4b6f32,_0x54e1cb['error']['message']);return _0xda9f0b(_0x54e1cb['error'][_0x0808('0x14')]);}else{logger[_0x0808('0xc')](_0x0808('0xd'),_0x4b6f32,'request\x20sent');_0xda9f0b(_0x54e1cb[_0x0808('0x15')][_0x0808('0x14')]);}})[_0x0808('0x16')](function(_0x2a4819){logger[_0x0808('0x12')](_0x0808('0xd'),_0x4b6f32,_0x2a4819);_0x40f096(_0x2a4819);});});}exports['CreateCmHopperHistory']=function(_0x5bb348){var _0x77b87c=this;return new Promise(function(_0x4fc1b,_0x58fc88){return db[_0x0808('0x17')][_0x0808('0x18')](_0x5bb348[_0x0808('0x19')],{'raw':_0x5bb348['options']?_0x5bb348[_0x0808('0x1a')][_0x0808('0x1b')]===undefined?!![]:![]:!![]})['then'](function(_0x34ec42){logger['info']('CreateCmHopperHistory',_0x5bb348);logger['debug']('CreateCmHopperHistory',_0x5bb348,JSON[_0x0808('0x11')](_0x34ec42));_0x4fc1b(_0x34ec42);})[_0x0808('0x16')](function(_0x47bb88){logger[_0x0808('0x12')](_0x0808('0x1c'),_0x47bb88[_0x0808('0x14')],_0x5bb348);_0x58fc88(_0x77b87c[_0x0808('0x12')](0x1f4,_0x47bb88['message']));});});};exports[_0x0808('0x1d')]=function(_0x30fcda){var _0x3eb442=this;return new Promise(function(_0x1e22e3,_0x5575b2){return db[_0x0808('0x17')]['findAll']({'raw':_0x30fcda['options']?_0x30fcda[_0x0808('0x1a')][_0x0808('0x1b')]===undefined?!![]:![]:!![],'where':_0x30fcda[_0x0808('0x1a')]?_0x30fcda['options'][_0x0808('0x1e')]||null:null,'attributes':[[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db[_0x0808('0x1f')][_0x0808('0x21')]('id')),_0x0808('0x22')],[db['sequelize']['fn'](_0x0808('0x20'),db['sequelize']['fn']('IF',db[_0x0808('0x1f')]['literal'](_0x0808('0x23')))),'predictiveIntervalAnsweredCalls'],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db['sequelize']['fn']('IF',db[_0x0808('0x1f')]['literal'](_0x0808('0x24')))),_0x0808('0x25')],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')]['literal'](_0x0808('0x26')))),_0x0808('0x27')],[db[_0x0808('0x1f')]['fn']('AVG',db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')][_0x0808('0x28')](_0x0808('0x29')))),'predictiveIntervalAvgHoldtime'],[db[_0x0808('0x1f')]['fn'](_0x0808('0x2a'),db['sequelize']['fn']('IF',db[_0x0808('0x1f')]['literal'](_0x0808('0x2b')))),_0x0808('0x2c')]]})['then'](function(_0xc1bdda){logger['info']('AvgHandleTime',_0x30fcda);logger[_0x0808('0xe')](_0x0808('0x1d'),_0x30fcda,JSON['stringify'](_0xc1bdda));_0x1e22e3(_0xc1bdda);})[_0x0808('0x16')](function(_0x1f1c02){logger[_0x0808('0x12')](_0x0808('0x1d'),_0x1f1c02[_0x0808('0x14')],_0x30fcda);_0x5575b2(_0x3eb442[_0x0808('0x12')](0x1f4,_0x1f1c02[_0x0808('0x14')]));});});};exports['GetVoiceQueueHopperHistory']=function(_0x31f1c2){var _0x321a6e=this;return new Promise(function(_0x3edd85,_0x4514c1){return db[_0x0808('0x17')][_0x0808('0x2d')]({'raw':_0x31f1c2[_0x0808('0x1a')]?_0x31f1c2[_0x0808('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x31f1c2[_0x0808('0x1a')]?_0x31f1c2['options'][_0x0808('0x1e')]||null:null,'attributes':[[_0x0808('0x2e'),_0x0808('0x2f')],[db['sequelize']['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')][_0x0808('0x28')]('`state`\x20=\x200,\x201,\x20null'))),'outboundNoSuchCallsDay'],[db[_0x0808('0x1f')]['fn']('COUNT',db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')][_0x0808('0x28')]('`state`\x20=\x203,\x201,\x20null'))),'outboundNoAnswerCallsDay'],[db['sequelize']['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x0808('0x1f')][_0x0808('0x28')]('`state`\x20=\x204,\x201,\x20null'))),'outboundAnswerCallsDay'],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db['sequelize']['fn']('IF',db[_0x0808('0x1f')]['literal'](_0x0808('0x30')))),_0x0808('0x31')],[db[_0x0808('0x1f')]['fn']('COUNT',db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')][_0x0808('0x28')](_0x0808('0x32')))),'outboundCongestionCallsDay'],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')][_0x0808('0x28')](_0x0808('0x33')))),_0x0808('0x34')],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db['sequelize']['literal'](_0x0808('0x35')))),_0x0808('0x36')],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db['sequelize']['literal'](_0x0808('0x37')))),_0x0808('0x38')],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db['sequelize']['fn']('IF',db[_0x0808('0x1f')]['literal'](_0x0808('0x39')))),_0x0808('0x3a')],[db[_0x0808('0x1f')]['fn']('COUNT',db['sequelize']['fn']('IF',db['sequelize'][_0x0808('0x28')](_0x0808('0x3b')))),'outboundOriginateFailureCallsDay'],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')]['literal']('`state`\x20=\x2018,\x201,\x20null'))),_0x0808('0x3c')],[db['sequelize']['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')][_0x0808('0x28')](_0x0808('0x3d')))),_0x0808('0x3e')],[db['sequelize']['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db['sequelize']['literal'](_0x0808('0x3f')))),_0x0808('0x3c')],[db['sequelize']['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')]['literal'](_0x0808('0x40')))),'outboundReCallsDay']],'group':[_0x0808('0x2e')]})[_0x0808('0xb')](function(_0x19b5db){logger['info'](_0x0808('0x41'),_0x31f1c2);logger[_0x0808('0xe')]('GetVoiceQueueHopperHistory',_0x31f1c2,JSON[_0x0808('0x11')](_0x19b5db));_0x3edd85(_0x19b5db);})[_0x0808('0x16')](function(_0xaabfcc){logger[_0x0808('0x12')](_0x0808('0x41'),_0xaabfcc[_0x0808('0x14')],_0x31f1c2);_0x4514c1(_0x321a6e[_0x0808('0x12')](0x1f4,_0xaabfcc[_0x0808('0x14')]));});});};exports['GetCampaignHopperHistory']=function(_0x5f4c5a){var _0x5459c9=this;return new Promise(function(_0x456f9b,_0x55dbaf){return db[_0x0808('0x17')][_0x0808('0x2d')]({'raw':_0x5f4c5a[_0x0808('0x1a')]?_0x5f4c5a[_0x0808('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x5f4c5a[_0x0808('0x1a')]?_0x5f4c5a[_0x0808('0x1a')][_0x0808('0x1e')]||null:null,'attributes':[[_0x0808('0x2e'),_0x0808('0x2f')],[db[_0x0808('0x1f')]['fn']('COUNT',db[_0x0808('0x1f')]['col']('id')),_0x0808('0x42')],[db[_0x0808('0x1f')]['fn'](_0x0808('0x20'),db[_0x0808('0x1f')]['fn']('IF',db[_0x0808('0x1f')]['literal'](_0x0808('0x23')))),_0x0808('0x43')]],'group':[_0x0808('0x2e')]})[_0x0808('0xb')](function(_0x36face){logger[_0x0808('0xc')](_0x0808('0x44'),_0x5f4c5a);logger[_0x0808('0xe')]('GetCampaignHopperHistory',_0x5f4c5a,JSON[_0x0808('0x11')](_0x36face));_0x456f9b(_0x36face);})[_0x0808('0x16')](function(_0x3a64e8){logger[_0x0808('0x12')](_0x0808('0x44'),_0x3a64e8[_0x0808('0x14')],_0x5f4c5a);_0x55dbaf(_0x5459c9[_0x0808('0x12')](0x1f4,_0x3a64e8[_0x0808('0x14')]));});});};