From 2b3a134842390c80f77d2d6c509aac8f6ddf9ff9 Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Mon, 13 Jul 2026 09:09:30 +0100 Subject: [PATCH] fix --- .../report/controller/getDailyOverviewReport.js | 2 -- backend/services/dailyReport/dailyReport.js | 16 +++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/backend/endpoints/report/controller/getDailyOverviewReport.js b/backend/endpoints/report/controller/getDailyOverviewReport.js index d533902..6f630f4 100644 --- a/backend/endpoints/report/controller/getDailyOverviewReport.js +++ b/backend/endpoints/report/controller/getDailyOverviewReport.js @@ -16,8 +16,6 @@ module.exports = (db) => { // Check date let date = null; if (rawDate !== undefined && rawDate !== null) { - console.log(`hello ${rawDate}`); - if (typeof rawDate !== 'string') { return res .status(400) diff --git a/backend/services/dailyReport/dailyReport.js b/backend/services/dailyReport/dailyReport.js index 0fe28f4..1e34c42 100644 --- a/backend/services/dailyReport/dailyReport.js +++ b/backend/services/dailyReport/dailyReport.js @@ -6,21 +6,19 @@ const { getDaily } = require('../../endpoints/rota/scheduleLogic'); * @param {import('mongodb').Db} db */ module.exports = async (db) => { - // Get all the reports since the last daily report - const now = new Date(); - - const start = new Date(now); + // Get start and end time + const start = new Date(); start.setDate(start.getDate() - 1); start.setHours(11, 0, 0, 0); - const end = new Date(now); + const end = new Date(); end.setHours(10, 59, 59, 999); // Check to see if a report exists already and if one does exit out const reportExists = await db.collection('overviewReport').findOne({ date: { - $gte: now.setHours(0, 0, 0, 0).getTime(), - $lte: now.setHours(23, 59, 59, 999).getTime() + $gte: start.getTime(), + $lte: end.getTime() } }); @@ -57,8 +55,8 @@ module.exports = async (db) => { .collection('report') .find({ startDate: { - $gte: start, - $lte: end + $gte: start.getTime(), + $lte: end.getTime() } }) .toArray()