From 3366d4ceb40cb807f7c4709be4bb0518c07f302c Mon Sep 17 00:00:00 2001 From: Tom Amberson Date: Wed, 21 Feb 2024 16:26:07 -0600 Subject: [PATCH] Fix incorrect day_avg_hrs caching Since the day_avg_hrs macro is 'for the current range' it should be cached with a key that takes the current range into account so it doesn't reuse the `_cached_log` for a different range. --- src/overview.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/overview.py b/src/overview.py index d630721..d8979d3 100644 --- a/src/overview.py +++ b/src/overview.py @@ -424,7 +424,11 @@ def _total_due_in_tree(tree: DeckTreeNode): cmd = Macro.CMD_DAY_AVERAGE_HOURS pattern = _time_pattern(cmd) for match in re.findall(pattern, updated_string): - logs = _cached_log(cmd, addon_config[Config.EXCLUDED_DIDS], _range_time_ms()) + logs = _cached_log( + _cache_key(cmd, cell_data[Config.RANGE]), + addon_config[Config.EXCLUDED_DIDS], + _range_time_ms(), + ) from_date = datetime.fromtimestamp(_range_time_ms()[0] / 1000) to_date = datetime.fromtimestamp(_range_time_ms()[1] / 1000) days_in_logs = (to_date - from_date).days