feat: use zero-time day for queries

main
RaviAnand Mohabir 3 weeks ago
parent f045fde26d
commit 1c420d9db8

@ -7,14 +7,17 @@ export const getCurrentAnnouncements = async (
const payload = await getPayload();
const today = new Date();
const todayDay = new Date(today.getFullYear(), today.getMonth(), today.getDay());
return await payload.find({
collection: "announcement",
sort: "from",
where: {
or: [
{ from: { equals: today } },
{ and: [{ from: { less_than_equal: today } }, { to: { greater_than_equal: today } }] },
{ from: { equals: todayDay } },
{
and: [{ from: { less_than_equal: todayDay } }, { to: { greater_than_equal: todayDay } }],
},
],
},
pagination: false,

@ -7,14 +7,17 @@ export const getCurrentHolidays = async (
const payload = await getPayload();
const today = new Date();
const todayDay = new Date(today.getFullYear(), today.getMonth(), today.getDay());
return await payload.find({
collection: "holiday",
sort: "from",
where: {
or: [
{ from: { equals: today } },
{ and: [{ from: { less_than_equal: today } }, { to: { greater_than_equal: today } }] },
{ from: { equals: todayDay } },
{
and: [{ from: { less_than_equal: todayDay } }, { to: { greater_than_equal: todayDay } }],
},
],
},
pagination: false,

@ -7,14 +7,17 @@ export const getCurrentVacations = async (
const payload = await getPayload();
const today = new Date();
const todayDay = new Date(today.getFullYear(), today.getMonth(), today.getDay());
return await payload.find({
collection: "vacation",
sort: "from",
where: {
or: [
{ from: { equals: today } },
{ and: [{ from: { less_than_equal: today } }, { to: { greater_than_equal: today } }] },
{ from: { equals: todayDay } },
{
and: [{ from: { less_than_equal: todayDay } }, { to: { greater_than_equal: todayDay } }],
},
],
},
pagination: false,

Loading…
Cancel
Save