mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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:
|
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)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user