mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Simplify query to find oldest state (#133700)
This commit is contained in:
parent
e43f4466e0
commit
02785a4ded
@ -640,9 +640,9 @@ def find_states_to_purge(
|
||||
def find_oldest_state() -> StatementLambdaElement:
|
||||
"""Find the last_updated_ts of the oldest state."""
|
||||
return lambda_stmt(
|
||||
lambda: select(States.last_updated_ts).where(
|
||||
States.state_id.in_(select(func.min(States.state_id)))
|
||||
)
|
||||
lambda: select(States.last_updated_ts)
|
||||
.order_by(States.last_updated_ts.asc())
|
||||
.limit(1)
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user