From 58b3a00b16543666b55afede114ad20ca74869e2 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 28 Nov 2022 19:48:06 +0100 Subject: [PATCH] Remove unnecessary DB access from statistic_during_period (#82871) --- homeassistant/components/recorder/statistics.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/homeassistant/components/recorder/statistics.py b/homeassistant/components/recorder/statistics.py index 7d7efd8b571..6c117b9698d 100644 --- a/homeassistant/components/recorder/statistics.py +++ b/homeassistant/components/recorder/statistics.py @@ -1502,13 +1502,6 @@ def statistic_during_period( main_start_time = start_time if head_end_time is None else head_end_time main_end_time = end_time if tail_start_time is None else tail_start_time - # Fetch metadata for the given statistic_id - metadata = get_metadata_with_session(session, statistic_ids=[statistic_id]) - if not metadata: - return result - - metadata_id = metadata[statistic_id][0] - if not types.isdisjoint({"max", "mean", "min"}): result = _get_max_mean_min_statistic( session,