✨ Return all future substitutions by default
This commit is contained in:
@ -36,9 +36,8 @@ export async function getSubstitutions(req, res) {
|
|||||||
if (req.query.from && req.query.to) {
|
if (req.query.from && req.query.to) {
|
||||||
from = new Date(req.query.from).setUTCHours(0, 0, 0, 0);
|
from = new Date(req.query.from).setUTCHours(0, 0, 0, 0);
|
||||||
to = new Date(req.query.to).setUTCHours(0, 0, 0, 0);
|
to = new Date(req.query.to).setUTCHours(0, 0, 0, 0);
|
||||||
} else {
|
} else if (req.query.date) {
|
||||||
date = new Date(req.query.date || new Date()).setUTCHours(0, 0, 0, 0);
|
date = new Date(req.query.date).setUTCHours(0, 0, 0, 0);
|
||||||
console.log(date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const prismaOptions = {
|
const prismaOptions = {
|
||||||
@ -57,8 +56,12 @@ export async function getSubstitutions(req, res) {
|
|||||||
gte: new Date(from),
|
gte: new Date(from),
|
||||||
lte: new Date(to),
|
lte: new Date(to),
|
||||||
};
|
};
|
||||||
} else {
|
} else if (date) {
|
||||||
prismaOptions.where.date = new Date(date);
|
prismaOptions.where.date = new Date(date);
|
||||||
|
} else {
|
||||||
|
prismaOptions.where.date = {
|
||||||
|
gte: new Date(new Date().setUTCHours(0, 0, 0, 0)),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawSubstitutions = await prisma.substitution.findMany(prismaOptions);
|
const rawSubstitutions = await prisma.substitution.findMany(prismaOptions);
|
||||||
|
Reference in New Issue
Block a user