Fix group_by clauses for postgres
This commit is contained in:
parent
079289c53c
commit
a2e2dcb010
1 changed files with 3 additions and 4 deletions
|
@ -626,7 +626,7 @@ def get_matching_users(username_prefix, robot_namespace=None,
|
||||||
|
|
||||||
query = (User
|
query = (User
|
||||||
.select(User.username, User.robot)
|
.select(User.username, User.robot)
|
||||||
.group_by(User.username)
|
.group_by(User.username, User.robot)
|
||||||
.where(direct_user_query))
|
.where(direct_user_query))
|
||||||
|
|
||||||
if organization:
|
if organization:
|
||||||
|
@ -2309,12 +2309,11 @@ def get_repository_usage():
|
||||||
one_month_ago = date.today() - timedelta(weeks=4)
|
one_month_ago = date.today() - timedelta(weeks=4)
|
||||||
repo_pull = LogEntryKind.get(name = 'pull_repo')
|
repo_pull = LogEntryKind.get(name = 'pull_repo')
|
||||||
repo_verb = LogEntryKind.get(name = 'repo_verb')
|
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.kind == repo_pull) | (LogEntry.kind == repo_verb))
|
||||||
.where(~(LogEntry.repository >> None))
|
.where(~(LogEntry.repository >> None))
|
||||||
.where(LogEntry.datetime >= one_month_ago)
|
.where(LogEntry.datetime >= one_month_ago)
|
||||||
.group_by(LogEntry.ip)
|
.group_by(LogEntry.ip, LogEntry.repository)
|
||||||
.group_by(LogEntry.repository)
|
|
||||||
.count())
|
.count())
|
||||||
|
|
||||||
def archivable_buildlogs_query():
|
def archivable_buildlogs_query():
|
||||||
|
|
Reference in a new issue