From c6e9dc8082a6795ec4d5ccd45ab0a0cb0023e295 Mon Sep 17 00:00:00 2001 From: BacLuc Date: Mon, 20 Nov 2023 14:45:28 +0100 Subject: [PATCH] frontend/api: add camp filter on days for Dashboard.vue That it's possible to load all days of a camp in one request. --- api/src/Entity/Day.php | 2 +- ...est__testOpenApiSpecMatchesSnapshot__1.yml | 26 +++++++++++++++++++ ...t__testRootEndpointMatchesSnapshot__1.json | 2 +- frontend/src/views/camp/Dashboard.vue | 7 +---- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/api/src/Entity/Day.php b/api/src/Entity/Day.php index 6a238dcb41..7b490cf5ef 100644 --- a/api/src/Entity/Day.php +++ b/api/src/Entity/Day.php @@ -38,7 +38,7 @@ normalizationContext: ['groups' => ['read']], order: ['period.start', 'dayOffset'] )] -#[ApiFilter(filterClass: SearchFilter::class, properties: ['period'])] +#[ApiFilter(filterClass: SearchFilter::class, properties: ['period', 'period.camp'])] #[UniqueEntity(fields: ['period', 'dayOffset'])] #[ORM\Entity(repositoryClass: DayRepository::class)] #[ORM\UniqueConstraint(name: 'offset_period_idx', columns: ['periodId', 'dayOffset'])] diff --git a/api/tests/Api/SnapshotTests/__snapshots__/ResponseSnapshotTest__testOpenApiSpecMatchesSnapshot__1.yml b/api/tests/Api/SnapshotTests/__snapshots__/ResponseSnapshotTest__testOpenApiSpecMatchesSnapshot__1.yml index 911c360d65..8126d24229 100644 --- a/api/tests/Api/SnapshotTests/__snapshots__/ResponseSnapshotTest__testOpenApiSpecMatchesSnapshot__1.yml +++ b/api/tests/Api/SnapshotTests/__snapshots__/ResponseSnapshotTest__testOpenApiSpecMatchesSnapshot__1.yml @@ -21462,6 +21462,32 @@ paths: schema: type: string style: form + - + allowEmptyValue: true + allowReserved: false + deprecated: false + description: '' + explode: false + in: query + name: period.camp + required: false + schema: + type: string + style: form + - + allowEmptyValue: true + allowReserved: false + deprecated: false + description: '' + explode: true + in: query + name: 'period.camp[]' + required: false + schema: + items: + type: string + type: array + style: form - allowEmptyValue: true allowReserved: false diff --git a/api/tests/Api/SnapshotTests/__snapshots__/ResponseSnapshotTest__testRootEndpointMatchesSnapshot__1.json b/api/tests/Api/SnapshotTests/__snapshots__/ResponseSnapshotTest__testRootEndpointMatchesSnapshot__1.json index 6014aa8d84..dff63932d5 100644 --- a/api/tests/Api/SnapshotTests/__snapshots__/ResponseSnapshotTest__testRootEndpointMatchesSnapshot__1.json +++ b/api/tests/Api/SnapshotTests/__snapshots__/ResponseSnapshotTest__testRootEndpointMatchesSnapshot__1.json @@ -41,7 +41,7 @@ "templated": true }, "days": { - "href": "\/days{\/id}{?period,period[]}", + "href": "\/days{\/id}{?period,period[],period.camp,period.camp[]}", "templated": true }, "invitations": { diff --git a/frontend/src/views/camp/Dashboard.vue b/frontend/src/views/camp/Dashboard.vue index 408b57088d..4e391e4287 100644 --- a/frontend/src/views/camp/Dashboard.vue +++ b/frontend/src/views/camp/Dashboard.vue @@ -404,12 +404,7 @@ export default { const { categories, periods, collaborators, progressLabels } = await loadAndProcessCollections(this.camp()) - await Promise.all( - this.camp() - .periods() - .items.map((period) => period._meta.self) - .map((periodHref) => this.api.get().days({ period: periodHref })) - ) + await this.api.get().days({ 'period.camp': this.camp()._meta.self }) const queryFilters = processRouteQuery(this.$route.query) const { period, responsible, category, progressLabel } = {