Built motion from commit (unavailable).|2.5.22
[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 _0xa5e4=['CreateCmHopperHistory','CmHopperHistory','create','body','options','raw','debug','AvgHandleTime','findAll','where','sequelize','COUNT','col','literal','`state`\x20=\x204,\x201,\x20null','predictiveIntervalAnsweredCalls','`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','GetVoiceQueueHopperHistory','campaign','name','`state`\x20=\x200,\x201,\x20null','outboundNoSuchCallsDay','`state`\x20=\x203,\x201,\x20null','outboundNoAnswerCallsDay','outboundAnswerCallsDay','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','outboundBlacklistCallsDay','outboundOriginateFailureCallsDay','`state`\x20=\x2016,\x201,\x20null','outboundAnswerAgiCallsDay','`state`\x20=\x2020,\x201,\x20null','outboundRejectCallsDay','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','outboundReCallsDay','GetCampaignHopperHistory','ivrTotalCallsDays','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','request','then','info','CmHopperHistory,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch'];(function(_0x126558,_0x143c9a){var _0x1f6d14=function(_0x2b0eea){while(--_0x2b0eea){_0x126558['push'](_0x126558['shift']());}};_0x1f6d14(++_0x143c9a);}(_0xa5e4,0x14d));var _0x4a5e=function(_0x2a90a3,_0x2c442d){_0x2a90a3=_0x2a90a3-0x0;var _0x2e245c=_0xa5e4[_0x2a90a3];return _0x2e245c;};'use strict';var _=require(_0x4a5e('0x0'));var util=require(_0x4a5e('0x1'));var moment=require(_0x4a5e('0x2'));var BPromise=require(_0x4a5e('0x3'));var rs=require(_0x4a5e('0x4'));var fs=require('fs');var Redis=require(_0x4a5e('0x5'));var db=require(_0x4a5e('0x6'))['db'];var utils=require(_0x4a5e('0x7'));var logger=require(_0x4a5e('0x8'))(_0x4a5e('0x9'));var config=require(_0x4a5e('0xa'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x482f69,_0x7ed7c,_0x3eafb4){return new BPromise(function(_0x36a907,_0x17a93f){return client[_0x4a5e('0xb')](_0x482f69,_0x3eafb4)[_0x4a5e('0xc')](function(_0x164f62){logger[_0x4a5e('0xd')](_0x4a5e('0xe'),_0x7ed7c,_0x4a5e('0xf'));logger['debug']('CmHopperHistory,\x20%s,\x20%s,\x20%s',_0x7ed7c,_0x4a5e('0xf'),JSON[_0x4a5e('0x10')](_0x164f62));if(_0x164f62['error']){if(_0x164f62[_0x4a5e('0x11')][_0x4a5e('0x12')]===0x1f4){logger[_0x4a5e('0x11')](_0x4a5e('0xe'),_0x7ed7c,_0x164f62['error'][_0x4a5e('0x13')]);return _0x17a93f(_0x164f62[_0x4a5e('0x11')][_0x4a5e('0x13')]);}logger[_0x4a5e('0x11')]('CmHopperHistory,\x20%s,\x20%s',_0x7ed7c,_0x164f62[_0x4a5e('0x11')][_0x4a5e('0x13')]);return _0x36a907(_0x164f62[_0x4a5e('0x11')][_0x4a5e('0x13')]);}else{logger[_0x4a5e('0xd')](_0x4a5e('0xe'),_0x7ed7c,_0x4a5e('0xf'));_0x36a907(_0x164f62[_0x4a5e('0x14')]['message']);}})[_0x4a5e('0x15')](function(_0x15d9a4){logger[_0x4a5e('0x11')]('CmHopperHistory,\x20%s,\x20%s',_0x7ed7c,_0x15d9a4);_0x17a93f(_0x15d9a4);});});}exports[_0x4a5e('0x16')]=function(_0x42cd40){var _0x2c4f4b=this;return new Promise(function(_0x2e4e26,_0x377103){return db[_0x4a5e('0x17')][_0x4a5e('0x18')](_0x42cd40[_0x4a5e('0x19')],{'raw':_0x42cd40[_0x4a5e('0x1a')]?_0x42cd40[_0x4a5e('0x1a')][_0x4a5e('0x1b')]===undefined?!![]:![]:!![]})[_0x4a5e('0xc')](function(_0x4dcdc4){logger['info'](_0x4a5e('0x16'),_0x42cd40);logger[_0x4a5e('0x1c')](_0x4a5e('0x16'),_0x42cd40,JSON[_0x4a5e('0x10')](_0x4dcdc4));_0x2e4e26(_0x4dcdc4);})[_0x4a5e('0x15')](function(_0x463e6f){logger[_0x4a5e('0x11')](_0x4a5e('0x16'),_0x463e6f['message'],_0x42cd40);_0x377103(_0x2c4f4b['error'](0x1f4,_0x463e6f[_0x4a5e('0x13')]));});});};exports[_0x4a5e('0x1d')]=function(_0x52245a){var _0x3bdcd8=this;return new Promise(function(_0x52f27d,_0x2051fb){return db[_0x4a5e('0x17')][_0x4a5e('0x1e')]({'raw':_0x52245a[_0x4a5e('0x1a')]?_0x52245a[_0x4a5e('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x52245a['options']?_0x52245a[_0x4a5e('0x1a')][_0x4a5e('0x1f')]||null:null,'attributes':[[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db['sequelize'][_0x4a5e('0x22')]('id')),'predictiveIntervalTotalCalls'],[db['sequelize']['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x24')))),_0x4a5e('0x25')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x26')))),'predictiveIntervalDroppedCallsTimeout'],[db[_0x4a5e('0x20')]['fn']('COUNT',db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x27')))),_0x4a5e('0x28')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x29'),db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x2a')))),_0x4a5e('0x2b')],[db['sequelize']['fn'](_0x4a5e('0x29'),db[_0x4a5e('0x20')]['fn']('IF',db['sequelize'][_0x4a5e('0x23')](_0x4a5e('0x2c')))),'predictiveIntervalAvgTalktime']]})[_0x4a5e('0xc')](function(_0x21414d){logger['info'](_0x4a5e('0x1d'),_0x52245a);logger['debug']('AvgHandleTime',_0x52245a,JSON['stringify'](_0x21414d));_0x52f27d(_0x21414d);})['catch'](function(_0x3f5ed2){logger[_0x4a5e('0x11')](_0x4a5e('0x1d'),_0x3f5ed2[_0x4a5e('0x13')],_0x52245a);_0x2051fb(_0x3bdcd8['error'](0x1f4,_0x3f5ed2['message']));});});};exports[_0x4a5e('0x2d')]=function(_0x5d1304){var _0xffacae=this;return new Promise(function(_0x40ef21,_0x35c28f){return db['CmHopperHistory'][_0x4a5e('0x1e')]({'raw':_0x5d1304['options']?_0x5d1304[_0x4a5e('0x1a')][_0x4a5e('0x1b')]===undefined?!![]:![]:!![],'where':_0x5d1304[_0x4a5e('0x1a')]?_0x5d1304['options']['where']||null:null,'attributes':[[_0x4a5e('0x2e'),_0x4a5e('0x2f')],[db['sequelize']['fn'](_0x4a5e('0x21'),db['sequelize']['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x30')))),_0x4a5e('0x31')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x32')))),_0x4a5e('0x33')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x24')))),_0x4a5e('0x34')],[db[_0x4a5e('0x20')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')]('`state`\x20=\x205,\x201,\x20null'))),_0x4a5e('0x35')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db['sequelize'][_0x4a5e('0x23')](_0x4a5e('0x36')))),'outboundCongestionCallsDay'],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')]['literal'](_0x4a5e('0x37')))),_0x4a5e('0x38')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db['sequelize']['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x39')))),_0x4a5e('0x3a')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x3b')))),_0x4a5e('0x3c')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')]('`state`\x20=\x2013,\x201,\x20null'))),_0x4a5e('0x3d')],[db['sequelize']['fn'](_0x4a5e('0x21'),db['sequelize']['fn']('IF',db['sequelize'][_0x4a5e('0x23')]('`state`\x20=\x2014,\x201,\x20null'))),_0x4a5e('0x3e')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db[_0x4a5e('0x20')]['fn']('IF',db['sequelize']['literal']('`state`\x20=\x2018,\x201,\x20null'))),'outboundRejectCallsDay'],[db[_0x4a5e('0x20')]['fn']('COUNT',db[_0x4a5e('0x20')]['fn']('IF',db['sequelize'][_0x4a5e('0x23')](_0x4a5e('0x3f')))),_0x4a5e('0x40')],[db['sequelize']['fn']('COUNT',db[_0x4a5e('0x20')]['fn']('IF',db[_0x4a5e('0x20')][_0x4a5e('0x23')](_0x4a5e('0x41')))),_0x4a5e('0x42')],[db[_0x4a5e('0x20')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x4a5e('0x20')]['literal'](_0x4a5e('0x43')))),_0x4a5e('0x44')]],'group':[_0x4a5e('0x2e')]})['then'](function(_0x29638a){logger['info']('GetVoiceQueueHopperHistory',_0x5d1304);logger[_0x4a5e('0x1c')]('GetVoiceQueueHopperHistory',_0x5d1304,JSON[_0x4a5e('0x10')](_0x29638a));_0x40ef21(_0x29638a);})[_0x4a5e('0x15')](function(_0x31842f){logger[_0x4a5e('0x11')](_0x4a5e('0x2d'),_0x31842f[_0x4a5e('0x13')],_0x5d1304);_0x35c28f(_0xffacae[_0x4a5e('0x11')](0x1f4,_0x31842f['message']));});});};exports[_0x4a5e('0x45')]=function(_0x383096){var _0x1823a3=this;return new Promise(function(_0x337f83,_0x3489b9){return db[_0x4a5e('0x17')]['findAll']({'raw':_0x383096['options']?_0x383096[_0x4a5e('0x1a')][_0x4a5e('0x1b')]===undefined?!![]:![]:!![],'where':_0x383096[_0x4a5e('0x1a')]?_0x383096[_0x4a5e('0x1a')]['where']||null:null,'attributes':[[_0x4a5e('0x2e'),_0x4a5e('0x2f')],[db[_0x4a5e('0x20')]['fn']('COUNT',db[_0x4a5e('0x20')][_0x4a5e('0x22')]('id')),_0x4a5e('0x46')],[db[_0x4a5e('0x20')]['fn'](_0x4a5e('0x21'),db['sequelize']['fn']('IF',db[_0x4a5e('0x20')]['literal'](_0x4a5e('0x24')))),'ivrAnswerCallsDay']],'group':['campaign']})[_0x4a5e('0xc')](function(_0x7cdd5d){logger[_0x4a5e('0xd')](_0x4a5e('0x45'),_0x383096);logger[_0x4a5e('0x1c')](_0x4a5e('0x45'),_0x383096,JSON[_0x4a5e('0x10')](_0x7cdd5d));_0x337f83(_0x7cdd5d);})[_0x4a5e('0x15')](function(_0x565391){logger['error']('GetCampaignHopperHistory',_0x565391[_0x4a5e('0x13')],_0x383096);_0x3489b9(_0x1823a3[_0x4a5e('0x11')](0x1f4,_0x565391[_0x4a5e('0x13')]));});});};