improve stale cutoff id perf (#1392)

This commit is contained in:
Jimmy Zelinskie 2016-04-20 15:03:06 -04:00
parent ec35b3ba04
commit 7239c465bf

View file

@ -137,10 +137,8 @@ def get_stale_logs_cutoff_id(cutoff_date):
""" Gets the most recent ID created before the cutoff_date. """
try:
return (LogEntry
.select(LogEntry.id)
.select(fn.Min(LogEntry.id))
.where(LogEntry.datetime <= cutoff_date)
.order_by(LogEntry.id.desc())
.limit(1)
.tuples())[0][0]
except IndexError:
return None