From a2e2dcb010fd3dd1a9cc40ffc3b65ff47debf829 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 12 Nov 2014 20:32:06 -0500 Subject: [PATCH] Fix group_by clauses for postgres --- data/model/legacy.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/data/model/legacy.py b/data/model/legacy.py index 9050830ef..c31c553b7 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -626,7 +626,7 @@ def get_matching_users(username_prefix, robot_namespace=None, query = (User .select(User.username, User.robot) - .group_by(User.username) + .group_by(User.username, User.robot) .where(direct_user_query)) if organization: @@ -2309,12 +2309,11 @@ def get_repository_usage(): one_month_ago = date.today() - timedelta(weeks=4) repo_pull = LogEntryKind.get(name = 'pull_repo') repo_verb = LogEntryKind.get(name = 'repo_verb') - return (LogEntry.select() + return (LogEntry.select(LogEntry.ip, LogEntry.repository) .where((LogEntry.kind == repo_pull) | (LogEntry.kind == repo_verb)) .where(~(LogEntry.repository >> None)) .where(LogEntry.datetime >= one_month_ago) - .group_by(LogEntry.ip) - .group_by(LogEntry.repository) + .group_by(LogEntry.ip, LogEntry.repository) .count()) def archivable_buildlogs_query():