Skip to content

Commit

Permalink
testing on forge.puppet.com/v3/releases shows that module & owner fil…
Browse files Browse the repository at this point in the history
…ters apply before offset, despite documentation implying otherwise
  • Loading branch information
Egari authored and dadav committed Dec 28, 2024
1 parent 39270b9 commit 0972519
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions internal/v3/api/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,9 @@ func (s *ReleaseOperationsApi) GetReleases(ctx context.Context, limit int32, off
}
}

prefiltered := []*gen.Release{}
if len(allReleases) > int(offset) {
prefiltered = allReleases[offset:]
}

if filterSet {
// We search through all available releases to see if they match the filter
for _, r := range prefiltered {
for _, r := range allReleases {
if module != "" && r.Module.Slug != module {
continue
}
Expand All @@ -343,17 +338,19 @@ func (s *ReleaseOperationsApi) GetReleases(ctx context.Context, limit int32, off
filtered = append(filtered, r)
}
} else {
filtered = prefiltered
filtered = allReleases
}

i := 1
for _, release := range filtered {
if i > int(limit) {
break
}
if len(filtered) > int(offset) {
i := 1
for _, release := range filtered[offset:] {
if i > int(limit) {
break
}

results = append(results, *release)
i++
results = append(results, *release)
i++
}
}

// If we're using a fallback-proxy, we should return a 404 so the proxy can handle the request
Expand Down

0 comments on commit 0972519

Please sign in to comment.