Skip to content

feat(fetcher): add fortune cookie fetcher + expand quote_of_day to 567 entries - #157

Merged
unhappychoice merged 4 commits into
mainfrom
feat/fortune-fetcher
Apr 26, 2026
Merged

unhappychoice merged 4 commits into
mainfrom
feat/fortune-fetcher

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Apr 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • New fortune fetcher — 445 classic Unix-style fortune cookies (one-liners, programmer humor, fortune-cookie wisdom, a few short verses). Realtime / Safe / zero-config; TextBlock default + Text shape.
  • quote_of_day refactored to mod.rs + data.txt, expanded from 50 → 567 entries.
  • Daily index switched from day_of_year % N to epoch_days % N for both — rotation drifts year over year instead of locking the same quote/cookie to the same calendar date forever.

The previous 50-entry quote_of_day would surface the same line ~7 times a year; 365+ entries plus epoch-days indexing eliminate within-year and year-over-year repeats.

Ticks the fortune checkbox in #67.

fortune reference

  • Kind: realtime
  • Safety: Safe
  • Shapes: text_block, text
  • Options: none
Shape Compatible renderers
text_block animated_boot, animated_postfx, animated_scanlines, animated_splitflap, animated_wave, list_plain, text_plain
text animated_boot, animated_figlet_morph, animated_postfx, animated_scanlines, animated_splitflap, animated_typewriter, animated_wave, text_ascii, text_plain

quote_of_day (refactor) reference

Shape table unchanged; same compatible renderer list as fortune. The only user-visible behaviour change: the same calendar date no longer always returns the same quote year over year (epoch-days rotation).

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test (781 passed, 0 failed)
  • Local smoke-test in cargo run --bin splashboard with both shapes for both fetchers
  • Both data files parse to ≥365 entries (covered by *_list_meets_size_floor tests)
  • pick_drifts_year_over_year test asserts the new index function actually drifts

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a fortune cookie provider that delivers deterministic daily fortunes.
  • Refactor

    • Restructured the quote provider into a modular architecture with organized data storage.

unhappychoice and others added 2 commits April 26, 2026 18:26
Move the bundled quotes from inline `(&str, &str)` array to a `%`-separated
`data.txt` parsed once via LazyLock. Switch the daily index from
`day_of_year % N` to `epoch_days % N` so the rotation drifts year over year
instead of locking the same quote to the same calendar date forever.

The previous 50-entry list saw the same quote ~7 times a year; 567 entries
guarantee no within-year repeat, and epoch-days indexing breaks the
calendar-stable repeat across years.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`fortune` ships a bundled set of 445 classic Unix-style fortune cookies — a
mix of one-liners, programmer humor, fortune-cookie wisdom, and a few short
verses. Realtime / Safe / zero-config; mirrors `quote_of_day`'s shape table
(`TextBlock` default + `Text`) but with no author attribution and multi-line
cookies preserved.

Selection is deterministic per calendar day via `epoch_days % N`, so the
cookie advances at midnight and drifts through the calendar year over year.

Ticks the `fortune` checkbox in #67.

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

coderabbitai Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@unhappychoice has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 23 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 48 minutes and 23 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a8678af6-b8b8-4b87-b4ae-4e0c4a401b19

📥 Commits

Reviewing files that changed from the base of the PR and between ad2422f and f94c937.

📒 Files selected for processing (4)
  • src/fetcher/fortune/data.txt
  • src/fetcher/fortune/mod.rs
  • src/fetcher/quote_of_day/data.txt
  • src/fetcher/quote_of_day/mod.rs
📝 Walkthrough

Walkthrough

This PR introduces a new FortuneFetcher that delivers daily fortune-cookie phrases and reorganizes the QuoteOfDayFetcher from a single file into a module structure with separated data. Both fetchers deterministically select content per calendar day using epoch-day modulo logic, supporting single-line and multi-line rendering modes. The fetcher registry is updated to include both modules.

Changes

Cohort / File(s) Summary
Fortune Fetcher
src/fetcher/fortune/mod.rs, src/fetcher/fortune/data.txt
New realtime fetcher that returns daily fortune-cookie phrases. Implementation includes time-based selection via epoch-day modulo, parsing logic for %-delimited entries, rendering in Text or TextBlock shapes, and comprehensive unit tests. Data file contains 900+ fortune entries including programming-themed sayings.
Quote of Day Refactor
src/fetcher/quote_of_day.rs (deleted), src/fetcher/quote_of_day/mod.rs, src/fetcher/quote_of_day/data.txt
Existing quote fetcher reorganized from single monolithic file into module structure with separated data. Maintains identical deterministic per-day selection logic, parsing of quote/author pairs, and multi-format rendering. Data file contains 1700+ lines of quoted phrases with attributions.
Fetcher Registry
src/fetcher/mod.rs
Updated to export fortune and quote_of_day modules and register both fetchers in the realtime fetcher registry, making them available for use.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Fetcher as FortuneFetcher/<br/>QuoteOfDayFetcher
    participant Time as Time System
    participant Data as Parsed Data

    Client->>Fetcher: FetchContext (shape)
    Fetcher->>Time: Get local time
    Time-->>Fetcher: current epoch day
    Fetcher->>Data: index = epoch_day % data.len()
    Data-->>Fetcher: selected entry
    alt shape == Text
        Fetcher->>Fetcher: Render single line
    else shape == TextBlock
        Fetcher->>Fetcher: Split on newlines
    end
    Fetcher-->>Client: Payload (Text or TextBlock)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #114: Modifies the fetcher registry to add and register new fetcher modules with similar module export and registration patterns.
  • PR #152: Updates the fetcher registry to integrate new built-in fetchers into the system, following the same registration approach as this PR.

Poem

🥠 Two oracles join the fetch today,
One whispers quotes, one fortunes say—
Each day a new pearl from the heap,
Time and modulo numbers keep.
Fortune smiles, wisdom grows bright! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.36% 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 changes: adding a fortune cookie fetcher and expanding quote_of_day entries, matching the actual implementation.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fortune-fetcher

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 Apr 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.01389% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.37%. Comparing base (0d5ebb2) to head (f94c937).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/fetcher/fortune/mod.rs 87.20% 16 Missing ⚠️
src/fetcher/quote_of_day/mod.rs 95.67% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
+ Coverage   78.16%   78.37%   +0.20%     
==========================================
  Files         113      116       +3     
  Lines       21378    21897     +519     
==========================================
+ Hits        16711    17161     +450     
- Misses       4667     4736      +69     
Files with missing lines Coverage Δ
src/fetcher/mod.rs 84.15% <100.00%> (+0.17%) ⬆️
src/fetcher/quote_of_day/mod.rs 95.67% <95.67%> (ø)
src/fetcher/fortune/mod.rs 87.20% <87.20%> (ø)

... and 2 files 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/fetcher/quote_of_day/data.txt`:
- Around line 1-1700: The file contains exact and near-duplicate quotes and
conflicting attributions which reduce variety; run a dedup and normalization
pass over the dataset: (1) remove exact duplicate entries (e.g. "Action is the
foundational key to all success." — Pablo Picasso; "Be yourself; everyone else
is already taken." — Oscar Wilde; "The only person you are destined to become is
the person you decide to be." — Ralph Waldo Emerson; "The man of knowledge must
be able not only to love his enemies but also to hate his friends." — Friedrich
Nietzsche), (2) collapse near-duplicates by normalizing punctuation/whitespace
so only one canonical phrasing remains (examples around the pairs highlighted in
the review), and (3) resolve conflicting attributions by choosing a single
canonical author per quote (for the conflicts like "Twenty years from now you
will be more disappointed…" and "Knowing is not enough; we must apply…") and
remove the alternate entry; save the cleaned list back to data.txt so epoch_days
% N no longer returns repeated or ambiguously attributed quotes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8bba075b-ef9b-4c0b-b91a-2fbe40bffaea

📥 Commits

Reviewing files that changed from the base of the PR and between 87c88b7 and ad2422f.

📒 Files selected for processing (6)
  • src/fetcher/fortune/data.txt
  • src/fetcher/fortune/mod.rs
  • src/fetcher/mod.rs
  • src/fetcher/quote_of_day.rs
  • src/fetcher/quote_of_day/data.txt
  • src/fetcher/quote_of_day/mod.rs
💤 Files with no reviewable changes (1)
  • src/fetcher/quote_of_day.rs

Comment thread src/fetcher/quote_of_day/data.txt Resolved
unhappychoice and others added 2 commits April 26, 2026 18:32
Windows checkouts via git autocrlf rewrite `\n` to `\r\n` in the bundled
`data.txt` files, so the `\n%\n` separator never matched and the entire
file collapsed to a single entry — failing the size-floor and rotation
tests on windows-latest CI runners.

Both parsers now `.replace("\r\n", "\n")` before splitting. Added
regression tests that parse the same fixture in both line-ending forms
and assert identical output.

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

quote_of_day had 5 exact-text duplicates (Emerson "destined to become",
Nietzsche "man of knowledge", Wilde "Be yourself", Picasso "Action is
the foundational", and "Knowing is not enough" attributed to both Goethe
and Bruce Lee) plus 3 near-dup variants (Henry Ford comma vs em-dash,
two phrasings of Mark Twain "Twenty years from now", and Steve Jobs's
reordered "Stay foolish, stay hungry").

fortune had 3 near-dup variants ("Today is the tomorrow you …" three
times, "early bird … second mouse" twice with one differing only by
inserted "may").

Removed in-place; both lists still well above the 365-entry floor
(quote_of_day 558, fortune 442). Added `*_list_has_no_duplicates`
regression tests so future expansions can't quietly reintroduce dupes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@unhappychoice
unhappychoice merged commit 6210589 into main Apr 26, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/fortune-fetcher branch April 26, 2026 09:44
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