Skip to content

feat(api): Add wiki-data endpoint for coverage help pages - #7770

Merged
albertisfu merged 6 commits into
mainfrom
7764-coverage-wiki-data-20260810
Aug 11, 2026
Merged

feat(api): Add wiki-data endpoint for coverage help pages#7770
albertisfu merged 6 commits into
mainfrom
7764-coverage-wiki-data-20260810

Conversation

@mlissner

@mlissner mlissner commented Aug 10, 2026

Copy link
Copy Markdown
Member

Fixes

Part of #7130 — implements #7764.

Summary

This adds a dedicated wiki_coverage_data() endpoint (/api/rest/v4/wiki-data/coverage/) that serves stats to the that are currently in the coverage page.

This skips the opinions coverage page b/c it's too complicated and we want to simplify it during this process.

Follows the wiki_data() pattern: cached for a day, with a staff-only ?bust_cache param to force a rebuild.

Deployment

This PR should:

  • skip-deploy (skips everything below)
    • skip-web-deploy
    • skip-celery-deploy
    • skip-cronjob-deploy
    • skip-daemon-deploy

AI Disclosure

  • Parts of this PR were created with the help of an AI tool, and I have carefully reviewed all of its content and take full responsibility for it.

🤖 Generated with Claude Code

mlissner and others added 2 commits August 10, 2026 16:58
Part of #7130 — API groundwork for moving the coverage help pages to
the wiki. wiki_data() is getting bloated, so this adds a dedicated
wiki_coverage_data() endpoint instead of extending it further.

Feeds the coverage, coverage_fds, and coverage_oa help pages:
- judges.count (judges DB size, used on the coverage overview page)
- oral_arguments.duration_minutes and a pre-rendered markdown table of
  oral argument search links, matching the coverage_oa page's layout
- financial_disclosures.* full breakdown (disclosures, investments,
  positions, agreements, non_investment_income, spousal_income,
  reimbursements, gifts, debts), reusing get_coverage_data_fds()

The opinions coverage page is intentionally left out: its data is a
nested court hierarchy driving interactive HTMX/chart forms, which
doesn't fit a flat JSON payload — that page already has its own
coverage_data_opinions() endpoint for the chart itself.

Follows the wiki_data() pattern: cached for a day, with a staff-only
?bust_cache param to force a rebuild.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Mirrors the existing wiki_data() test coverage: response shape and
field types, the oral argument court table's markdown rendering, and
staff-only ?bust_cache behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comment thread cl/api/views.py Outdated
Comment thread cl/api/tests.py Outdated
Comment thread cl/api/tests.py Outdated
Comment thread cl/api/tests.py Outdated
@mlissner
mlissner marked this pull request as ready for review August 11, 2026 00:09
Comment thread cl/api/views.py Outdated
Comment thread cl/api/views.py Outdated
Comment thread cl/api/tests.py Outdated
Comment thread cl/api/views.py Outdated
mlissner and others added 2 commits August 10, 2026 17:33
- Drop the oral-argument court markdown table entirely. The wiki editor
  will summarize OA coverage as text (circuit and supreme courts), so
  the endpoint no longer needs to render it.
- Extract get_or_build_wiki_json() to share the ?bust_cache + cache
  get/set logic between wiki_data() and wiki_coverage_data(), instead of
  duplicating it in both views.
- Replace BasicAPIPageTest's fixtures with a CourtFactory-created "ca1"
  court, per the no-fixtures rule.
- Move test_wiki_coverage_data_endpoint into BasicAPIPageTest and merge
  the two nearly-identical bust_cache tests into one parametrized test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
get_coverage_data_fds() caches its financial disclosure counts under
"coverage-data.fd3" for a week, independent of wiki_data() and
wiki_coverage_data()'s own caches. Staff hitting ?bust_cache — e.g.
right after new disclosures land, which wiki_coverage_data()'s
docstring calls out as the use case — still got up to a week-old FD
counts, because the outer rebuild happily returned the stale nested
cache entry.

Thread the bust_cache flag from get_or_build_wiki_json() through each
endpoint's build_data() callable and into get_coverage_data_fds(), so
busting an endpoint's cache actually refreshes the FD counts it embeds
too.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@mlissner mlissner left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, but a second review would be welcome.

CI failed: test_bust_cache_param's wiki_coverage_data case ran with
the client still logged in as staff from the wiki_data case's
aforce_login(staff), so the "anonymous/non-staff can't bust the cache"
request actually busted it and returned fresh data instead of the
sentinel. Give each subTest case its own fresh, logged-out client.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@albertisfu albertisfu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

@albertisfu
albertisfu enabled auto-merge August 11, 2026 22:30
@albertisfu
albertisfu merged commit 973136f into main Aug 11, 2026
9 checks passed
@albertisfu
albertisfu deleted the 7764-coverage-wiki-data-20260810 branch August 11, 2026 22:43
@github-project-automation github-project-automation Bot moved this from To Do to Done in Sprint (Web Team) Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants