feat: use zero-time day for queries

main
RaviAnand Mohabir 3 months ago
parent f045fde26d
commit 1c420d9db8

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

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

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

Loading…
Cancel
Save