Skip to content

Commit

Permalink
fix(aws/findimage): Truncate results list after filters have been app…
Browse files Browse the repository at this point in the history
…lied (#4508)
  • Loading branch information
german-muzquiz committed May 18, 2020
1 parent ed76ff4 commit c968ca6
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ class AmazonNamedImageLookupController {
Collection<String> namedImageIdentifiers = !isAmi ? cacheView.filterIdentifiers(NAMED_IMAGES.ns, namedImageSearch) : []
Collection<String> imageIdentifiers = namedImageIdentifiers.isEmpty() ? cacheView.filterIdentifiers(IMAGES.ns, imageSearch) : []

namedImageIdentifiers = (namedImageIdentifiers as List).subList(0, Math.min(MAX_SEARCH_RESULTS, namedImageIdentifiers.size()))
Collection<CacheData> matchesByName = cacheView.getAll(NAMED_IMAGES.ns, namedImageIdentifiers, RelationshipCacheFilter.include(IMAGES.ns))

Collection<CacheData> matchesByImageId = cacheView.getAll(IMAGES.ns, imageIdentifiers)

return filter(
List<NamedImage> allFilteredImages = filter(
render(matchesByName, matchesByImageId, lookupOptions.q, lookupOptions.region),
extractTagFilters(request)
)

return allFilteredImages.subList(0, Math.min(MAX_SEARCH_RESULTS, allFilteredImages.size()))
}

private List<NamedImage> render(Collection<CacheData> namedImages, Collection<CacheData> images, String requestedName = null, String requiredRegion = null) {
Expand Down

0 comments on commit c968ca6

Please sign in to comment.