From 99412935b5ce090f7aee7991f295ff1021cadc42 Mon Sep 17 00:00:00 2001 From: Marcos Defendi Date: Mon, 23 Mar 2020 15:52:12 -0300 Subject: [PATCH] Fix omnichannel agent activity monitor --- .../server/statistics/LivechatAgentActivityMonitor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/livechat/server/statistics/LivechatAgentActivityMonitor.js b/app/livechat/server/statistics/LivechatAgentActivityMonitor.js index 2f0dd987bfbd2..413a36014cb0e 100644 --- a/app/livechat/server/statistics/LivechatAgentActivityMonitor.js +++ b/app/livechat/server/statistics/LivechatAgentActivityMonitor.js @@ -52,11 +52,11 @@ export class LivechatAgentActivityMonitor { return; } const today = moment(new Date()); - const yesterday = today.clone().subtract(1, 'days'); - const stoppedAt = new Date(yesterday.year(), yesterday.month(), yesterday.date(), 23, 59, 59); const startedAt = new Date(today.year(), today.month(), today.date()); for (const session of openLivechatAgentSessions) { - const data = { ...formatDate(yesterday), agentId: session.agentId }; + const startDate = moment(session.lastStartedAt); + const stoppedAt = new Date(startDate.year(), startDate.month(), startDate.date(), 23, 59, 59); + const data = { ...formatDate(startDate.toDate()), agentId: session.agentId }; const availableTime = moment(stoppedAt).diff(moment(new Date(session.lastStartedAt)), 'seconds'); LivechatAgentActivity.updateLastStoppedAt({ ...data, availableTime, lastStoppedAt: stoppedAt }); LivechatAgentActivity.updateServiceHistory({ ...data, serviceHistory: { startedAt: session.lastStartedAt, stoppedAt } });