-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into CSCEXAM-1391
- Loading branch information
Showing
16 changed files
with
248 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- SPDX-FileCopyrightText: 2024 The members of the EXAM Consortium | ||
-- | ||
-- SPDX-License-Identifier: EUPL-1.2 | ||
|
||
# --- !Ups | ||
ALTER TABLE reservation ADD external_org_ref character varying(32); | ||
ALTER TABLE reservation ADD external_org_name character varying(255); | ||
|
||
# --- !Downs | ||
ALTER TABLE reservation DROP external_org_ref; | ||
ALTER TABLE reservation DROP external_org_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -343,6 +343,8 @@ public void testProvideReservation() { | |
.put("start", ISODateTimeFormat.dateTime().print(start)) | ||
.put("end", ISODateTimeFormat.dateTime().print(end)) | ||
.put("user", "[email protected]") | ||
.put("orgRef", "1234") | ||
.put("orgName", "1234") | ||
); | ||
assertThat(result.status()).isEqualTo(201); | ||
Reservation reservation = DB.find(Reservation.class).where().eq("externalRef", RESERVATION_REF).findOne(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
ui/src/app/administrative/statistics/categories/iop-reservation-statistics.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// SPDX-FileCopyrightText: 2024 The members of the EXAM Consortium | ||
// | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
|
||
import { KeyValuePipe } from '@angular/common'; | ||
import type { OnInit } from '@angular/core'; | ||
import { Component, Input } from '@angular/core'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { groupBy } from 'ramda'; | ||
import { QueryParams } from 'src/app/administrative/administrative.model'; | ||
import { StatisticsService } from 'src/app/administrative/statistics/statistics.service'; | ||
import { Reservation } from 'src/app/reservation/reservation.model'; | ||
|
||
@Component({ | ||
template: ` | ||
<div class="row my-2"> | ||
<div class="col-12"> | ||
<button class="btn btn-primary" (click)="listReservations()"> | ||
{{ 'i18n_search' | translate }} | ||
</button> | ||
</div> | ||
</div> | ||
@if (grouped) { | ||
<div class="row"> | ||
<div class="col-12"> | ||
<table class="table table-striped table-sm"> | ||
<thead class="table-light"> | ||
<tr> | ||
<th>{{ 'i18n_faculty_name' | translate }}</th> | ||
<th>{{ 'i18n_outbound_reservations' | translate }}</th> | ||
<th> | ||
{{ 'i18n_outbound_reservations' | translate }} - | ||
{{ 'i18n_unused_reservation' | translate }} | ||
</th> | ||
<th>{{ 'i18n_inbound_reservations' | translate }}</th> | ||
<th> | ||
{{ 'i18n_inbound_reservations' | translate }} - | ||
{{ 'i18n_unused_reservation' | translate }} | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@for (rg of grouped | keyvalue; track rg) { | ||
<tr> | ||
<td>{{ rg.key }}</td> | ||
<td>{{ outgoingTo(rg.key) }}</td> | ||
<td>{{ outgoingNoShowsTo(rg.key) }}</td> | ||
<td>{{ incomingFrom(rg.key) }}</td> | ||
<td>{{ incomingNoShowsFrom(rg.key) }}</td> | ||
</tr> | ||
} | ||
</tbody> | ||
<tfoot class="table-light"> | ||
<tr> | ||
<td> | ||
<strong>{{ 'i18n_total' | translate }}</strong> | ||
</td> | ||
<td> | ||
<strong>{{ totalOutgoing() }}</strong> | ||
</td> | ||
<td> | ||
<strong>{{ totalOutgoingNoShows() }}</strong> | ||
</td> | ||
<td> | ||
<strong>{{ totalIncoming() }}</strong> | ||
</td> | ||
<td> | ||
<strong>{{ totalIncomingNoShows() }}</strong> | ||
</td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</div> | ||
</div> | ||
} | ||
`, | ||
selector: 'xm-iop-reservation-statistics', | ||
standalone: true, | ||
imports: [KeyValuePipe, TranslateModule], | ||
}) | ||
export class IopReservationStatisticsComponent implements OnInit { | ||
@Input() queryParams: QueryParams = {}; | ||
|
||
reservations: Reservation[] = []; | ||
grouped!: Record<string, Reservation[]>; | ||
|
||
constructor(private Statistics: StatisticsService) {} | ||
|
||
ngOnInit() { | ||
this.listReservations(); | ||
} | ||
|
||
listReservations = () => | ||
this.Statistics.listIopReservations$(this.queryParams).subscribe((resp) => { | ||
const byOrg = groupBy((r: Reservation) => r.externalOrgName || r.externalReservation?.orgName || ''); | ||
this.grouped = byOrg(resp) as Record<string, Reservation[]>; | ||
}); | ||
|
||
incomingFrom = (org: keyof typeof this.grouped): number => | ||
this.grouped[org].filter((r) => r.externalOrgRef && !r.enrolment?.noShow).length; | ||
incomingNoShowsFrom = (org: keyof typeof this.grouped): number => | ||
this.grouped[org].filter((r) => r.externalOrgRef && r.enrolment?.noShow === true).length; | ||
outgoingTo = (org: keyof typeof this.grouped): number => | ||
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 = () => | ||
Object.keys(this.grouped) | ||
.map((k) => this.outgoingNoShowsTo(k)) | ||
.reduce((a, b) => a + b); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.