Skip to content

Follow-ups: cache-timestamp persistence, formatter dedup, config template, tests/CI - #47

Merged
brah merged 4 commits into
mainfrom
audit/followups
Jun 16, 2026
Merged

Follow-ups: cache-timestamp persistence, formatter dedup, config template, tests/CI#47
brah merged 4 commits into
mainfrom
audit/followups

Conversation

@brah

@brah brah commented Jun 16, 2026

Copy link
Copy Markdown
Owner

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 — previously last_updated was reset to now on every load, so a stale on-disk cache looked fresh for another full update_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 unused utilities.days_hours_minutes — into a single canonical utilities.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 .gitignore negation so it survives the broad *.json ignore) so new users can cp config.example.json config.json and fill in values instead of hand-copying from the README.

Tests + CI

Added pytest unit tests for the pure helpers (check_response/get_response_data, format_duration, _parse_random_args, and the size/speed/clock formatters) and a CI test job 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

brah and others added 4 commits June 16, 2026 15:44
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>
@brah
brah merged commit 7e99c0c into main Jun 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant