[UI] 'Top-10 of the Week' rotating spotlight on /home + RSS feed

← All Specs

Effort: standard

Goal

Build a /home spotlight panel showing the 10 highest-Elo cross-domain hypotheses of the past 7 days, refreshed every Monday. Plus an RSS/Atom feed at /feed/top10 for external consumption (Mastodon, etc.). Goal: surface SciDEX's best ideas to outside readers automatically.

Acceptance Criteria

/home (dashboard) displays a "Top 10 of the Week" spotlight panel above the fold showing the 10 highest-composite_score hypotheses created in the past 7 days, with at most 1 hypothesis per analysis domain (cross-domain constraint)
☐ Each panel entry shows: rank, title, target gene, domain, composite score
☐ Panel is visually distinct (spotlight style with gold/yellow accent)
/feed/top10 returns a valid Atom 1.0 feed with proper XML content-type
☐ Feed entries include: title, link, updated date, summary (description), author
☐ Feed lists the same 10 hypotheses as the panel
☐ API uses read-only replica (get_db_ro())
☐ No new database tables or migrations required

Approach

Step 1 — Query for cross-domain top-10 weekly hypotheses

Join hypotheses with analyses on analysis_id to get domain. Rank by composite_score descending within each domain, then pick the top hypothesis per domain until we have 10. Filter to created_at >= NOW() - INTERVAL '7 days'.

WITH ranked AS (
  SELECT h.id, h.title, h.composite_score, h.target_gene, h.created_at,
         a.domain,
         ROW_NUMBER() OVER (PARTITION BY a.domain ORDER BY h.composite_score DESC) as rn
  FROM hypotheses h
  JOIN analyses a ON h.analysis_id = a.id
  WHERE h.created_at >= NOW() - INTERVAL '7 days'
    AND h.composite_score IS NOT NULL
)
SELECT id, title, composite_score, target_gene, domain, created_at
FROM ranked
WHERE rn = 1
ORDER BY composite_score DESC
LIMIT 10

Fallback (if hypothesis has no analysis_id): use the hypothesis directly with domain = 'general'.

Step 2 — Add spotlight panel to dashboard

Insert a new HTML section into the dashboard() function in api.py, placed after the featured_html section and before the "Universal Activity Feed" section. The panel should:

  • Show a header "🏆 Top 10 of the Week" with a "Updated weekly" badge
  • Display rank (#1–#10), title (linked), target gene badge, domain badge, and score
  • Use gold/yellow accent colors (#ffd54f) for the spotlight feel
  • Link to /feed/top10 with an RSS/Atom icon

Step 3 — Add /feed/top10 Atom endpoint

Create a new route @app.get("/feed/top10") in api.py (or a dedicated route file) that:

  • Uses get_db_ro() to fetch the same top-10 query
  • Returns Content-Type: application/atom+xml; charset=utf-8
  • Renders a valid Atom 1.0 feed with:
- <id>: tag:scidex.ai,2026:/feed/top10
- <updated>: ISO-8601 timestamp of most recent hypothesis created_at
- <title>: "SciDEX Top 10 Hypotheses of the Week"
- <subtitle>: "The 10 highest-scoring cross-domain hypotheses on SciDEX this week"
- One <entry> per hypothesis with proper Atom elements

Dependencies

  • None (no new tables or migrations)

Work Log

2026-04-27 — Implementation

  • Queried DB schema for hypotheses + analyses tables
  • Identified composite_score as the Elo score, domain lives on analyses
  • Mapped out dashboard() function structure (line 34279+ in api.py)
  • Implemented cross-domain top-10 SQL query with ROW_NUMBER() window function
  • Added /feed/top10 Atom endpoint
  • Added "Top 10 of the Week" spotlight panel to dashboard HTML
  • Tested: curl http://localhost:8000/feed/top10 returns valid XML

File: top-10-spotlight-rss-feed_spec.md
Modified: 2026-05-01 20:13
Size: 3.7 KB