mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Remove unused types argument in statistics query generation (#90431)
* Remove unused types argument in statistics query generation * update test
This commit is contained in:
parent
2c7c8ccbfe
commit
ce28bfe5b2
@ -1034,7 +1034,6 @@ def _generate_statistics_during_period_stmt(
|
||||
end_time: datetime | None,
|
||||
metadata_ids: list[int] | None,
|
||||
table: type[StatisticsBase],
|
||||
types: set[Literal["last_reset", "max", "mean", "min", "state", "sum"]],
|
||||
) -> StatementLambdaElement:
|
||||
"""Prepare a database query for statistics during a given period.
|
||||
|
||||
@ -1535,7 +1534,7 @@ def _statistics_during_period_with_session(
|
||||
if "sum" in types:
|
||||
columns = columns.add_columns(table.sum)
|
||||
stmt = _generate_statistics_during_period_stmt(
|
||||
columns, start_time, end_time, metadata_ids, table, types
|
||||
columns, start_time, end_time, metadata_ids, table
|
||||
)
|
||||
stats = cast(Sequence[Row], execute_stmt_lambda_element(session, stmt))
|
||||
|
||||
|
@ -1246,11 +1246,11 @@ def test_cache_key_for_generate_statistics_during_period_stmt() -> None:
|
||||
"""Test cache key for _generate_statistics_during_period_stmt."""
|
||||
columns = select(StatisticsShortTerm.metadata_id, StatisticsShortTerm.start_ts)
|
||||
stmt = _generate_statistics_during_period_stmt(
|
||||
columns, dt_util.utcnow(), dt_util.utcnow(), [0], StatisticsShortTerm, {}
|
||||
columns, dt_util.utcnow(), dt_util.utcnow(), [0], StatisticsShortTerm
|
||||
)
|
||||
cache_key_1 = stmt._generate_cache_key()
|
||||
stmt2 = _generate_statistics_during_period_stmt(
|
||||
columns, dt_util.utcnow(), dt_util.utcnow(), [0], StatisticsShortTerm, {}
|
||||
columns, dt_util.utcnow(), dt_util.utcnow(), [0], StatisticsShortTerm
|
||||
)
|
||||
cache_key_2 = stmt2._generate_cache_key()
|
||||
assert cache_key_1 == cache_key_2
|
||||
@ -1266,7 +1266,6 @@ def test_cache_key_for_generate_statistics_during_period_stmt() -> None:
|
||||
dt_util.utcnow(),
|
||||
[0],
|
||||
StatisticsShortTerm,
|
||||
{"max", "mean"},
|
||||
)
|
||||
cache_key_3 = stmt3._generate_cache_key()
|
||||
assert cache_key_1 != cache_key_3
|
||||
|
Loading…
x
Reference in New Issue
Block a user