Make sure to re-sort the filtered repositories in search

The filtering breaks the ordered we expected, so we need to re-sort
This commit is contained in:
Joseph Schorr 2017-05-03 18:38:46 -04:00
parent 105acbc041
commit 9d97e053b3

View file

@ -464,7 +464,13 @@ def _filter_repositories_visible_to_username(unfiltered_query, filter_username,
.where(Repository.id << list(new_unfiltered_ids)))
filtered = _basequery.filter_to_repos_for_user(query, filter_username, repo_kind=repo_kind)
for filtered_repo in filtered:
# Sort the filtered repositories by their initial order.
all_filtered_repos = list(filtered)
all_filtered_repos.sort(key=lambda repo: found_ids.index(repo.id))
# Yield the repositories in sorted order.
for filtered_repo in all_filtered_repos:
yield filtered_repo
# If the number of found IDs is less than the chunk count, then we're done.