Remove unused types argument in statistics query generation (#90431)

* Remove unused types argument in statistics query generation

* update test
This commit is contained in:
J. Nick Koston 2023-03-28 17:01:11 -10:00 committed by GitHub
parent 2c7c8ccbfe
commit ce28bfe5b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -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))

View File

@ -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