feat(masters): phase-aware Vegas scroll, crisp countdown rendering, stale-date guard (v2.5.0)#105
Conversation
|
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 31 minutes and 9 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: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughUpdates masters-tournament metadata to v2.5.0 and makes Vegas rendering phase-aware: off-season/pre-tournament can return a countdown-only card; clamps parsed tournament end_date to the expected Sunday; and adds per-card sizing & dedicated countdown font to the renderer. Changes
Sequence DiagramsequenceDiagram
participant Manager as Manager<br/>(get_vegas_content)
participant Data as MastersData<br/>(_meta_dates / _parse_tournament_meta)
participant Phase as PhaseDetect<br/>(get_detailed_phase)
participant Renderer as MastersRenderer<br/>(render_countdown)
Manager->>Data: Request tournament meta dates
Data-->>Manager: Return meta_start/meta_end (end_date clamped)
Manager->>Phase: Determine detailed phase from dates
Phase-->>Manager: Return phase (off-season, pre-tournament, etc.)
alt Off-Season or Pre-Tournament
Manager->>Renderer: render_countdown(days,hours,minutes, card_width, card_height)
Renderer->>Renderer: Select font_countdown based on tier/height
Renderer->>Renderer: Compute layout using derived w/h
Renderer-->>Manager: Return countdown card
Manager-->>Client: Return single countdown card
else Practice/Tournament/Post-Tournament
Manager->>Renderer: render_leaderboard_cards() / render_hole_cards()
Renderer-->>Manager: Return multi-card composition
Manager-->>Client: Return leaderboard + hole cards (+ fun-facts)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
plugins/masters-tournament/manager.py (1)
710-715: Avoid reaching into_computed_fallback_metafrom outside the data source.
fetch_tournament_meta()already falls back to_computed_fallback_meta()when cache + live fetch both fail, so the two-stepmeta or _computed_fallback_meta()dance here duplicates that logic and leaks a private helper across module boundaries. A single call is clearer and keeps the data-source encapsulation intact:♻️ Suggested cleanup
- meta = self._tournament_meta or {} - target = meta.get("start_date") - if target is None: - target = self.data_source._computed_fallback_meta().get("start_date") + meta = self._tournament_meta or self.data_source.fetch_tournament_meta() or {} + target = meta.get("start_date") if not target: return None🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/masters-tournament/manager.py` around lines 710 - 715, This code reaches into data_source._computed_fallback_meta() and duplicates fallback logic; replace the meta resolution with a single call to fetch_tournament_meta() (or use self.fetch_tournament_meta() / the public data-source method that already applies cache+live+fallback) instead of inspecting self._tournament_meta or calling the private _computed_fallback_meta(), then extract target = meta.get("start_date") and return None if not target; remove any direct references to _computed_fallback_meta() to preserve encapsulation (keep references to self._tournament_meta only if fetch_tournament_meta() is unavailable but prefer the public fetch).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/masters-tournament/manager.py`:
- Around line 716-724: The countdown card is being resized with
Image.Resampling.LANCZOS which blurs bitmap/pixel fonts from render_countdown;
update the code so render_countdown can produce the card at the target size (add
optional card_width/card_height parameters to render_countdown and call it with
(cw,ch) matching render_player_card/render_hole_card), and if you cannot change
render_countdown immediately, change the resize call that currently uses
Image.Resampling.LANCZOS to use Image.Resampling.NEAREST so pixel glyphs remain
crisp when cw != self.display_width; ensure references include
calculate_tournament_countdown, render_countdown, cw, ch, and
Image.Resampling.NEAREST.
In `@plugins/masters-tournament/masters_renderer.py`:
- Around line 343-352: The countdown font selection currently picks
self.font_countdown via _load_font("xl"/"medium"/"small") purely on self.height,
which causes overflow on narrow tall panels; change the logic in the
font-selection block so it also considers horizontal budget (self.width or
self.tier) before choosing "xl" or "medium" — e.g., only pick "xl" when
self.height >= 20 AND self.width is wide enough (or tier != "small"), otherwise
fall back to the more compact self.font_score or a smaller _load_font size;
adjust references to font_countdown and ensure render_countdown uses that
smaller font to prevent overflow.
---
Nitpick comments:
In `@plugins/masters-tournament/manager.py`:
- Around line 710-715: This code reaches into
data_source._computed_fallback_meta() and duplicates fallback logic; replace the
meta resolution with a single call to fetch_tournament_meta() (or use
self.fetch_tournament_meta() / the public data-source method that already
applies cache+live+fallback) instead of inspecting self._tournament_meta or
calling the private _computed_fallback_meta(), then extract target =
meta.get("start_date") and return None if not target; remove any direct
references to _computed_fallback_meta() to preserve encapsulation (keep
references to self._tournament_meta only if fetch_tournament_meta() is
unavailable but prefer the public fetch).
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3eba7dc4-c310-4790-801d-00fef2a37b03
📒 Files selected for processing (6)
plugins.jsonplugins/masters-tournament/logo_loader.pyplugins/masters-tournament/manager.pyplugins/masters-tournament/manifest.jsonplugins/masters-tournament/masters_data.pyplugins/masters-tournament/masters_renderer.py
c38942d to
f34fd91
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/masters-tournament/manager.py`:
- Around line 689-691: The manifest/plugin version was increased only from
2.4.3→2.4.6 but this PR adds new phase-aware display functionality so you must
bump the MINOR version (not a patch); update the plugin manifest/version
constant to 2.5.0 (look for symbols like MANIFEST["version"], PLUGIN_VERSION, or
any VERSION constant in manager.py and the plugin manifest object) and ensure
any published metadata that references 2.4.x is updated to 2.5.0 so the release
reflects a new feature.
- Around line 710-716: get_vegas_content currently uses self._tournament_meta or
falls back to self.data_source._computed_fallback_meta() only when start_date is
None; change it to treat a start_date that is already past as stale and fall
back as well: retrieve meta via self._tournament_meta (or computed fallback),
parse the candidate start_date, call calculate_tournament_countdown(target) only
if the countdown indicates a non-zero future time (or if target > now),
otherwise reassign target =
self.data_source._computed_fallback_meta().get("start_date") and re-evaluate;
update the logic around variables meta, target and the call to
calculate_tournament_countdown to ensure stale/past start_date from cached
_tournament_meta does not produce an all-zero countdown.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dc193474-d30b-4516-bfe9-14fee467e8c5
📒 Files selected for processing (5)
plugins.jsonplugins/masters-tournament/manager.pyplugins/masters-tournament/manifest.jsonplugins/masters-tournament/masters_data.pyplugins/masters-tournament/masters_renderer.py
✅ Files skipped from review due to trivial changes (2)
- plugins.json
- plugins/masters-tournament/manifest.json
🚧 Files skipped from review as they are similar to previous changes (2)
- plugins/masters-tournament/masters_data.py
- plugins/masters-tournament/masters_renderer.py
| Content is phase-aware: | ||
| off-season / pre-tournament → countdown card only | ||
| practice / tournament / post → leaderboard + holes + fun facts |
There was a problem hiding this comment.
Use a minor version bump for the new phase-aware Vegas behavior.
This changes display functionality, but the PR summary says the manifest moved from 2.4.3 to 2.4.6. Please bump the plugin to the next minor version instead, e.g. 2.5.0, if this ships as new functionality. As per coding guidelines, “Bump MINOR version (1.x.0) for new features added, new config options (backward compatible), or new display modes/functionality”.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/masters-tournament/manager.py` around lines 689 - 691, The
manifest/plugin version was increased only from 2.4.3→2.4.6 but this PR adds new
phase-aware display functionality so you must bump the MINOR version (not a
patch); update the plugin manifest/version constant to 2.5.0 (look for symbols
like MANIFEST["version"], PLUGIN_VERSION, or any VERSION constant in manager.py
and the plugin manifest object) and ensure any published metadata that
references 2.4.x is updated to 2.5.0 so the release reflects a new feature.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
plugins/masters-tournament/manager.py (1)
710-721: Same stale-start_dateguard is missing in_display_countdown.The new guard here correctly falls back to
_computed_fallback_meta()when cachedstart_dateis in the past. However,_display_countdown(lines 648–667) still only falls back whenstart_dateis falsy — ifself._tournament_metaholds a completed tournament'sstart_date(truthy but stale),calculate_tournament_countdown()will return all zeros there too. Consider extracting a shared helper (e.g._resolve_countdown_target()) so both paths stay consistent.♻️ Suggested refactor
+ def _resolve_countdown_target(self): + """Return a future start_date for the countdown, falling back when + cached meta is missing or stale (past).""" + meta = self._tournament_meta or {} + target = meta.get("start_date") + if target is not None: + t_aware = target if target.tzinfo else target.replace(tzinfo=timezone.utc) + if t_aware <= datetime.now(timezone.utc): + target = None + if target is None: + target = self.data_source._computed_fallback_meta().get("start_date") + return targetThen reuse it in both
_display_countdownand the newget_vegas_contentbranch.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/masters-tournament/manager.py` around lines 710 - 721, Extract a single helper (e.g. _resolve_countdown_target) that encapsulates the stale start_date check currently in get_vegas_content: it should read self._tournament_meta.get("start_date"), if present make it timezone-aware (default UTC) and if <= datetime.now(timezone.utc) treat it as None, then fallback to self.data_source._computed_fallback_meta().get("start_date") and return the final target or None. Replace the direct start_date handling in _display_countdown (and the new branch in get_vegas_content) to call _resolve_countdown_target so both paths use the same logic before invoking calculate_tournament_countdown or returning None.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@plugins/masters-tournament/manager.py`:
- Around line 710-721: Extract a single helper (e.g. _resolve_countdown_target)
that encapsulates the stale start_date check currently in get_vegas_content: it
should read self._tournament_meta.get("start_date"), if present make it
timezone-aware (default UTC) and if <= datetime.now(timezone.utc) treat it as
None, then fallback to
self.data_source._computed_fallback_meta().get("start_date") and return the
final target or None. Replace the direct start_date handling in
_display_countdown (and the new branch in get_vegas_content) to call
_resolve_countdown_target so both paths use the same logic before invoking
calculate_tournament_countdown or returning None.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3d5b5a41-bd41-4203-95a2-8caf198218ea
📒 Files selected for processing (3)
plugins.jsonplugins/masters-tournament/manager.pyplugins/masters-tournament/manifest.json
✅ Files skipped from review due to trivial changes (2)
- plugins.json
- plugins/masters-tournament/manifest.json
|
@sarjent I'm a bit confused on this one. Claude says it's empty and changes have already been merged. It's got a conflict with the lacrosse PR I just merged but I am not sure if we need to resolve and re-merge or just ignore. Open to suggestions |
All sync'd. I was a bit behind on the branch. |
- get_vegas_content() now checks tournament phase: off-season and pre-tournament return a single countdown card only; practice/ tournament/post-tournament return the full leaderboard+holes+facts rotation. Fixes Vegas scroll always showing stale leaderboard data in off-season regardless of phase. - Cap ESPN endDate to start_date+3d in _parse_leaderboard_event so ESPN's extended post-tournament API window can never push end_date beyond Sunday, preventing annual stale-cache phase detection bugs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add font_countdown that always uses the largest font fitting the display height (xl=10px for height>=20, medium=8px for height>=14, else small). Bypasses the wide-short override that was reducing font_score to 6px on 192x32 and similar panels, making the countdown number very small. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…v2.4.6) Add card_width/card_height params to render_countdown so Vegas scroll draws the card at the target size directly instead of LANCZOS-scaling a full-panel render (which blurs pixel fonts). Also gate font_countdown xl selection on tier=="large" so narrow-tall panels (e.g. 32x64, 64x64) don't overflow with the 10px PressStart2P countdown string. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
….5.0 Bump MINOR version to 2.5.0: phase-aware Vegas scroll is new user-visible functionality (off-season/pre-tournament show countdown only; active phases show leaderboard+holes+fun facts), not a bug fix. Also guard against stale cached start_date in get_vegas_content: if _tournament_meta holds a past start_date (e.g. prior year cached value), treat it as missing and fall back to _computed_fallback_meta() so the countdown never shows all-zero from an expired date. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
df91c7b to
d351b79
Compare
Summary
get_vegas_content()previously rendered the full leaderboard and course cards regardless of tournament phase. Off-season and pre-tournament now show a countdown card only; practice/tournament/post-tournament show the full leaderboard + hole + fun-fact strip.render_countdown()now accepts optionalcard_width/card_heightparams (matchingrender_player_card/render_hole_card), so Vegas scroll draws the card at the target dimensions directly instead of post-scaling a full-panel render with LANCZOS (which blurred pixel fonts).font_countdownso the countdown number uses a large font independently of the compact leaderboard font override applied on wide-short panels like 192×32.font_countdownnow gates "xl" (10px PressStart2P) ontier == "large"(width > 64). Narrow-tall panels (e.g. 32×64, 64×64) previously selected xl and overflowed on long strings like "364d 12h"; they now get "medium" (8px).endDatecap — ESPN keeps the Masters event active post-tournament and extendsendDatewell past Sunday, causing the plugin to stay in tournament phase and never transition to countdown. Fixed by capping parsedendDatetostart_date + 3 days 23:59:59in_parse_leaderboard_event(), preventing an annual stale-cache bug.PHASE_MODES["off-season"]now listsmasters_countdown3× (out of 10 entries) so it gets ~30% of screen time during the off-season rotation._computed_fallback_meta()microseconds — Fixedthu_midnight_edtto zero microseconds to avoid sub-second drift in phase boundary calculations.×(U+00D7) withxin an inline comment to satisfy RUF003 linter.except—get_player_headshot()download path now catches only(requests.exceptions.RequestException, UnidentifiedImageError, OSError)instead of bareException.Files changed
manager.pyget_vegas_content(), countdown called withcard_width/card_height, off-season countdown weightingmasters_renderer.pyrender_countdown()card_width/card_heightparams,font_countdownwith tier+height guardmasters_data.pyendDatecap,_computed_fallback_meta()microsecond fixmasters_helpers.pylogo_loader.pyexceptin headshot downloadmanifest.jsonTest plan
endDatecap prevents stale phase after tournament Sunday🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Chores