add support for endDate

This commit is contained in:
Dobromir Popov
2024-04-05 15:07:27 +03:00
parent 95ac760447
commit 3c9dcfece6
2 changed files with 20 additions and 4 deletions

View File

@ -580,6 +580,7 @@ export async function filterPublishers(selectFields, searchText, filterDate, fet
//substract the time difference between from ISO string and local time
const offset = filterDate.getTimezoneOffset() * 60000; // offset in milliseconds
var dateAsISO = new Date(filterDate.getTime() + offset);
//if full day, match by date only
if (filterDate.getHours() == 0 || dateAsISO.getHours() == 0) {
whereClause["availabilities"] = {
some: {
@ -594,14 +595,23 @@ export async function filterPublishers(selectFields, searchText, filterDate, fet
// This includes availabilities from previous assignments but not with preference
{
dayOfMonth: null, // includes monthly and weekly repeats
dayofweek: dayOfWeekEnum
dayofweek: dayOfWeekEnum,
// ToDo: and weekOfMonth
//startTime: { gte: currentMonthStart },
startTime: { lte: filterDate },
AND: [
{
OR: [ // OR condition for repeatUntil to handle events that either end after filterDate or repeat forever
{ endDate: { gte: filterDate } },
{ endDate: null }
]
}
]
}
]
}
};
}
//if not full day, match by date and time
else {
//match exact time (should be same as data.findPublisherAvailability())
whereClause["availabilities"] = {
@ -617,12 +627,14 @@ export async function filterPublishers(selectFields, searchText, filterDate, fet
{
dayOfMonth: null,
dayofweek: dayOfWeekEnum,
startTime: { gte: filterDate },
}
]
}
};
}
} else { // we use month filter if date is passed and useDateFilter is false
} else {
// we use month filter if date is passed and useDateFilter is false to get all publishers with availabilities for the current month
if (fetchAvailabilities) {
// If no filter date, return all publishers's availabilities for currentMonthStart
whereClause["availabilities"] = {