Repository navigation
feat(fetcher): add fortune cookie fetcher + expand quote_of_day to 567 entries - #157
Conversation
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]>
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces a new Changes
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
src/fetcher/fortune/data.txtsrc/fetcher/fortune/mod.rssrc/fetcher/mod.rssrc/fetcher/quote_of_day.rssrc/fetcher/quote_of_day/data.txtsrc/fetcher/quote_of_day/mod.rs
💤 Files with no reviewable changes (1)
- src/fetcher/quote_of_day.rs
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]>
Summary
fortunefetcher — 445 classic Unix-style fortune cookies (one-liners, programmer humor, fortune-cookie wisdom, a few short verses). Realtime / Safe / zero-config;TextBlockdefault +Textshape.quote_of_dayrefactored tomod.rs + data.txt, expanded from 50 → 567 entries.day_of_year % Ntoepoch_days % Nfor 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_daywould surface the same line ~7 times a year; 365+ entries plus epoch-days indexing eliminate within-year and year-over-year repeats.Ticks the
fortunecheckbox in #67.fortunereferencetext_block,texttext_blockanimated_boot,animated_postfx,animated_scanlines,animated_splitflap,animated_wave,list_plain,text_plaintextanimated_boot,animated_figlet_morph,animated_postfx,animated_scanlines,animated_splitflap,animated_typewriter,animated_wave,text_ascii,text_plainquote_of_day(refactor) referenceShape 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 -- --checkcargo clippy --all-targets -- -D warningscargo test(781 passed, 0 failed)cargo run --bin splashboardwith both shapes for both fetchers*_list_meets_size_floortests)pick_drifts_year_over_yeartest asserts the new index function actually drifts🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Refactor