Repository navigation
enquire_archive daily: read each archive file once - #339
Merged
Merged
Conversation
verbosity daily without a limit opened every archive file in the range on every call - 13 s for a month (about 6,900 files) on a Raspberry Pi class host. Archive files are written once and never changed, so the part the daily totals and the list filters need (created, outcome, priority, deliveries sent/failed, scenario names) is now kept in memory by file name; the next call opens only the files archived since. Names gone from the directory (purge_archive) drop out of the cache on the next scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xb3AAHgGH8CosCCseNn4yt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #338.
verbosity: dailywithout alimitopened every archive file in the range on every call. Archive files arewritten once and never changed, so
ArchiveDirectorynow keeps a daily record per file name (_daily_record:created, outcome, priority, deliveries sent/failed, scenario names) and
list_daily_recordsopens only files ithas not seen. Files gone from the directory (purge) are dropped from the cache on the next scan.
summarize_by_dayreads the record exactly as it reads the full file (tested).after,before,period,outcome,priority) work on the record;limitkeeps the old path.scandir+stat). On my HA the month took 12.8 s before.Tests:
test_action_reads_each_file_once,test_action_cached_matches_filters_and_purge,test_daily_record_keeps_what_the_summary_needs,test_daily_records_outside_home_assistant.CI replica: ruff check/format, codespell, mypy, ty green; pytest green on HA 2026.10 and HA 2026.5 (plus the four new tests);
archive.pynew lines covered.