Skip to content

[codex] Fix later-round scorecard generation#120

Merged
jonatanklosko merged 2 commits into
jonatanklosko:masterfrom
coder13:codex/fix-round-2-scorecards
May 3, 2026
Merged

[codex] Fix later-round scorecard generation#120
jonatanklosko merged 2 commits into
jonatanklosko:masterfrom
coder13:codex/fix-round-2-scorecards

Conversation

@coder13

@coder13 coder13 commented May 2, 2026

Copy link
Copy Markdown
Contributor

What changed

This PR was generated entirely by AI assistance.

It fixes later-round scorecard generation when a round already has competitor assignments but the WCIF does not yet have populated result scaffolding for that round.

The functional changes are:

  • treat later rounds with existing assignments but empty results arrays as needing scorecards
  • generate later-round scorecards from actual persons[].assignments when those assignments exist, instead of falling back to blank nameless cards
  • add regression tests covering assigned later rounds with empty results

Why these code changes were needed

src/logic/activities.js

roundsMissingScorecards() now evaluates all rounds through a small helper instead of relying on roundsMissingResults().

I made that change because roundsMissingResults() was too narrow for this case. A later round can already have assignments and still have an empty results array. In that state, we still want the round to show up as scorecard-ready.

The new helper keeps the rule explicit:

  • first rounds with no results still need scorecards
  • later rounds with no results also need scorecards if they already have group assignments
  • rounds with result rows but no attempts still need scorecards as before

src/logic/documents/scorecards.js

groupActivitiesWithCompetitors() now builds the group list before deciding whether it can derive competitors from results.

I made that change because the old flow only had one source of truth for later rounds: competitorsForRound(). That works when the WCIF already has the expected round/result scaffolding, but it fails when assignments exist before those result rows are populated.

The new flow adds a second path:

  • gather the round's group activities first
  • look directly at wcif.persons[].assignments for competitor assignments in each group
  • if assignments exist, use them to build scorecards
  • if assignments do not exist, keep the previous fallback behavior that generates nameless placeholder scorecards

That is why the diff in scorecards.js is larger than a simple condition change. This fix needed a real assignment-based path, not just a different boolean.

The direct assignment path also sorts competitors in a stable order. It prefers known round ordering when available, then station number, then name. I added that so printing stays consistent and readable even when round rankings are not available yet.

scorecards() is now exported so the regression test can exercise the actual scorecard-generation path directly.

Impact

  • assigned later rounds show up as scorecard-ready
  • scorecards for those rounds include competitor names and stations when assignments are present
  • rounds with no known competitor assignments still fall back to nameless placeholder scorecards as before

Validation

  • yarn test --watch=false --runInBand src/logic/tests/activities.test.js src/logic/tests/scorecards.test.js src/logic/tests/competitors.test.js src/components/App/App.test.js src/components/Header/Header.test.js src/components/CompetitionList/CompetitionList.test.js src/logic/tests/formatters.test.js

@coder13 coder13 changed the title [codex] Fix later-round scorecards and local dev startup [codex] Fix later-round scorecard generation May 2, 2026
@coder13 coder13 marked this pull request as ready for review May 2, 2026 15:50
@jonatanklosko jonatanklosko merged commit bd9af49 into jonatanklosko:master May 3, 2026
5 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