Skip to content

Commit

Permalink
fix: filter assignments to include only those in the current school year
Browse files Browse the repository at this point in the history
  • Loading branch information
vidigi committed Oct 29, 2024
1 parent 3d4ceae commit 6ee4a2b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions apps/frontend/src/routes/opgaver/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
onMount(async () => {
await assignmentStore.fetch();
if ($assignmentsPageSettingsStore) {
// filter to only include assignments that are in the current school year
// school year is not the same as calendar year
// each school year starts in august and ends in august the following year
const now = DateTime.now();
const currentYear = now.month >= 8 ? now.year : now.year - 1;
$assignmentStore ??= [];
$assignmentStore = $assignmentStore.filter((opgave) => {
const frist = DateTime.fromFormat(opgave.frist, 'd/M-yyyy HH:mm');
const fristYear = frist.month >= 8 ? frist.year : frist.year - 1;
return fristYear === currentYear;
});
}
originalOpgaver = $assignmentStore || [];
search();
});
Expand All @@ -47,19 +60,6 @@
return opgave.status === 'Afleveret' || opgave.status === 'Afsluttet';
}
});
if ($assignmentsPageSettingsStore) {
// filter to only include assignments that are in the current school year
// school year is not the same as calendar year
// each school year starts in august and ends in august the following year
const now = DateTime.now();
const currentYear = now.month >= 8 ? now.year : now.year - 1;
filteredOpgaver = filteredOpgaver.filter((opgave) => {
const frist = DateTime.fromFormat(opgave.frist, 'd/M-yyyy HH:mm');
const fristYear = frist.month >= 8 ? frist.year : frist.year - 1;
return fristYear === currentYear;
});
}
}
function search() {
Expand Down

0 comments on commit 6ee4a2b

Please sign in to comment.