Simplify query to find oldest state (#133700)

This commit is contained in:
J. Nick Koston 2024-12-20 23:37:16 -10:00 committed by GitHub
parent e43f4466e0
commit 02785a4ded
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -640,9 +640,9 @@ def find_states_to_purge(
def find_oldest_state() -> StatementLambdaElement: def find_oldest_state() -> StatementLambdaElement:
"""Find the last_updated_ts of the oldest state.""" """Find the last_updated_ts of the oldest state."""
return lambda_stmt( return lambda_stmt(
lambda: select(States.last_updated_ts).where( lambda: select(States.last_updated_ts)
States.state_id.in_(select(func.min(States.state_id))) .order_by(States.last_updated_ts.asc())
) .limit(1)
) )