Skip to content

feat(fetcher): add *_trending batch — reddit / wikipedia / crypto / huggingface - #242

Merged
unhappychoice merged 1 commit into
mainfrom
feat/trending-fetchers-batch
May 16, 2026
Merged

unhappychoice merged 1 commit into
mainfrom
feat/trending-fetchers-batch

Conversation

@unhappychoice

@unhappychoice unhappychoice commented May 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a *_trending batch — four sibling fetchers covering the "what's hot right now" axis across distinct public APIs.

fetcher source family catalog sub-issue
reddit_trending /r/popular.json site-wide listing reddit_* #67
wikipedia_trending Wikimedia pageview top API (previous UTC day) wikipedia_* #67
crypto_trending CoinGecko /search/trending crypto_* #68
huggingface_trending HF Hub /api/{models|datasets|spaces}?sort=trendingScore huggingface_* (new) #64

All four are Safety::Safe (each host hardcoded; user input is closed enums or numeric counts), all cached, all share the same 7-shape contract:

Shape Notes
linked_text_block (default) clickable rows via OSC 8
image_linked_list thumbnails — direct from response (crypto), per-row REST summary (wikipedia), per-row reddit thumbnail (reddit), per-author user/org overview (huggingface)
text_block / text / markdown_text_block line variants
entries label → score key-value rows
bars rank-encoded for the chart family

Rejected shapes (Ratio / NumberSeries / PointSeries / Image / Calendar / Heatmap / Badge / Timeline) carry no natural representation for a "snapshot list of items ranked by popularity" — see the spec discussion on the trending batch.

Design notes

  • Reuse: reddit_trending plugs into the existing reddit/client.rs + Post DTO + thumbnail pipeline. common.rs exposes post_title / post_meta to the new module so the renderer can build Text / Markdown / Bars without duplicating the formatting helpers.
  • Wikipedia date handling: defaults to yesterday-in-UTC because the pageviews API serves complete days only and today's snapshot isn't finalised. Filters Main_Page, search, and meta namespaces (Special: / Wikipedia: / Portal: / File: / Category: / Help: / Template: / Talk:) so the list reads as real articles a reader would click.
  • CoinGecko trending bars: the API's own score field decays to zero for the lower half, which makes chart_bar collapse. rank_bar uses (MAX_COUNT - position).max(1) instead so the chart stays informative across the full top-15.
  • HF avatar resolution: not exposed in the trending response. Falls back to /api/users/{author} then /api/organizations/{author} (HF puts both in the same namespace but separate API paths). In-loop dedup keeps a 20-row feed at ≤ N distinct lookups when one org ships multiple trending models in the same window.

Test plan

  • cargo fmt --all -- --check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo test — 2,609 tests pass (73 new across the four fetchers)
  • User smoke-tested via a temporary .splashboard/dashboard.toml exercising each fetcher in two shapes (list_links + list_cards / chart_bar): list rendering, OSC 8 links, thumbnails, and number formatting all looked correct.

Reference pages

After this lands and the docs site rebuilds, the new fetchers will appear at:

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added trending cryptocurrency data source with currency selection
    • Added trending Hugging Face models, datasets, and spaces
    • Added Reddit popular posts trending feed
    • Added Wikipedia trending articles with language and access-type options
    • Multiple display formats supported across all trending sources

Review Change Stack

…uggingface

Four sibling fetchers covering the "what's hot right now" axis across
distinct public APIs. All Safety::Safe (each host hardcoded; user input
is closed enums or numeric counts), all cached, all share the same
7-shape contract: LinkedTextBlock (default) / ImageLinkedList /
TextBlock / Text / MarkdownTextBlock / Entries / Bars.

reddit_trending  — /r/popular.json site-wide listing, reuses the
                   existing reddit/client.rs + Post DTO; extends
                   common.rs to expose post_title / post_meta to
                   the new module.
wikipedia_trending — wikimedia.org pageview top API for the
                     previous UTC day, filters Main_Page / Special:
                     / Wikipedia: / Portal: / File: / Category: /
                     Help: / Template: / Talk: namespaces;
                     per-article /page/summary lookup resolves the
                     thumbnail URL for ImageLinkedList.
crypto_trending  — CoinGecko /search/trending; the response already
                   carries thumb URLs so ImageLinkedList needs no
                   N+1 fan-out. Rank-by-position bars
                   ((MAX_COUNT - position).max(1)) avoid the
                   degenerate "score=0" tail of CoinGecko's own
                   score field.
huggingface_trending — HF Hub /api/{models|datasets|spaces}
                       ?sort=trendingScore. Author avatar is
                       resolved per-author via /api/users then
                       /api/organizations fallback, dedup'd
                       in-loop so repeat authors don't fan out.

Ticks the candidate boxes on #67 (reddit_trending, wikipedia_trending),
#68 (crypto_trending), #64 (huggingface_trending).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 16, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds four new trending fetchers (CoinGecko, Hugging Face Hub, Reddit, Wikimedia) that retrieve and render trending data across different platforms. Each fetcher supports configurable options, HTTP fetching with size/status limits, multi-shape rendering with optional thumbnail downloads, sample payloads, and comprehensive unit tests.

Changes

Trending Fetchers Across Multiple Platforms

Layer / File(s) Summary
CryptoTrendingFetcher: CoinGecko Trending Coins
src/fetcher/crypto_trending.rs, src/fetcher/mod.rs
CryptoTrendingFetcher fetches top trending coins with user-configurable count (clamped to 15) and vs_currency (validated as lowercase 2–5 letter code). HTTP fetch enforces 5MB size limit and 2xx responses. Rendering supports text/text-block/markdown/entries/bars/image-linked-list shapes (default LinkedTextBlock), with optional thumbnail download and rank/market-cap labeling. Includes samples for all shapes and tests covering option parsing, currency normalization, rendering output, image-linked wiring, cache-key partitioning, and error handling.
HuggingfaceTrendingFetcher: HF Models/Datasets/Spaces
src/fetcher/huggingface_trending.rs
HuggingfaceTrendingFetcher retrieves trending entries from Hugging Face Hub using sort=trendingScore with configurable kind and count (clamped 1–30). HTTP fetch enforces 5MB limit with status validation. Pipeline normalizes likes/downloads, assigns ranks, and extracts author avatars. For ImageLinkedList, performs best-effort per-author thumbnail resolution via /overview endpoint with deduplication; other shapes render synchronously. Includes samples for all shapes and comprehensive tests covering option parsing, enum paths, URL construction, score formatting, and metadata exposure.
RedditTrendingFetcher: Reddit /r/popular Posts
src/fetcher/reddit/trending.rs, src/fetcher/reddit/common.rs, src/fetcher/reddit/mod.rs
RedditTrendingFetcher retrieves site-wide trending posts from /r/popular.json with configurable count (default 10). Rendering dispatches to text (single headline), markdown (bullet list), bars (score-based, negative clamped to 0), or image-linked-list (async thumbnail download). Other shapes delegate to shared render_posts. Supporting changes expose post_title and post_meta as pub(super) in common.rs. Includes samples for all shapes and tests covering option parsing, shape-specific rendering, cache-key variation by shape/count, and async dispatch.
WikipediaTrendingFetcher: Wikimedia Top Viewed Articles
src/fetcher/wikipedia/trending.rs, src/fetcher/wikipedia/mod.rs
WikipediaTrendingFetcher retrieves previous UTC day's top viewed articles from Wikimedia pageviews API with configurable lang, count (clamped 1–20), and access type. Article fetch builds percent-encoded URLs, filters non-article namespaces and placeholders. For ImageLinkedList, performs per-article /page/summary lookups to resolve thumbnails; other shapes render synchronously with view-count formatting (k/M units). Includes samples for all shapes and tests covering option parsing/rejection, article filtering, URL encoding, rendering behavior, and cache-key partitioning.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • unhappychoice/splashboard#152: Both PRs extend the Wikipedia fetcher family by adding new trending fetchers and updating fetchers() registry in wikipedia/mod.rs.
  • unhappychoice/splashboard#240: Both PRs extend Registry::with_builtins() in src/fetcher/mod.rs to register newly added fetchers via the same registry initialization path.

Poem

A quartet of feeds hops across the web wide,
CoinGecko, HF Hub, Reddit, Wiki collide—
Each trending with thumbnails and shape-shifting flair,
Unit tests hopping to certify care. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 49.47% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding four new trending fetchers (reddit, wikipedia, crypto, huggingface) in a batch. It is concise, specific, and clearly communicates the primary contribution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/trending-fetchers-batch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented May 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.10503% with 234 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.42%. Comparing base (952b1ea) to head (5b3515b).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/fetcher/huggingface_trending.rs 78.62% 93 Missing ⚠️
src/fetcher/crypto_trending.rs 85.62% 67 Missing ⚠️
src/fetcher/wikipedia/trending.rs 84.17% 66 Missing ⚠️
src/fetcher/reddit/trending.rs 96.76% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #242      +/-   ##
==========================================
- Coverage   95.71%   95.42%   -0.30%     
==========================================
  Files         207      211       +4     
  Lines       55326    56895    +1569     
==========================================
+ Hits        52958    54293    +1335     
- Misses       2368     2602     +234     
Files with missing lines Coverage Δ
src/fetcher/mod.rs 98.99% <100.00%> (+<0.01%) ⬆️
src/fetcher/reddit/common.rs 96.92% <100.00%> (ø)
src/fetcher/reddit/mod.rs 100.00% <100.00%> (ø)
src/fetcher/wikipedia/mod.rs 100.00% <100.00%> (ø)
src/fetcher/reddit/trending.rs 96.76% <96.76%> (ø)
src/fetcher/wikipedia/trending.rs 84.17% <84.17%> (ø)
src/fetcher/crypto_trending.rs 85.62% <85.62%> (ø)
src/fetcher/huggingface_trending.rs 78.62% <78.62%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@unhappychoice
unhappychoice merged commit 2ea314e into main May 16, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/trending-fetchers-batch branch May 16, 2026 15:16
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