Skip to content

Commit

Permalink
if pagination not at end, presume at least a couple more pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 14, 2024
1 parent 352769e commit e134ba6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/implementation/cicd.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func (impl *DripStrictServerImplementation) GetGitcommitsummary(ctx context.Cont
summaries := make(map[string]*drip.GitCommitSummary)
commitsThusFar := 0
readCount := 4096
reachedEnd := false

for len(summaries) < targetCount {

Expand Down Expand Up @@ -181,6 +182,7 @@ func (impl *DripStrictServerImplementation) GetGitcommitsummary(ctx context.Cont
}
log.Ctx(ctx).Info().Msgf("Retrieved %d commits to summarize", len(commits))
if len(commits) == 0 {
reachedEnd = true
break
}

Expand Down Expand Up @@ -239,11 +241,15 @@ func (impl *DripStrictServerImplementation) GetGitcommitsummary(ctx context.Cont

paginatedSummaries := summarySlice[start:end]
totalPages := (len(summarySlice) + pageSize - 1) / pageSize
displayedTotalPages := totalPages
if !reachedEnd {
displayedTotalPages = page + 2
}

log.Ctx(ctx).Info().Msgf("Git commit summaries retrieved successfully, %d summaries, %d of %d pages", len(paginatedSummaries), page, totalPages)
return drip.GetGitcommitsummary200JSONResponse{
CommitSummaries: &paginatedSummaries,
TotalNumberOfPages: &totalPages,
TotalNumberOfPages: &displayedTotalPages,
}, nil
}

Expand Down

0 comments on commit e134ba6

Please sign in to comment.