diff --git a/server/controllers/public/lessons.js b/server/controllers/public/lessons.js index 52faeac4..0f929427 100644 --- a/server/controllers/public/lessons.js +++ b/server/controllers/public/lessons.js @@ -1,6 +1,10 @@ const EventPhdCourse = require('../../models/EventPhdCourse') async function lessonsQuery(req) { + // TODO: Forse serve usare $add ~> + const from = req.query.from ? new Date(req.query.from) : new Date() + const to = req.query.to ? new Date(req.query.to) : maxDate + const pipeline = [ {$unwind: '$lessons'}, {$project: { diff --git a/server/controllers/public/seminars.js b/server/controllers/public/seminars.js index e5fc0574..1f91427b 100644 --- a/server/controllers/public/seminars.js +++ b/server/controllers/public/seminars.js @@ -1,9 +1,18 @@ const EventSeminar = require('../../models/EventSeminar') +const maxDate = new Date(8640000000000000); + +/** @param {import('@types/express').Request} req */ async function seminarsQuery(req) { + const from = req.query.from ? new Date(req.query.from) : new Date() + const to = req.query.to ? new Date(req.query.to) : maxDate + const pipeline = [ { $match: { - startDatetime: {$gte: new Date()} + startDatetime: { + $gte: from, + $lt: to, + }, }}, { $lookup: { from: 'people',