Skip to content

Commit

Permalink
Request up to 1000 ingredients at a time during searches to avoid mul…
Browse files Browse the repository at this point in the history
…tiple paged requests.
  • Loading branch information
mitchell-as committed Sep 5, 2024
1 parent c8af791 commit b42e6d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/platform/model/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ type ErrTooManyMatches struct {

func searchIngredientsNamespace(ns string, name string, includeVersions bool, exactOnly bool, partial bool, ts *time.Time, auth *authentication.Auth) ([]*IngredientAndVersion, error) {
defer profile.Measure("searchIngredientsNamespace", time.Now())
limit := 100
limit := 1000
offset := 0

if ts == nil {
Expand All @@ -198,7 +198,7 @@ func searchIngredientsNamespace(ns string, name string, includeVersions bool, ex
var ingredients []*IngredientAndVersion
for {
response := hsInventoryModel.SearchIngredientsResponse{}
if offset > (limit * 10) { // at most we will get 10 pages of ingredients (that's ONE THOUSAND ingredients)
if offset > 0 {
// Guard against queries that match TOO MANY ingredients
return nil, &ErrTooManyMatches{locale.NewInputError("err_searchingredient_toomany", "", name), name}
}
Expand Down

0 comments on commit b42e6d9

Please sign in to comment.