Skip to content

feat: run history & statistics dashboard#39

Open
bin101 wants to merge 3 commits into
mainfrom
feat/run-history-stats
Open

feat: run history & statistics dashboard#39
bin101 wants to merge 3 commits into
mainfrom
feat/run-history-stats

Conversation

@bin101

@bin101 bin101 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Rolling run history store (store.py): append_run_history / read_run_history β€” atomic JSON writes, capped at 500 entries newest-first, same pattern as all other store functions
  • Hook in scheduler job (app.py): compact RunResult snapshot persisted after every completed job (started_at, finished_at, dry_run, total, would_give, given, success)
  • GET /api/history?limit= (routes.py): returns up to 500 history entries; limit clamped server-side
  • Statistics tab (stats.js, index.html, tabs.js): summary cards (total runs, kudos given, dry-runs), 14-day daily kudos bar chart via pure <canvas> (no CDN β€” CSP-safe), last-20-runs detail table; lazy-loaded on first tab visit
  • ./stats.js added to importmap (routes.py::serve_index) for version-based cache-busting
  • 7 unit tests (tests/unit/test_run_history.py) written first (TDD)

Test plan

  • ruff check src tests β€” zero errors
  • ruff format --check src tests β€” zero issues
  • mypy src β€” zero type errors
  • pytest --cov=kudosy β€” 387 tests pass, 86% coverage (β‰₯ 85 %)
  • Trigger a dry-run β†’ check data/run-history.json has a new entry
  • GET /api/history returns the entry
  • Open Statistics tab β†’ summary cards populate, bar chart renders, history table shows the run
  • Refresh button reloads data without page reload

πŸ€– Generated with Claude Code

bin101 and others added 3 commits July 1, 2026 17:43
The 1450-line app.js is replaced by 12 focused ES modules:
state.js, dom.js, api.js, format.js, schedule-matrix.js,
athletes.js, config.js, settings.js, feed.js, status.js,
tabs.js, main.js.

The importmap in routes.py::serve_index now covers all local
modules so every module is cache-busted on release. Entry
point changes from app.js to main.js.

No behaviour change β€” all 380 tests pass, coverage 87 %.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a rolling run-history store (capped at 500 entries, newest-first) and
a Statistics tab that aggregates kudos per day, summary cards, and a
last-20-runs detail table rendered with a pure-canvas bar chart.

- store.py: append_run_history / read_run_history (atomic JSON writes)
- app.py: persist compact RunResult entry after every scheduler job
- routes.py: GET /api/history?limit= endpoint + ./stats.js in importmap
- static/stats.js: loadStats() + drawBarChart() (no CDN, CSP-safe)
- static/tabs.js: 'stats' added to validTabs; first-visit loadStats() call
- static/main.js: initStatsTab() wired in init()
- static/state.js: statsLoaded flag
- static/index.html: Statistics tab nav button + tab-pane (inside <main>)
- static/i18n.js: DE + EN keys for stats tab
- tests/unit/test_run_history.py: 7 unit tests (TDD)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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