Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] feat: hook up occurrence event filter #1658

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ export async function processFilters(
// if a startDateRange was provided, we prioritize that over individual startDateBefore or startDateAfter
// filters to prevent collisions
if (startDateRange.length) {
processedFilters.startDateTimeBefore = new Date(
startDateRange[0].to
).toISOString();
processedFilters.startDateTimeAfter = new Date(
startDateRange[0].from
).toISOString();
startDateRange[0].to &&
(processedFilters.startDateTimeBefore = new Date(
startDateRange[0].to
).toISOString());
startDateRange[0].from &&
(processedFilters.startDateTimeAfter = new Date(
startDateRange[0].from
).toISOString());
} else {
// individual startDateBefore & startDateAfter filters
const startDateBefore = getPredicateValuesByKey<string | number>(
Expand Down Expand Up @@ -194,12 +196,14 @@ export async function processFilters(
// if a endDateRange was provided, we prioritize that over individual endDateBefore or endDateAfter
// filters to prevent collisions
if (endDateRange.length) {
processedFilters.endDateTimeBefore = new Date(
endDateRange[0].to
).toISOString();
processedFilters.endDateTimeAfter = new Date(
endDateRange[0].from
).toISOString();
endDateRange[0].to &&
(processedFilters.endDateTimeBefore = new Date(
endDateRange[0].to
).toISOString());
endDateRange[0].from &&
(processedFilters.endDateTimeAfter = new Date(
endDateRange[0].from
).toISOString());
} else {
// individual endDateBefore & endDateAfter filters
const endDateBefore = getPredicateValuesByKey<string | number>(
Expand All @@ -221,5 +225,23 @@ export async function processFilters(
).toISOString();
}
}

const occurrence = getPredicateValuesByKey<string>(filters, "occurrence");
if (occurrence.length) {
occurrence.forEach((o) => {
switch (o) {
case "upcoming":
processedFilters.startDateTimeAfter = new Date().toISOString();
break;
case "past":
processedFilters.endDateTimeBefore = new Date().toISOString();
break;
case "inProgress":
processedFilters.startDateTimeBefore = new Date().toISOString();
processedFilters.endDateTimeAfter = new Date().toISOString();
break;
}
});
}
return processedFilters;
}
Loading