Skip to content

Commit 105b9c2

Browse files
committed
perf: implement historic_usage_set to optimise new usage data lookup
1 parent 550bc27 commit 105b9c2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ def get_and_update_historic_usage(
9292
# Append the new usage data to the existing historic usage data
9393
dates_added = []
9494
new_usage_data = []
95+
historic_usage_set = {d["day"] for d in historic_usage}
9596

9697
for day in usage_data:
97-
if not any(d["day"] == day["day"] for d in historic_usage):
98+
if not day["day"] in historic_usage_set:
9899
new_usage_data.append(day)
99100
dates_added.append(day["day"])
100101
logger.info("Added data for day %s", day["day"])

0 commit comments

Comments
 (0)