Skip to content

Hide topics with 2 or fewer sources from A-Z, category browse, and Google [sc-45176]#3496

Open
nsantacruz wants to merge 2 commits into
masterfrom
chore/sc-45176/hiding-topics-with-two-or-less-sources
Open

Hide topics with 2 or fewer sources from A-Z, category browse, and Google [sc-45176]#3496
nsantacruz wants to merge 2 commits into
masterfrom
chore/sc-45176/hiding-topics-with-two-or-less-sources

Conversation

@nsantacruz

Copy link
Copy Markdown
Contributor

Summary

  • Topics with ≤2 sources no longer appear on the Topic A-Z page, category/TOC browse cards, or in Google (excluded from topics-sitemap.xml and marked noindex on their own page).
  • They remain fully intact in the database and still show up in other topics' "Related Topics" sidebars, as required — the sidebar path (annotate_topic_link) is untouched.
  • The existing curation exemption is preserved: a topic with ≤2 sources but a published description or data_source == "sefaria" still displays.
  • Topic.should_display() gains an optional min_sources param (default 1, preserving prior behavior everywhere it isn't explicitly overridden); the stricter threshold (MIN_SOURCES_FOR_TOPIC_DISPLAY = 3) is applied only at the three affected call sites: get_all_topics() (A-Z page), get_topic_toc_json_recursive() (category browse), and generate_topics_sitemap().
  • No frontend changes needed — the React components already key off the server-computed shouldDisplay field.

Test plan

  • pytest sefaria/model/tests/topic_test.py sefaria/helper/tests/topic_test.py — 33 passed, including new coverage for the threshold, the curation exemption, and get_all_topics(min_sources=...)
  • Confirmed two pre-existing, unrelated failures in reader/tests/social_image_api_test.py (ALLOWED_HOSTS/hostname handling) are present on master too, via git stash
  • Manual verification in a running environment: confirm a ≤2-source topic disappears from /topics/all/<letter> and its category page, still renders directly at /topics/<slug> with <meta name="robots" content="noindex, nofollow">, still appears in a linked topic's sidebar, and is absent from topics-sitemap.xml

🤖 Generated with Claude Code

…oogle search [sc-45176]

Topics with 2 or fewer sources are no longer surfaced on the Topic A-Z page,
category/TOC browse cards, or Google (excluded from the sitemap and marked
noindex on their own page). They remain fully intact in the database and
still appear in other topics' "Related Topics" sidebars.

should_display() gains an optional min_sources param (default preserves
existing behavior) so the stricter threshold can be applied only at the
three affected call sites, leaving the sidebar's annotate_topic_link() path
untouched.

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

Copy link
Copy Markdown

📊 Code Quality Score: 16/100

Base Score 40 × ESF 0.4 = 16

Category Score Factors
🔭 Scope 10/20 8 files across model/helper/view/sitemap/constants/tests; single feature applied to multiple surfaces; no new endpoints or DB migrations; contained within topic subsystem
🏗️ Architecture 6/20 Centralizes implicit threshold into named constant; refactors should_display to accept parameter; min_sources_for_display passed via kwargs following existing pattern; no new dependencies
⚙️ Implementation 7/20 Straightforward parameter threading; clean >= vs > equivalence at default; cache key behavior handled by framework; no complex algorithms
⚠️ Risk 6/20 Changes SEO behavior (noindex) for existing pages; modifies sitemap content; changes A-Z listing API response; easily reversible via constant change; no DB migrations or auth changes
✅ Quality 10/15 Good unit tests for should_display covering all branches including exemptions; integration test for get_all_topics; missing tests for view noindex, sitemap, and TOC path; helpful inline comments
🔒 Perf / Security 1/5 Cache behavior considered in tests; no security implications; no performance benchmarks

Was this score accurate? 👍 Yes · 👎 No

Scored by GitVelocity · How are scores calculated?

Collapses four repetitive test methods into a single pytest.mark.parametrize
covering the same cases (default vs raised threshold, curation exemptions,
explicit shouldDisplay=False override).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@nsantacruz nsantacruz requested a review from yonadavGit July 8, 2026 18:46
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