More performant implementation of event filter
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2022-12-28 15:27:31 +01:00
parent bafc56d604
commit 754408dfa3
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE

View File

@ -39,9 +39,6 @@ export class AdminComponent implements OnInit {
this.api.getEvents(this.selectedCalendar).subscribe((events: Event[]): void => { this.api.getEvents(this.selectedCalendar).subscribe((events: Event[]): void => {
for (let event of events) { for (let event of events) {
if(!this.checkEventMeetsFilterCriteria(event)) {
continue;
}
this.events.push({ this.events.push({
...event, ...event,
startDateTime: new Date(event.startDateTime), startDateTime: new Date(event.startDateTime),
@ -49,6 +46,7 @@ export class AdminComponent implements OnInit {
createdDate: new Date(event.createdDate) createdDate: new Date(event.createdDate)
}); });
} }
this.filterEvents();
this.sortEvents(); this.sortEvents();
}); });
} }
@ -76,6 +74,12 @@ export class AdminComponent implements OnInit {
} }
} }
filterEvents() {
this.events = this.events.filter((event) => {
return this.checkEventMeetsFilterCriteria(event);
});
}
checkEventMeetsFilterCriteria(event: Event): boolean { checkEventMeetsFilterCriteria(event: Event): boolean {
switch (this.eventFilter) { switch (this.eventFilter) {
case '': case '':
@ -121,6 +125,6 @@ export class AdminComponent implements OnInit {
return 1; return 1;
} }
return 1; return 1;
}) });
} }
} }