Skip to content
Snippets Groups Projects
Verified Commit b5af65d1 authored by Dorian Koch's avatar Dorian Koch
Browse files

Lecture Import: Sort by date, closes #68

parent ade41e89
Branches
No related tags found
No related merge requests found
Pipeline #6831 passed
...@@ -55,14 +55,23 @@ function TerminBody({ ...@@ -55,14 +55,23 @@ function TerminBody({
return (event: ICalEvent) => !nCi(event); return (event: ICalEvent) => !nCi(event);
}; };
const sortEvents = (a: ICalEvent, b: ICalEvent) => {
if (a.startDate === undefined || b.startDate === undefined) {
return 0;
}
return a.startDate.toMillis() - b.startDate.toMillis();
};
// find events that are new (place, duration and time unique) // find events that are new (place, duration and time unique)
const new_events = imported_events.current const new_events = imported_events.current
.filter(notContainedIn(existingEvents)) .filter(notContainedIn(existingEvents))
.filter(removeDuplicates); .filter(removeDuplicates)
.sort(sortEvents);
// find existing events that are not in the imported events // find existing events that are not in the imported events
const not_imported_events = existingEvents const not_imported_events = existingEvents
.filter(notContainedIn(imported_events.current)) .filter(notContainedIn(imported_events.current))
.filter(removeDuplicates); .filter(removeDuplicates)
.sort(sortEvents);
// events that are in both // events that are in both
const full_matches = imported_events.current const full_matches = imported_events.current
.filter(containedIn(existingEvents)) .filter(containedIn(existingEvents))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment