Move the repo sorting by pull count into the main matching query, to both make it more accurate and make the search faster
This commit is contained in:
parent
396cba64e6
commit
0be0aed17d
2 changed files with 29 additions and 19 deletions
|
@ -205,11 +205,10 @@ def conduct_admined_team_search(username, query, encountered_teams, results):
|
|||
|
||||
def conduct_repo_search(username, query, results):
|
||||
""" Finds matching repositories. """
|
||||
matching_repos = list(model.get_matching_repositories(query, username, limit=5))
|
||||
matching_repo_counts = {t[0]: t[1] for t in model.get_repository_pull_counts(matching_repos)}
|
||||
matching_repos = model.get_matching_repositories(query, username, limit=5, pull_count_sort=True)
|
||||
|
||||
for repo in matching_repos:
|
||||
repo_score = math.log(matching_repo_counts.get(repo.id, 1), 10) or 1
|
||||
repo_score = math.log(repo.count or 1, 10) or 1
|
||||
|
||||
# If the repository is under the user's namespace, give it 50% more weight.
|
||||
namespace = repo.namespace_user.username
|
||||
|
|
Reference in a new issue