diff --git a/data/model/repository.py b/data/model/repository.py index 948d97cac..13499904f 100644 --- a/data/model/repository.py +++ b/data/model/repository.py @@ -231,6 +231,8 @@ def get_visible_repositories(username, namespace=None, include_public=False): """ Returns the repositories visible to the given user (if any). """ if not include_public and not username: + # Short circuit by returning a query that will find no repositories. We need to return a query + # here, as it will be modified by other queries later on. return Repository.select().where(Repository.id == -1) query = (Repository @@ -394,6 +396,6 @@ def list_popular_public_repos(action_count_threshold, time_span): .join(RepositoryActionCount) .where(RepositoryActionCount.date >= cutoff, Repository.visibility == get_public_repo_visibility()) - .group_by(RepositoryActionCount.repository) + .group_by(RepositoryActionCount.repository, Repository.name, Namespace.username) .having(fn.Sum(RepositoryActionCount.count) >= action_count_threshold) .tuples())