Skip to content

fix(ufc): throttle has_live_content(), which logged once per display frame - #474

Merged
ChuckBuilds merged 1 commit into
mainfrom
fix/ufc-live-content-throttle
Sep 10, 2026
Merged

fix(ufc): throttle has_live_content(), which logged once per display frame#474
ChuckBuilds merged 1 commit into
mainfrom
fix/ufc-live-content-throttle

Conversation

@ChuckBuilds

Copy link
Copy Markdown
Owner

The bug

has_live_content() is called from the display path — once per frame in Vegas mode. UFC throttled only the False branch:

self.logger.info(                       # ← no guard, inside `if live_games:`
    f"has_live_content: UFC live_games={len(live_games)}, "
    f"ufc_live={ufc_live}")
...
should_log = ufc_live or (current_time - self._last_live_content_false_log >= interval)
if should_log and not ufc_live:         # ← guards the False path only
    self.logger.info("has_live_content() returning False")

Whenever a card was live, that first call fired on every frame — roughly 50 lines/second on a rig measured at 50 fps.

Why it survived every previous fix

It sits outside the should_log guard. baseball 1.20.4, football, and #308 (hockey/basketball/lacrosse) all inspected the guard rather than the whole function body, so none of them saw it. It has been there since the plugin landed in #24 (2026-02-13).

Audited state across the lineage before this change:

plugin INFO in has_live_content throttled
baseball, football 1 yes (full)
basketball, hockey, lacrosse 1 yes (partial)
afl, cricket, nrl, soccer 0 n/a
ufc 2 False branch only

The fix

Both branches now share one throttle in baseball-scoreboard's shape — log on state change, re-log an unchanged answer once per 60s so a steady state stays visible.

Testing

  • test_live_content_log_throttle.py, ported from baseball's, plus a case for the exact state that triggered this: a live card with favorites configured and none of them fighting, so ufc_live is False while live_games is not empty. Verified it fails against the pre-fix manager.
  • scripts/check_plugin.py --plugin ufc-scoreboard: 24/24 PASS across all 8 panel sizes.

🤖 Generated with Claude Code

https://claude.ai/code/session_014RRtqXDCnvnY6EQwhT5CV9

…frame

has_live_content() runs on the display path -- once per *frame* in Vegas mode.
UFC guarded only the False branch: `should_log and not ufc_live` sat at the
bottom of the function, but a second INFO line lived inside the `if live_games:`
block above it with no guard at all. Whenever a card was live that call fired on
every frame, roughly 50 lines a second on a rig measured at 50 fps.

Because it sat outside the guard, every earlier throttle fix missed it --
baseball 1.20.4, football, and #308 for hockey/basketball/lacrosse all inspected
the guard rather than the whole function body. It has been there since the
plugin landed in #24.

Both branches now share one throttle in baseball-scoreboard's shape: log when
the answer changes, and re-log an unchanged answer once per 60s so a steady
state stays visible.

test_live_content_log_throttle.py is ported from baseball's, plus a case for the
exact state that triggered it -- a live card with favorites configured and none
of them fighting, where ufc_live is False but live_games is not empty.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014RRtqXDCnvnY6EQwhT5CV9
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: cd2e72ee-aff5-4612-bcce-daec7d477a15


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.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 17 complexity

Metric Results
Complexity 17

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@ChuckBuilds
ChuckBuilds merged commit 37cd61b into main Sep 10, 2026
4 checks passed
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.

2 participants