Skip to content

Commit

Permalink
feat: aggiunti parametri query from e to all'endpoint /seminars
Browse files Browse the repository at this point in the history
  • Loading branch information
aziis98 committed Nov 5, 2023
1 parent 7fe45bf commit 00a2bd4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions server/controllers/public/lessons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const EventPhdCourse = require('../../models/EventPhdCourse')

async function lessonsQuery(req) {
// TODO: Forse serve usare $add ~> <https://www.mongodb.com/docs/manual/reference/operator/aggregation/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: {
Expand Down
11 changes: 10 additions & 1 deletion server/controllers/public/seminars.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 00a2bd4

Please sign in to comment.