From 117ccda1cf773124382f4ac2f4dc4d6cded34fee Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 30 Jun 2016 17:31:46 -0400 Subject: [PATCH] Fix postgres error in SQL query --- data/model/repository.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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())