Built motion from commit 9e1ec266.|2.6.28
[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 _0x0194=['name','`state`\x20=\x203,\x201,\x20null','outboundAnswerCallsDay','`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','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','`state`\x20=\x2020,\x201,\x20null','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','outboundReCallsDay','ivrTotalCallsDays','ivrAnswerCallsDay','GetCampaignHopperHistory','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','CmHopperHistory,\x20%s,\x20%s','CmHopperHistory,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','error','message','CreateCmHopperHistory','CmHopperHistory','create','body','options','raw','debug','catch','AvgHandleTime','where','COUNT','sequelize','col','predictiveIntervalTotalCalls','literal','`state`\x20=\x204,\x201,\x20null','predictiveIntervalAnsweredCalls','predictiveIntervalDroppedCallsTimeout','`state`\x20=\x2011,\x201,\x20null','predictiveIntervalDroppedCallsCallersExit','AVG','`state`\x20=\x204,\x20`holdtime`,\x20null','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','GetVoiceQueueHopperHistory','findAll','campaign'];(function(_0x2e5988,_0x482943){var _0x35080f=function(_0x56f09b){while(--_0x56f09b){_0x2e5988['push'](_0x2e5988['shift']());}};_0x35080f(++_0x482943);}(_0x0194,0xf1));var _0x4019=function(_0x4dcd50,_0x58dcef){_0x4dcd50=_0x4dcd50-0x0;var _0x4aac8f=_0x0194[_0x4dcd50];return _0x4aac8f;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x4019('0x0'));var BPromise=require(_0x4019('0x1'));var rs=require(_0x4019('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4019('0x3'))['db'];var utils=require(_0x4019('0x4'));var logger=require(_0x4019('0x5'))(_0x4019('0x6'));var config=require(_0x4019('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x4019('0x8')][_0x4019('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3b47b6,_0x45b6d8,_0x5c4015){return new BPromise(function(_0x173f77,_0x598c33){return client[_0x4019('0xa')](_0x3b47b6,_0x5c4015)[_0x4019('0xb')](function(_0x2e09be){logger[_0x4019('0xc')](_0x4019('0xd'),_0x45b6d8,'request\x20sent');logger['debug'](_0x4019('0xe'),_0x45b6d8,_0x4019('0xf'),JSON[_0x4019('0x10')](_0x2e09be));if(_0x2e09be['error']){if(_0x2e09be['error'][_0x4019('0x11')]===0x1f4){logger[_0x4019('0x12')](_0x4019('0xd'),_0x45b6d8,_0x2e09be['error'][_0x4019('0x13')]);return _0x598c33(_0x2e09be[_0x4019('0x12')]['message']);}logger['error']('CmHopperHistory,\x20%s,\x20%s',_0x45b6d8,_0x2e09be[_0x4019('0x12')][_0x4019('0x13')]);return _0x173f77(_0x2e09be[_0x4019('0x12')]['message']);}else{logger[_0x4019('0xc')]('CmHopperHistory,\x20%s,\x20%s',_0x45b6d8,_0x4019('0xf'));_0x173f77(_0x2e09be['result']['message']);}})['catch'](function(_0x5f0371){logger[_0x4019('0x12')](_0x4019('0xd'),_0x45b6d8,_0x5f0371);_0x598c33(_0x5f0371);});});}exports[_0x4019('0x14')]=function(_0x4e28d1){var _0x439dac=this;return new Promise(function(_0x4b19ed,_0x2c7b18){return db[_0x4019('0x15')][_0x4019('0x16')](_0x4e28d1[_0x4019('0x17')],{'raw':_0x4e28d1[_0x4019('0x18')]?_0x4e28d1[_0x4019('0x18')][_0x4019('0x19')]===undefined?!![]:![]:!![]})[_0x4019('0xb')](function(_0x952060){logger[_0x4019('0xc')](_0x4019('0x14'),_0x4e28d1);logger[_0x4019('0x1a')](_0x4019('0x14'),_0x4e28d1,JSON[_0x4019('0x10')](_0x952060));_0x4b19ed(_0x952060);})[_0x4019('0x1b')](function(_0x123f61){logger[_0x4019('0x12')]('CreateCmHopperHistory',_0x123f61[_0x4019('0x13')],_0x4e28d1);_0x2c7b18(_0x439dac['error'](0x1f4,_0x123f61[_0x4019('0x13')]));});});};exports[_0x4019('0x1c')]=function(_0x492550){var _0x4b696f=this;return new Promise(function(_0x2083b2,_0x5f32c0){return db['CmHopperHistory']['findAll']({'raw':_0x492550[_0x4019('0x18')]?_0x492550[_0x4019('0x18')][_0x4019('0x19')]===undefined?!![]:![]:!![],'where':_0x492550[_0x4019('0x18')]?_0x492550[_0x4019('0x18')][_0x4019('0x1d')]||null:null,'attributes':[[db['sequelize']['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')][_0x4019('0x20')]('id')),_0x4019('0x21')],[db[_0x4019('0x1f')]['fn'](_0x4019('0x1e'),db['sequelize']['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x23')))),_0x4019('0x24')],[db[_0x4019('0x1f')]['fn']('COUNT',db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')]('`state`\x20=\x2010,\x201,\x20null'))),_0x4019('0x25')],[db['sequelize']['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x26')))),_0x4019('0x27')],[db[_0x4019('0x1f')]['fn'](_0x4019('0x28'),db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x29')))),_0x4019('0x2a')],[db[_0x4019('0x1f')]['fn'](_0x4019('0x28'),db[_0x4019('0x1f')]['fn']('IF',db['sequelize']['literal']('`state`\x20=\x204,\x20`talktime`,\x20null'))),_0x4019('0x2b')]]})[_0x4019('0xb')](function(_0x3cad04){logger[_0x4019('0xc')](_0x4019('0x1c'),_0x492550);logger[_0x4019('0x1a')](_0x4019('0x1c'),_0x492550,JSON['stringify'](_0x3cad04));_0x2083b2(_0x3cad04);})['catch'](function(_0x23be4e){logger[_0x4019('0x12')](_0x4019('0x1c'),_0x23be4e[_0x4019('0x13')],_0x492550);_0x5f32c0(_0x4b696f[_0x4019('0x12')](0x1f4,_0x23be4e[_0x4019('0x13')]));});});};exports[_0x4019('0x2c')]=function(_0x3d6757){var _0x536ad9=this;return new Promise(function(_0x3d7eb2,_0x2f6039){return db[_0x4019('0x15')][_0x4019('0x2d')]({'raw':_0x3d6757['options']?_0x3d6757['options']['raw']===undefined?!![]:![]:!![],'where':_0x3d6757['options']?_0x3d6757[_0x4019('0x18')][_0x4019('0x1d')]||null:null,'attributes':[[_0x4019('0x2e'),_0x4019('0x2f')],[db['sequelize']['fn'](_0x4019('0x1e'),db['sequelize']['fn']('IF',db[_0x4019('0x1f')]['literal']('`state`\x20=\x200,\x201,\x20null'))),'outboundNoSuchCallsDay'],[db['sequelize']['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x30')))),'outboundNoAnswerCallsDay'],[db[_0x4019('0x1f')]['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x23')))),_0x4019('0x31')],[db[_0x4019('0x1f')]['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')]['fn']('IF',db['sequelize'][_0x4019('0x22')](_0x4019('0x32')))),_0x4019('0x33')],[db['sequelize']['fn'](_0x4019('0x1e'),db['sequelize']['fn']('IF',db[_0x4019('0x1f')]['literal'](_0x4019('0x34')))),'outboundCongestionCallsDay'],[db[_0x4019('0x1f')]['fn']('COUNT',db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x35')))),_0x4019('0x36')],[db['sequelize']['fn']('COUNT',db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x37')))),_0x4019('0x38')],[db[_0x4019('0x1f')]['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')]['fn']('IF',db['sequelize'][_0x4019('0x22')]('`state`\x20=\x2012,\x201,\x20null'))),_0x4019('0x39')],[db[_0x4019('0x1f')]['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x3a')))),_0x4019('0x3b')],[db['sequelize']['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x3c')))),_0x4019('0x3d')],[db[_0x4019('0x1f')]['fn']('COUNT',db[_0x4019('0x1f')]['fn']('IF',db['sequelize'][_0x4019('0x22')](_0x4019('0x3e')))),_0x4019('0x3f')],[db[_0x4019('0x1f')]['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')]['fn']('IF',db['sequelize'][_0x4019('0x22')](_0x4019('0x40')))),_0x4019('0x41')],[db[_0x4019('0x1f')]['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')]['fn']('IF',db['sequelize'][_0x4019('0x22')](_0x4019('0x42')))),_0x4019('0x3f')],[db[_0x4019('0x1f')]['fn']('COUNT',db['sequelize']['fn']('IF',db[_0x4019('0x1f')][_0x4019('0x22')](_0x4019('0x43')))),_0x4019('0x44')]],'group':[_0x4019('0x2e')]})[_0x4019('0xb')](function(_0x229b9a){logger[_0x4019('0xc')]('GetVoiceQueueHopperHistory',_0x3d6757);logger[_0x4019('0x1a')](_0x4019('0x2c'),_0x3d6757,JSON['stringify'](_0x229b9a));_0x3d7eb2(_0x229b9a);})[_0x4019('0x1b')](function(_0x46fd78){logger[_0x4019('0x12')]('GetVoiceQueueHopperHistory',_0x46fd78[_0x4019('0x13')],_0x3d6757);_0x2f6039(_0x536ad9[_0x4019('0x12')](0x1f4,_0x46fd78['message']));});});};exports['GetCampaignHopperHistory']=function(_0x4a3736){var _0x35dff1=this;return new Promise(function(_0x5ae382,_0xbe8262){return db[_0x4019('0x15')][_0x4019('0x2d')]({'raw':_0x4a3736[_0x4019('0x18')]?_0x4a3736[_0x4019('0x18')][_0x4019('0x19')]===undefined?!![]:![]:!![],'where':_0x4a3736[_0x4019('0x18')]?_0x4a3736[_0x4019('0x18')][_0x4019('0x1d')]||null:null,'attributes':[[_0x4019('0x2e'),_0x4019('0x2f')],[db['sequelize']['fn'](_0x4019('0x1e'),db[_0x4019('0x1f')][_0x4019('0x20')]('id')),_0x4019('0x45')],[db[_0x4019('0x1f')]['fn']('COUNT',db[_0x4019('0x1f')]['fn']('IF',db[_0x4019('0x1f')]['literal'](_0x4019('0x23')))),_0x4019('0x46')]],'group':['campaign']})[_0x4019('0xb')](function(_0x472f17){logger[_0x4019('0xc')](_0x4019('0x47'),_0x4a3736);logger[_0x4019('0x1a')]('GetCampaignHopperHistory',_0x4a3736,JSON[_0x4019('0x10')](_0x472f17));_0x5ae382(_0x472f17);})[_0x4019('0x1b')](function(_0x1c5ffc){logger['error'](_0x4019('0x47'),_0x1c5ffc[_0x4019('0x13')],_0x4a3736);_0xbe8262(_0x35dff1[_0x4019('0x12')](0x1f4,_0x1c5ffc[_0x4019('0x13')]));});});};