More performant implementation of event filter
All checks were successful
Jenkins Production Deployment
All checks were successful
Jenkins Production Deployment
This commit is contained in:
parent
bafc56d604
commit
754408dfa3
|
@ -33,15 +33,12 @@ export class AdminComponent implements OnInit {
|
|||
getEvents(): void {
|
||||
this.events = [];
|
||||
|
||||
if(this.selectedCalendar === '') {
|
||||
if (this.selectedCalendar === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.api.getEvents(this.selectedCalendar).subscribe((events: Event[]): void => {
|
||||
for(let event of events) {
|
||||
if(!this.checkEventMeetsFilterCriteria(event)) {
|
||||
continue;
|
||||
}
|
||||
for (let event of events) {
|
||||
this.events.push({
|
||||
...event,
|
||||
startDateTime: new Date(event.startDateTime),
|
||||
|
@ -49,6 +46,7 @@ export class AdminComponent implements OnInit {
|
|||
createdDate: new Date(event.createdDate)
|
||||
});
|
||||
}
|
||||
this.filterEvents();
|
||||
this.sortEvents();
|
||||
});
|
||||
}
|
||||
|
@ -64,7 +62,7 @@ export class AdminComponent implements OnInit {
|
|||
}
|
||||
|
||||
getCalendarId(text: string): number {
|
||||
switch(text) {
|
||||
switch (text) {
|
||||
case 'public':
|
||||
return 1;
|
||||
case 'members':
|
||||
|
@ -76,6 +74,12 @@ export class AdminComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
filterEvents() {
|
||||
this.events = this.events.filter((event) => {
|
||||
return this.checkEventMeetsFilterCriteria(event);
|
||||
});
|
||||
}
|
||||
|
||||
checkEventMeetsFilterCriteria(event: Event): boolean {
|
||||
switch (this.eventFilter) {
|
||||
case '':
|
||||
|
@ -105,7 +109,7 @@ export class AdminComponent implements OnInit {
|
|||
}
|
||||
|
||||
sortEvents(): void {
|
||||
this.events.sort((a,b) => {
|
||||
this.events.sort((a, b) => {
|
||||
switch (this.eventSorting) {
|
||||
case '':
|
||||
return 1;
|
||||
|
@ -121,6 +125,6 @@ export class AdminComponent implements OnInit {
|
|||
return 1;
|
||||
}
|
||||
return 1;
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user