From 1e2ec4ac717d6b6265052b09cd4dd775bb15fed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 19 Jun 2024 15:00:20 +0200 Subject: [PATCH] split up API requests for relations in gantt chart --- .../endpoints/relations/apiv3-relations-paths.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/core/apiv3/endpoints/relations/apiv3-relations-paths.ts b/frontend/src/app/core/apiv3/endpoints/relations/apiv3-relations-paths.ts index cc2956e0b9ff..2aa1dd9a8e0b 100644 --- a/frontend/src/app/core/apiv3/endpoints/relations/apiv3-relations-paths.ts +++ b/frontend/src/app/core/apiv3/endpoints/relations/apiv3-relations-paths.ts @@ -28,12 +28,14 @@ import { ApiV3GettableResource, ApiV3ResourceCollection } from 'core-app/core/apiv3/paths/apiv3-resource'; import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service'; -import { from, Observable } from 'rxjs'; +import { forkJoin, from, Observable } from 'rxjs'; import { CollectionResource } from 'core-app/features/hal/resources/collection-resource'; import { RelationResource } from 'core-app/features/hal/resources/relation-resource'; import { map } from 'rxjs/operators'; import { ApiV3Filter } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder'; +export const MAGIC_RELATION_SIZE = 100; + export class ApiV3RelationsPaths extends ApiV3ResourceCollection> { constructor(protected apiRoot:ApiV3Service, protected basePath:string) { @@ -50,6 +52,14 @@ export class ApiV3RelationsPaths extends ApiV3ResourceCollection { + if (workPackageIds.length > MAGIC_RELATION_SIZE) { + const chunks = _.chunk(workPackageIds, MAGIC_RELATION_SIZE); + return forkJoin(chunks.map((chunk) => this.loadInvolved(chunk))) + .pipe( + map((results) => _.flatten(results)), + ); + } + const validIds = _.filter(workPackageIds, (id) => /\d+/.test(id)); if (validIds.length === 0) {