Skip to content
Merged

fix #88

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions backend/endpoints/report/controller/getDailyOverviewReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 7 additions & 9 deletions backend/services/dailyReport/dailyReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
});

Expand Down Expand Up @@ -57,8 +55,8 @@ module.exports = async (db) => {
.collection('report')
.find({
startDate: {
$gte: start,
$lte: end
$gte: start.getTime(),
$lte: end.getTime()
}
})
.toArray()
Expand Down
Loading