From 4c34a99d59c3223a71ae69aa7efa87eea0c5db39 Mon Sep 17 00:00:00 2001 From: imcaizheng Date: Sat, 28 Nov 2020 17:06:36 +0800 Subject: [PATCH] fix weekly count --- src/services/TeamService.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/TeamService.js b/src/services/TeamService.js index 0f5c2b89..79c0113a 100644 --- a/src/services/TeamService.js +++ b/src/services/TeamService.js @@ -71,6 +71,8 @@ async function getTeamDetail (currentUser, projects, isSearch = true) { const firstDay = new Date(curr.setDate(first)) const lastDay = new Date(curr.setDate(last)) + lastDay.setHours(23, 59, 59, 59) // the end of the day + logger.debug({ component: 'TeamService', context: 'getTeamDetail', message: `week started: ${firstDay}, week ended: ${lastDay}` }) const result = [] for (const project of projects) { @@ -104,8 +106,9 @@ async function getTeamDetail (currentUser, projects, isSearch = true) { const startDate = new Date(item.startDate) const endDate = new Date(item.endDate) - if ((!item.startDate || (startDate <= firstDay && startDate < lastDay)) && - (!item.endDate || (endDate >= lastDay && endDate > firstDay))) { + // normally startDate is smaller than endDate for a resourceBooking so not check if startDate < endDate + if ((!item.startDate || startDate < lastDay) && + (!item.endDate || endDate > firstDay)) { res.weeklyCount += item.customerRate } }