Built motion from commit (unavailable).|2.0.72
[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 _0x863e=['`state`\x20=\x2016,\x201,\x20null','outboundAnswerAgiCallsDay','`state`\x20=\x2022\x20or\x20`state`\x20=\x2023,\x201,\x20null','outboundReCallsDay','ivrTotalCallsDays','ivrAnswerCallsDay','GetCampaignHopperHistory','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','request\x20sent','debug','stringify','error','code','message','CmHopperHistory,\x20%s,\x20%s','result','catch','CreateCmHopperHistory','CmHopperHistory','body','AvgHandleTime','findAll','options','where','sequelize','COUNT','col','predictiveIntervalTotalCalls','`state`\x20=\x204,\x201,\x20null','literal','`state`\x20=\x2010,\x201,\x20null','predictiveIntervalDroppedCallsTimeout','AVG','`state`\x20=\x204,\x20`holdtime`,\x20null','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','GetVoiceQueueHopperHistory','raw','campaign','name','outboundNoSuchCallsDay','`state`\x20=\x203,\x201,\x20null','outboundAnswerCallsDay','`state`\x20=\x205,\x201,\x20null','outboundBusyCallsDay','`state`\x20=\x208,\x201,\x20null','outboundDropCallsDayTimeout','`state`\x20=\x2011\x20,\x201,\x20null','outboundDropCallsDayCallersExit','`state`\x20=\x2012,\x201,\x20null','outboundUnknownCallsDay','outboundBlacklistCallsDay','`state`\x20=\x2014,\x201,\x20null','outboundOriginateFailureCallsDay','`state`\x20=\x2018,\x201,\x20null','outboundRejectCallsDay'];(function(_0x25430a,_0x46ee6c){var _0x5f8fd7=function(_0x19f9dd){while(--_0x19f9dd){_0x25430a['push'](_0x25430a['shift']());}};_0x5f8fd7(++_0x46ee6c);}(_0x863e,0x1ab));var _0xe863=function(_0x26fac8,_0x4c4906){_0x26fac8=_0x26fac8-0x0;var _0x1c54cc=_0x863e[_0x26fac8];return _0x1c54cc;};'use strict';var _=require(_0xe863('0x0'));var util=require(_0xe863('0x1'));var moment=require(_0xe863('0x2'));var BPromise=require(_0xe863('0x3'));var rs=require(_0xe863('0x4'));var fs=require('fs');var db=require(_0xe863('0x5'))['db'];var utils=require(_0xe863('0x6'));var logger=require(_0xe863('0x7'))(_0xe863('0x8'));var config=require(_0xe863('0x9'));var jayson=require(_0xe863('0xa'));var client=jayson[_0xe863('0xb')][_0xe863('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x3ff1fc,_0x427063,_0x3c7a3d){return new BPromise(function(_0x382f04,_0x7adfe7){return client['request'](_0x3ff1fc,_0x3c7a3d)[_0xe863('0xd')](function(_0xfdc40f){logger[_0xe863('0xe')]('CmHopperHistory,\x20%s,\x20%s',_0x427063,_0xe863('0xf'));logger[_0xe863('0x10')]('CmHopperHistory,\x20%s,\x20%s,\x20%s',_0x427063,'request\x20sent',JSON[_0xe863('0x11')](_0xfdc40f));if(_0xfdc40f[_0xe863('0x12')]){if(_0xfdc40f['error'][_0xe863('0x13')]===0x1f4){logger['error']('CmHopperHistory,\x20%s,\x20%s',_0x427063,_0xfdc40f[_0xe863('0x12')][_0xe863('0x14')]);return _0x7adfe7(_0xfdc40f['error']['message']);}logger['error'](_0xe863('0x15'),_0x427063,_0xfdc40f[_0xe863('0x12')][_0xe863('0x14')]);return _0x382f04(_0xfdc40f['error'][_0xe863('0x14')]);}else{logger[_0xe863('0xe')](_0xe863('0x15'),_0x427063,_0xe863('0xf'));_0x382f04(_0xfdc40f[_0xe863('0x16')][_0xe863('0x14')]);}})[_0xe863('0x17')](function(_0x307d2e){logger[_0xe863('0x12')](_0xe863('0x15'),_0x427063,_0x307d2e);_0x7adfe7(_0x307d2e);});});}exports[_0xe863('0x18')]=function(_0x236086){var _0x227915=this;return new Promise(function(_0x323026,_0x24b9cf){return db[_0xe863('0x19')]['create'](_0x236086[_0xe863('0x1a')],{'raw':_0x236086['options']?_0x236086['options']['raw']===undefined?!![]:![]:!![]})[_0xe863('0xd')](function(_0x1db187){logger[_0xe863('0xe')](_0xe863('0x18'),_0x236086);logger[_0xe863('0x10')](_0xe863('0x18'),_0x236086,JSON[_0xe863('0x11')](_0x1db187));_0x323026(_0x1db187);})[_0xe863('0x17')](function(_0x5e6bde){logger['error']('CreateCmHopperHistory',_0x5e6bde[_0xe863('0x14')],_0x236086);_0x24b9cf(_0x227915[_0xe863('0x12')](0x1f4,_0x5e6bde['message']));});});};exports[_0xe863('0x1b')]=function(_0x1177d7){var _0x484419=this;return new Promise(function(_0x40dad4,_0x5720a8){return db[_0xe863('0x19')][_0xe863('0x1c')]({'raw':_0x1177d7['options']?_0x1177d7[_0xe863('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x1177d7[_0xe863('0x1d')]?_0x1177d7[_0xe863('0x1d')][_0xe863('0x1e')]||null:null,'attributes':[[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db['sequelize'][_0xe863('0x21')]('id')),_0xe863('0x22')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db['sequelize']['literal'](_0xe863('0x23')))),'predictiveIntervalAnsweredCalls'],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db['sequelize'][_0xe863('0x24')](_0xe863('0x25')))),_0xe863('0x26')],[db['sequelize']['fn']('COUNT',db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')][_0xe863('0x24')]('`state`\x20=\x2011,\x201,\x20null'))),'predictiveIntervalDroppedCallsCallersExit'],[db[_0xe863('0x1f')]['fn'](_0xe863('0x27'),db['sequelize']['fn']('IF',db['sequelize'][_0xe863('0x24')](_0xe863('0x28')))),_0xe863('0x29')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x27'),db[_0xe863('0x1f')]['fn']('IF',db['sequelize'][_0xe863('0x24')]('`state`\x20=\x204,\x20`talktime`,\x20null'))),_0xe863('0x2a')]]})[_0xe863('0xd')](function(_0x1d9c4d){logger['info'](_0xe863('0x1b'),_0x1177d7);logger[_0xe863('0x10')](_0xe863('0x1b'),_0x1177d7,JSON[_0xe863('0x11')](_0x1d9c4d));_0x40dad4(_0x1d9c4d);})[_0xe863('0x17')](function(_0x1feab3){logger['error'](_0xe863('0x1b'),_0x1feab3[_0xe863('0x14')],_0x1177d7);_0x5720a8(_0x484419['error'](0x1f4,_0x1feab3[_0xe863('0x14')]));});});};exports[_0xe863('0x2b')]=function(_0x225102){var _0x227c2d=this;return new Promise(function(_0x1b59e8,_0xbdaa82){return db[_0xe863('0x19')][_0xe863('0x1c')]({'raw':_0x225102[_0xe863('0x1d')]?_0x225102[_0xe863('0x1d')][_0xe863('0x2c')]===undefined?!![]:![]:!![],'where':_0x225102['options']?_0x225102[_0xe863('0x1d')][_0xe863('0x1e')]||null:null,'attributes':[[_0xe863('0x2d'),_0xe863('0x2e')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')]['literal']('`state`\x20=\x200,\x201,\x20null'))),_0xe863('0x2f')],[db[_0xe863('0x1f')]['fn']('COUNT',db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')][_0xe863('0x24')](_0xe863('0x30')))),'outboundNoAnswerCallsDay'],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')]['literal'](_0xe863('0x23')))),_0xe863('0x31')],[db['sequelize']['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db['sequelize'][_0xe863('0x24')](_0xe863('0x32')))),_0xe863('0x33')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')]['literal'](_0xe863('0x34')))),'outboundCongestionCallsDay'],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')]['literal']('`state`\x20=\x2010\x20,\x201,\x20null'))),_0xe863('0x35')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')]['literal'](_0xe863('0x36')))),_0xe863('0x37')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')]['literal'](_0xe863('0x38')))),_0xe863('0x39')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')][_0xe863('0x24')]('`state`\x20=\x2013,\x201,\x20null'))),_0xe863('0x3a')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')]['literal'](_0xe863('0x3b')))),_0xe863('0x3c')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db['sequelize'][_0xe863('0x24')](_0xe863('0x3d')))),_0xe863('0x3e')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db['sequelize']['fn']('IF',db[_0xe863('0x1f')][_0xe863('0x24')](_0xe863('0x3f')))),_0xe863('0x40')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db[_0xe863('0x1f')][_0xe863('0x24')]('`state`\x20=\x2020,\x201,\x20null'))),'outboundRejectCallsDay'],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db['sequelize'][_0xe863('0x24')](_0xe863('0x41')))),_0xe863('0x42')]],'group':[_0xe863('0x2d')]})[_0xe863('0xd')](function(_0x3fbbf5){logger[_0xe863('0xe')](_0xe863('0x2b'),_0x225102);logger[_0xe863('0x10')](_0xe863('0x2b'),_0x225102,JSON[_0xe863('0x11')](_0x3fbbf5));_0x1b59e8(_0x3fbbf5);})[_0xe863('0x17')](function(_0x33e2c9){logger['error'](_0xe863('0x2b'),_0x33e2c9[_0xe863('0x14')],_0x225102);_0xbdaa82(_0x227c2d['error'](0x1f4,_0x33e2c9[_0xe863('0x14')]));});});};exports['GetCampaignHopperHistory']=function(_0x12ad07){var _0x4d8e18=this;return new Promise(function(_0x4c205b,_0x3b5a45){return db[_0xe863('0x19')][_0xe863('0x1c')]({'raw':_0x12ad07[_0xe863('0x1d')]?_0x12ad07[_0xe863('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x12ad07[_0xe863('0x1d')]?_0x12ad07[_0xe863('0x1d')][_0xe863('0x1e')]||null:null,'attributes':[[_0xe863('0x2d'),'name'],[db[_0xe863('0x1f')]['fn']('COUNT',db[_0xe863('0x1f')][_0xe863('0x21')]('id')),_0xe863('0x43')],[db[_0xe863('0x1f')]['fn'](_0xe863('0x20'),db[_0xe863('0x1f')]['fn']('IF',db['sequelize'][_0xe863('0x24')](_0xe863('0x23')))),_0xe863('0x44')]],'group':[_0xe863('0x2d')]})[_0xe863('0xd')](function(_0x3673b2){logger[_0xe863('0xe')](_0xe863('0x45'),_0x12ad07);logger[_0xe863('0x10')](_0xe863('0x45'),_0x12ad07,JSON[_0xe863('0x11')](_0x3673b2));_0x4c205b(_0x3673b2);})[_0xe863('0x17')](function(_0x21df4d){logger[_0xe863('0x12')](_0xe863('0x45'),_0x21df4d['message'],_0x12ad07);_0x3b5a45(_0x4d8e18[_0xe863('0x12')](0x1f4,_0x21df4d[_0xe863('0x14')]));});});};