Skip to content

Commit

Permalink
CSCEXAM-459 Fix filtering by department
Browse files Browse the repository at this point in the history
  • Loading branch information
lupari committed Feb 4, 2025
1 parent fdb72f6 commit 7f709a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/ReportController.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public Result getIopReservations(Optional<String> dept, Optional<String> start,
.endOr();
query = applyFilters(
query,
"examEnrolment.exam.course",
"enrolment.exam.course",
"startAt",
dept.orElse(null),
start.orElse(null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class IopReservationStatisticsComponent implements OnInit {
@Input() queryParams: QueryParams = {};

reservations: Reservation[] = [];
grouped!: Record<string, Reservation[]>;
grouped: Record<string, Reservation[]> = {};

constructor(private Statistics: StatisticsService) {}

Expand All @@ -104,20 +104,13 @@ export class IopReservationStatisticsComponent implements OnInit {
this.grouped[org].filter((r) => r.externalReservation?.orgName && !r.enrolment?.noShow).length;
outgoingNoShowsTo = (org: keyof typeof this.grouped): number =>
this.grouped[org].filter((r) => r.externalReservation?.orgName && r.enrolment?.noShow === true).length;
totalIncoming = () =>
Object.keys(this.grouped)
.map((k) => this.incomingFrom(k))
.reduce((a, b) => a + b);
totalOutgoing = () =>
Object.keys(this.grouped)
.map((k) => this.outgoingTo(k))
.reduce((a, b) => a + b);
totalIncomingNoShows = () =>
Object.keys(this.grouped)
.map((k) => this.incomingNoShowsFrom(k))
.reduce((a, b) => a + b);
totalOutgoingNoShows = () =>
totalIncoming = () => this.reduce(this.incomingFrom);
totalOutgoing = () => this.reduce(this.outgoingTo);
totalIncomingNoShows = () => this.reduce(this.incomingNoShowsFrom);
totalOutgoingNoShows = () => this.reduce(this.outgoingNoShowsTo);

private reduce = (fn: (org: keyof typeof this.grouped) => number) =>
Object.keys(this.grouped)
.map((k) => this.outgoingNoShowsTo(k))
.reduce((a, b) => a + b);
.map(fn)
.reduce((a, b) => a + b, 0);
}

0 comments on commit 7f709a2

Please sign in to comment.