OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Replace getAllPaginated with new helper function
Oliver Güntherdb973ebdf958
diff --git a/frontend/src/app/core/apiv3/endpoints/work_packages/api-v3-work-packages-paths.ts b/frontend/src/app/core/apiv3/endpoints/work_packages/api-v3-work-packages-paths.tsindex 01437fd6f4f..8430e1966e5 100644--- a/frontend/src/app/core/apiv3/endpoints/work_packages/api-v3-work-packages-paths.ts+++ b/frontend/src/app/core/apiv3/endpoints/work_packages/api-v3-work-packages-paths.ts@@ -159,11 +159,11 @@ export class ApiV3WorkPackagesPaths extends ApiV3Collection<WorkPackageResource,.halResourceService.getAllPaginated<WorkPackageCollectionResource>(this.path,- ids.length,{filters: ApiV3Filter('id', '=', ids).toJson(),},- );+ )+ .toPromise();}protected createCache():WorkPackageCache {diff --git a/frontend/src/app/features/hal/services/hal-resource.service.ts b/frontend/src/app/features/hal/services/hal-resource.service.tsindex c49259b2751..e5072f29a1e 100644--- a/frontend/src/app/features/hal/services/hal-resource.service.ts+++ b/frontend/src/app/features/hal/services/hal-resource.service.ts@@ -65,6 +65,7 @@ import {} from 'core-app/features/hal/resources/hal-resource';import { initializeHalProperties } from '../helpers/hal-resource-builder';import { HalError } from 'core-app/features/hal/services/hal-error';+import { getPaginatedResults } from 'core-app/core/apiv3/helpers/get-paginated-results';export interface HalResourceFactoryConfigInterface {cls?:any;@@ -142,46 +143,23 @@ export class HalResourceService {* Return all potential pages to the request, when the elements returned from API is smaller* than the expected.*- * @param href- * @param expected The expected number of elements- * @param params- * @param headers- * @return {Promise<CollectionResource[]>}+ * @param href The URL to request+ * @param params Parameters to pass to each paged request+ * @param headers Headers to pass to each paged request+ * @return {Observable<CollectionResource[]>}*/- public async getAllPaginated<T extends CollectionResource>(+ public getAllPaginated<T extends CollectionResource>(href:string,- expected:number,params:Record<string, string|number> = {},headers:HTTPClientHeaders = {},- ):Promise<T[]> {- // Total number retrieved- let retrieved = 0;- // Current offset page- let page = 1;- // Accumulated results- const allResults:T[] = [];- // If possible, request all at once.- const requestParams = { ...params };- requestParams.pageSize = expected;-- while (retrieved < expected) {- requestParams.offset = page;-- const promise = this.request<T>('get', href, this.toEprops(requestParams), headers).toPromise();- // eslint-disable-next-line no-await-in-loop- const results = await promise;-- if (results.count === 0) {- throw new Error('No more results for this query, but expected more.');- }-- allResults.push(results);-- retrieved += results.count;- page += 1;- }-- return allResults;+ ):Observable<T[]> {+ return getPaginatedResults(+ (pageParams) => {+ const requestParams = { ...params, pageParams };+ return this.request<CollectionResource<T>>('get', href, this.toEprops(requestParams), headers);+ },+ (params.pageSize as number|undefined) || -1,+ );}/**