improve stale cutoff id perf (#1392)
This commit is contained in:
parent
ec35b3ba04
commit
7239c465bf
1 changed files with 1 additions and 3 deletions
|
@ -137,10 +137,8 @@ def get_stale_logs_cutoff_id(cutoff_date):
|
||||||
""" Gets the most recent ID created before the cutoff_date. """
|
""" Gets the most recent ID created before the cutoff_date. """
|
||||||
try:
|
try:
|
||||||
return (LogEntry
|
return (LogEntry
|
||||||
.select(LogEntry.id)
|
.select(fn.Min(LogEntry.id))
|
||||||
.where(LogEntry.datetime <= cutoff_date)
|
.where(LogEntry.datetime <= cutoff_date)
|
||||||
.order_by(LogEntry.id.desc())
|
|
||||||
.limit(1)
|
|
||||||
.tuples())[0][0]
|
.tuples())[0][0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return None
|
return None
|
||||||
|
|
Reference in a new issue