Simplify and further optimize handling of unfiltered search results
Using the DB-side limit is much faster
This commit is contained in:
parent
8ede3084d8
commit
32255f122b
1 changed files with 5 additions and 10 deletions
|
@ -428,10 +428,6 @@ def get_app_search(lookup, search_fields=None, username=None, limit=50):
|
|||
offset=0, limit=limit)
|
||||
|
||||
|
||||
def _iterator_wrap(query):
|
||||
for row in query:
|
||||
yield row
|
||||
|
||||
def get_filtered_matching_repositories(lookup_value, filter_username=None, repo_kind='image',
|
||||
offset=0, limit=25, search_fields=None):
|
||||
""" Returns an iterator of all repositories matching the given lookup value, with optional
|
||||
|
@ -451,14 +447,13 @@ def get_filtered_matching_repositories(lookup_value, filter_username=None, repo_
|
|||
if filter_username is not None:
|
||||
iterator = _filter_repositories_visible_to_username(unfiltered_query, filter_username, limit,
|
||||
repo_kind)
|
||||
else:
|
||||
iterator = _iterator_wrap(unfiltered_query)
|
||||
if offset > 0:
|
||||
take(offset, iterator)
|
||||
|
||||
if offset > 0:
|
||||
take(offset, iterator)
|
||||
# Return the results.
|
||||
return list(take(limit, iterator))
|
||||
|
||||
# Return the results.
|
||||
return list(take(limit, iterator))
|
||||
return list(unfiltered_query.offset(offset).limit(limit))
|
||||
|
||||
|
||||
def _filter_repositories_visible_to_username(unfiltered_query, filter_username, limit, repo_kind):
|
||||
|
|
Reference in a new issue