Skip to content

Commit

Permalink
fix: use resource count returned from db
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Nov 1, 2023
1 parent 272722f commit 79a2a73
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions api/build/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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++
Expand All @@ -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)

Expand All @@ -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++
Expand Down

0 comments on commit 79a2a73

Please sign in to comment.