Add the logentrykind and performer information to log listing. This makes the system much faster, since new queries are not needed for every log entry.

This commit is contained in:
Joseph Schorr 2014-11-20 12:03:16 -05:00
parent 9b31b9805a
commit cc7bccea4c

View file

@ -2046,7 +2046,15 @@ def list_repo_notifications(namespace_name, repository_name, event_name=None):
def list_logs(start_time, end_time, performer=None, repository=None, namespace=None):
joined = LogEntry.select().join(User)
Performer = User.alias()
joined = (LogEntry.select(LogEntry, LogEntryKind, User, Performer)
.join(User)
.switch(LogEntry)
.join(Performer, JOIN_LEFT_OUTER,
on=(LogEntry.performer == Performer.id).alias('performer'))
.switch(LogEntry)
.join(LogEntryKind))
if repository:
joined = joined.where(LogEntry.repository == repository)