Follow-ups: cache-timestamp persistence, formatter dedup, config template, tests/CI - #47
Merged
Conversation
The cache file is now wrapped as {"updated_at", "items"} so the real
last-updated time survives a restart; previously it was reset to "now" on every
load, making a stale on-disk cache look fresh for another full update_interval.
Legacy bare-list cache files are still read, falling back to the file mtime.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the duplicated compact-duration helpers (plex_stats._format_watch_duration, media_commands._format_seconds) and the unused utilities.days_hours_minutes with a single canonical format_duration(). The "Total Watch Time" field now shows days for durations over 24h, consistent with the rest of the bot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover the pure helpers (check_response/get_response_data, format_duration, _parse_random_args, and the formatters in media_commands) with pytest, and add a CI job that installs the pinned requirements and runs them. Installing the requirements also verifies they resolve together on the supported Python. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ship config.example.json (a .gitignore negation keeps it out of the broad *.json ignore) so new users can `cp config.example.json config.json` and fill in their values, instead of hand-copying the structure from the README. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Follow-up improvements after the audit PR (#46), implementing the agreed items.
Persist media-cache timestamp across restarts
The cache file is now wrapped as
{"updated_at", "items"}so freshness survives a restart — previouslylast_updatedwas reset to now on every load, so a stale on-disk cache looked fresh for another fullupdate_interval. Legacy bare-list cache files are still read (falling back to the file mtime).Consolidate duration formatters
Collapsed three near-duplicate helpers —
plex_stats._format_watch_duration,media_commands._format_seconds, and the unusedutilities.days_hours_minutes— into a single canonicalutilities.format_duration(). (Minor improvement: "Total Watch Time" now shows days for >24h, consistent with the rest of the bot.)Config template
Added a committed
config.example.json(with a.gitignorenegation so it survives the broad*.jsonignore) so new users cancp config.example.json config.jsonand fill in values instead of hand-copying from the README.Tests + CI
Added
pytestunit tests for the pure helpers (check_response/get_response_data,format_duration,_parse_random_args, and the size/speed/clock formatters) and a CItestjob that installs the pinned requirements and runs them — which also verifies the dependency set resolves on the supported Python. 30 tests pass locally on 3.13.🤖 Generated with Claude Code