f87882f55854c38a0b9892510c3068dd3524d197
[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 _0xa101=['client','http','request','then','info','CmHopperHistory,\x20%s,\x20%s','debug','CmHopperHistory,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','catch','CreateCmHopperHistory','CmHopperHistory','create','body','options','raw','stringify','AvgHandleTime','findAll','where','sequelize','COUNT','literal','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','`state`\x20=\x2011,\x201,\x20null','AVG','`state`\x20=\x204,\x20`holdtime`,\x20null','`state`\x20=\x204,\x20`talktime`,\x20null','predictiveIntervalAvgTalktime','GetVoiceQueueHopperHistory','campaign','name','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','`state`\x20=\x2011\x20,\x201,\x20null','outboundDropCallsDayCallersExit','`state`\x20=\x2012,\x201,\x20null','outboundUnknownCallsDay','`state`\x20=\x2013,\x201,\x20null','outboundBlacklistCallsDay','`state`\x20=\x2014,\x201,\x20null','outboundOriginateFailureCallsDay','`state`\x20=\x2018,\x201,\x20null','outboundRejectCallsDay','`state`\x20=\x2016,\x201,\x20null','outboundAnswerAgiCallsDay','outboundReCallsDay','GetCampaignHopperHistory','col','ivrTotalCallsDays','`state`\x20=\x204,\x201,\x20null','ivrAnswerCallsDay','lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise'];(function(_0xdb5ab9,_0x210c9c){var _0x5c8280=function(_0x15b632){while(--_0x15b632){_0xdb5ab9['push'](_0xdb5ab9['shift']());}};_0x5c8280(++_0x210c9c);}(_0xa101,0x15f));var _0x1a10=function(_0x838813,_0x448f0f){_0x838813=_0x838813-0x0;var _0x2bd32d=_0xa101[_0x838813];return _0x2bd32d;};'use strict';var _=require(_0x1a10('0x0'));var util=require(_0x1a10('0x1'));var moment=require('moment');var BPromise=require(_0x1a10('0x2'));var rs=require(_0x1a10('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1a10('0x4'))['db'];var utils=require(_0x1a10('0x5'));var logger=require('../../config/logger')(_0x1a10('0x6'));var config=require(_0x1a10('0x7'));var jayson=require(_0x1a10('0x8'));var client=jayson[_0x1a10('0x9')][_0x1a10('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2b95f3,_0x5eea77,_0x4f0cd4){return new BPromise(function(_0x3c90fa,_0x2df5ef){return client[_0x1a10('0xb')](_0x2b95f3,_0x4f0cd4)[_0x1a10('0xc')](function(_0x7c7a8a){logger[_0x1a10('0xd')](_0x1a10('0xe'),_0x5eea77,'request\x20sent');logger[_0x1a10('0xf')](_0x1a10('0x10'),_0x5eea77,_0x1a10('0x11'),JSON['stringify'](_0x7c7a8a));if(_0x7c7a8a[_0x1a10('0x12')]){if(_0x7c7a8a[_0x1a10('0x12')][_0x1a10('0x13')]===0x1f4){logger['error'](_0x1a10('0xe'),_0x5eea77,_0x7c7a8a[_0x1a10('0x12')][_0x1a10('0x14')]);return _0x2df5ef(_0x7c7a8a[_0x1a10('0x12')][_0x1a10('0x14')]);}logger['error'](_0x1a10('0xe'),_0x5eea77,_0x7c7a8a['error']['message']);return _0x3c90fa(_0x7c7a8a['error'][_0x1a10('0x14')]);}else{logger[_0x1a10('0xd')](_0x1a10('0xe'),_0x5eea77,_0x1a10('0x11'));_0x3c90fa(_0x7c7a8a['result'][_0x1a10('0x14')]);}})[_0x1a10('0x15')](function(_0x5395b4){logger[_0x1a10('0x12')](_0x1a10('0xe'),_0x5eea77,_0x5395b4);_0x2df5ef(_0x5395b4);});});}exports[_0x1a10('0x16')]=function(_0x457e2f){var _0x4a3813=this;return new Promise(function(_0x169cf2,_0x1b394c){return db[_0x1a10('0x17')][_0x1a10('0x18')](_0x457e2f[_0x1a10('0x19')],{'raw':_0x457e2f[_0x1a10('0x1a')]?_0x457e2f[_0x1a10('0x1a')][_0x1a10('0x1b')]===undefined?!![]:![]:!![]})[_0x1a10('0xc')](function(_0x203561){logger[_0x1a10('0xd')](_0x1a10('0x16'),_0x457e2f);logger[_0x1a10('0xf')](_0x1a10('0x16'),_0x457e2f,JSON[_0x1a10('0x1c')](_0x203561));_0x169cf2(_0x203561);})['catch'](function(_0x70ae18){logger['error'](_0x1a10('0x16'),_0x70ae18['message'],_0x457e2f);_0x1b394c(_0x4a3813[_0x1a10('0x12')](0x1f4,_0x70ae18['message']));});});};exports[_0x1a10('0x1d')]=function(_0x74c06a){var _0x5f2d2d=this;return new Promise(function(_0x3b3aee,_0x2e618a){return db[_0x1a10('0x17')][_0x1a10('0x1e')]({'raw':_0x74c06a['options']?_0x74c06a[_0x1a10('0x1a')][_0x1a10('0x1b')]===undefined?!![]:![]:!![],'where':_0x74c06a[_0x1a10('0x1a')]?_0x74c06a[_0x1a10('0x1a')][_0x1a10('0x1f')]||null:null,'attributes':[[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['col']('id')),'predictiveIntervalTotalCalls'],[db['sequelize']['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')]('`state`\x20=\x204,\x201,\x20null'))),_0x1a10('0x23')],[db[_0x1a10('0x20')]['fn']('COUNT',db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')]('`state`\x20=\x2010,\x201,\x20null'))),_0x1a10('0x24')],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')]['literal'](_0x1a10('0x25')))),'predictiveIntervalDroppedCallsCallersExit'],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x26'),db['sequelize']['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')](_0x1a10('0x27')))),'predictiveIntervalAvgHoldtime'],[db['sequelize']['fn'](_0x1a10('0x26'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')](_0x1a10('0x28')))),_0x1a10('0x29')]]})[_0x1a10('0xc')](function(_0x3ab2ce){logger['info'](_0x1a10('0x1d'),_0x74c06a);logger[_0x1a10('0xf')](_0x1a10('0x1d'),_0x74c06a,JSON[_0x1a10('0x1c')](_0x3ab2ce));_0x3b3aee(_0x3ab2ce);})[_0x1a10('0x15')](function(_0x404025){logger['error'](_0x1a10('0x1d'),_0x404025[_0x1a10('0x14')],_0x74c06a);_0x2e618a(_0x5f2d2d[_0x1a10('0x12')](0x1f4,_0x404025[_0x1a10('0x14')]));});});};exports[_0x1a10('0x2a')]=function(_0x816f92){var _0x2f1c48=this;return new Promise(function(_0x567e29,_0x4efdc3){return db[_0x1a10('0x17')][_0x1a10('0x1e')]({'raw':_0x816f92[_0x1a10('0x1a')]?_0x816f92[_0x1a10('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x816f92[_0x1a10('0x1a')]?_0x816f92['options'][_0x1a10('0x1f')]||null:null,'attributes':[[_0x1a10('0x2b'),_0x1a10('0x2c')],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')]('`state`\x20=\x200,\x201,\x20null'))),_0x1a10('0x2d')],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db['sequelize'][_0x1a10('0x22')](_0x1a10('0x2e')))),_0x1a10('0x2f')],[db['sequelize']['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x1a10('0x20')]['literal']('`state`\x20=\x204,\x201,\x20null'))),_0x1a10('0x30')],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')]['literal'](_0x1a10('0x31')))),_0x1a10('0x32')],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')]['literal'](_0x1a10('0x33')))),_0x1a10('0x34')],[db[_0x1a10('0x20')]['fn']('COUNT',db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')](_0x1a10('0x35')))),'outboundDropCallsDayTimeout'],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db['sequelize']['fn']('IF',db['sequelize'][_0x1a10('0x22')](_0x1a10('0x36')))),_0x1a10('0x37')],[db['sequelize']['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')](_0x1a10('0x38')))),_0x1a10('0x39')],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')](_0x1a10('0x3a')))),_0x1a10('0x3b')],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')]['literal'](_0x1a10('0x3c')))),_0x1a10('0x3d')],[db[_0x1a10('0x20')]['fn']('COUNT',db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')][_0x1a10('0x22')](_0x1a10('0x3e')))),_0x1a10('0x3f')],[db['sequelize']['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db['sequelize'][_0x1a10('0x22')](_0x1a10('0x40')))),_0x1a10('0x41')],[db['sequelize']['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')]['literal']('`state`\x20=\x2020,\x201,\x20null'))),'outboundRejectCallsDay'],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db[_0x1a10('0x20')]['literal']('`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null'))),_0x1a10('0x42')]],'group':['campaign']})[_0x1a10('0xc')](function(_0xe4c55d){logger[_0x1a10('0xd')]('GetVoiceQueueHopperHistory',_0x816f92);logger[_0x1a10('0xf')](_0x1a10('0x2a'),_0x816f92,JSON[_0x1a10('0x1c')](_0xe4c55d));_0x567e29(_0xe4c55d);})[_0x1a10('0x15')](function(_0x5ca1a2){logger[_0x1a10('0x12')](_0x1a10('0x2a'),_0x5ca1a2[_0x1a10('0x14')],_0x816f92);_0x4efdc3(_0x2f1c48[_0x1a10('0x12')](0x1f4,_0x5ca1a2[_0x1a10('0x14')]));});});};exports[_0x1a10('0x43')]=function(_0x2920e9){var _0x1a3e67=this;return new Promise(function(_0x377f08,_0x497a8e){return db[_0x1a10('0x17')][_0x1a10('0x1e')]({'raw':_0x2920e9[_0x1a10('0x1a')]?_0x2920e9[_0x1a10('0x1a')][_0x1a10('0x1b')]===undefined?!![]:![]:!![],'where':_0x2920e9[_0x1a10('0x1a')]?_0x2920e9['options'][_0x1a10('0x1f')]||null:null,'attributes':[[_0x1a10('0x2b'),_0x1a10('0x2c')],[db[_0x1a10('0x20')]['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')][_0x1a10('0x44')]('id')),_0x1a10('0x45')],[db['sequelize']['fn'](_0x1a10('0x21'),db[_0x1a10('0x20')]['fn']('IF',db['sequelize']['literal'](_0x1a10('0x46')))),_0x1a10('0x47')]],'group':['campaign']})['then'](function(_0x2df349){logger['info']('GetCampaignHopperHistory',_0x2920e9);logger[_0x1a10('0xf')](_0x1a10('0x43'),_0x2920e9,JSON[_0x1a10('0x1c')](_0x2df349));_0x377f08(_0x2df349);})[_0x1a10('0x15')](function(_0x3dc312){logger[_0x1a10('0x12')]('GetCampaignHopperHistory',_0x3dc312[_0x1a10('0x14')],_0x2920e9);_0x497a8e(_0x1a3e67['error'](0x1f4,_0x3dc312[_0x1a10('0x14')]));});});};