From 79a2a737987ff3890f8bc4c998905f352f36f5b1 Mon Sep 17 00:00:00 2001 From: davidvader Date: Wed, 1 Nov 2023 09:16:56 -0500 Subject: [PATCH] fix: use resource count returned from db --- api/build/graph.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/api/build/graph.go b/api/build/graph.go index ab80d5b09..58cadc356 100644 --- a/api/build/graph.go +++ b/api/build/graph.go @@ -155,7 +155,7 @@ func GetBuildGraph(c *gin.Context) { perPage := 100 for page > 0 { // retrieve build steps (per page) from the database - stepsPart, _, err := database.FromContext(c).ListStepsForBuild(b, nil, page, perPage) + stepsPart, stepsCount, err := database.FromContext(c).ListStepsForBuild(b, nil, page, perPage) if err != nil { retErr := fmt.Errorf("unable to retrieve steps for build %s: %w", entry, err) @@ -168,9 +168,7 @@ func GetBuildGraph(c *gin.Context) { steps = append(steps, stepsPart...) // assume no more pages exist if under 100 results are returned - // - // nolint: gomnd // ignore magic number - if len(stepsPart) < 100 { + if stepsCount < 100 { page = 0 } else { page++ @@ -189,7 +187,7 @@ func GetBuildGraph(c *gin.Context) { perPage = 100 for page > 0 { // retrieve build services (per page) from the database - servicesPart, _, err := database.FromContext(c).ListServicesForBuild(ctx, b, nil, page, perPage) + servicesPart, servicesCount, err := database.FromContext(c).ListServicesForBuild(ctx, b, nil, page, perPage) if err != nil { retErr := fmt.Errorf("unable to retrieve services for build %s: %w", entry, err) @@ -202,9 +200,7 @@ func GetBuildGraph(c *gin.Context) { services = append(services, servicesPart...) // assume no more pages exist if under 100 results are returned - // - // nolint: gomnd // ignore magic number - if len(servicesPart) < 100 { + if servicesCount < 100 { page = 0 } else { page++