Skip to content

Add dual-league main front-end dispatch for NHL and PWHL workflows#40

Merged
pbulsink merged 11 commits into
masterfrom
copilot/update-main-r-for-pwhl-support
May 5, 2026
Merged

Add dual-league main front-end dispatch for NHL and PWHL workflows#40
pbulsink merged 11 commits into
masterfrom
copilot/update-main-r-for-pwhl-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

The main front-end entry points only orchestrated NHL workflows, while PWHL had separate, parallel functionality. This change makes the package front-end league-aware so one call can run NHL, PWHL, or both consistently.

  • Unify front-end orchestration

    • Added league dispatch to the main exported entry points:
      • updateModel()
      • updatePredictions()
      • todayOddsPlot()
      • playoffOdds()
      • presidentOdds()
      • pointPredict()
      • ratings()
      • dailySummary()
    • league = NULL, NA, or "both" now runs both leagues.
    • "nhl" and "pwhl" run a single league without changing the existing NHL-specific workflows underneath.
  • Preserve current NHL behavior while exposing PWHL through the same interface

    • Split existing NHL logic into internal NHL-specific helpers, then routed the exported functions through a small league resolver.
    • Reused existing PWHL update/summary implementations instead of duplicating orchestration logic.
  • Add shared prediction support for PWHL

    • updatePredictions() now writes PWHL prediction snapshots under a dedicated pwhl/ subdirectory.
    • PWHL snapshots are shaped so the existing shared prediction plot wrappers can render playoff, first-place, and points views through the same exported front-end functions.
  • Harden prediction-history loading

    • Updated prediction readers to ignore non-date entries in prediction directories.
    • This avoids breaking NHL history reads once the root prediction directory contains a pwhl/ subdirectory.
  • Make shared plotting wrappers work cleanly for PWHL

    • Updated shared graphics code to respect the supplied team metadata when deriving divisions and short codes.
    • This allows the existing plot wrappers to render PWHL prediction history correctly without separate plot implementations.
  • Document the dual-league API surface

    • Updated roxygen/man pages and NEWS for the new league-aware front-end behavior.

Example:

# Run both leagues in one call
updateModel(league = "both")
dailySummary(league = NA)

# Run a single league
todayOddsPlot(league = "pwhl")
playoffOdds(league = "nhl")

# Build both league plots from one entry point
ratings()

Copilot AI linked an issue May 1, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 1, 2026 02:06
Copilot AI changed the title [WIP] Refactor main.R to include PWHL options and functions Add dual-league main front-end dispatch for NHL and PWHL workflows May 1, 2026
Copilot AI requested a review from pbulsink May 1, 2026 02:08
@pbulsink pbulsink marked this pull request as ready for review May 4, 2026 01:48
Copilot AI review requested due to automatic review settings May 4, 2026 01:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the package’s high-level front-end functions league-aware so the same exported entry points can orchestrate NHL, PWHL, or both workflows. It fits into the broader codebase by reusing the existing NHL and PWHL back-end implementations while exposing a unified public interface.

Changes:

  • Added shared league dispatch to main exported entry points like updateModel(), updatePredictions(), todayOddsPlot(), ratings(), and dailySummary().
  • Added PWHL prediction snapshot support and shared history-plot wrappers so playoff/first-place/points plots can reuse existing graphics code.
  • Updated prediction-history readers and documentation/tests to support the new dual-league front-end behavior.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
R/main.R Adds league resolution, front-end dispatch helpers, PWHL prediction writing, and dual-league wrappers for exported functions.
R/graphics.R Updates shared prediction-history plots to use supplied team metadata and hardens prediction directory scanning.
R/league.R Makes prediction-history loaders ignore non-date directory entries.
tests/testthat/test-main.R Adds new front-end dispatch and PWHL snapshot unit tests.
tests/testthat/test-graphics.R Updates existing graphics test to force NHL-only path.
tests/testthat/test-graphics-comprehensive.R Updates comprehensive graphics test to force NHL-only path.
man/updatePredictions.Rd Documents new league parameter for prediction updates.
man/updateModel.Rd Documents new dual-league updateModel() interface and return shape.
man/todayOddsPlot.Rd Documents new league parameter and multi-league return shape.
man/ratings.Rd Documents league-aware ratings wrapper and return shape.
man/presidentOdds.Rd Documents new parameters for president-odds wrapper.
man/pointPredict.Rd Documents new parameters for points wrapper.
man/playoffOdds.Rd Documents new parameters for playoff-odds wrapper.
man/dot-update_predictions_pwhl.Rd Generated docs for internal PWHL prediction snapshot helper.
man/dot-update_predictions_nhl.Rd Generated docs for internal NHL prediction snapshot helper.
man/dot-update_model_nhl.Rd Generated docs for internal NHL model payload helper.
man/dot-today_odds_plot_pwhl.Rd Generated docs for internal PWHL today-odds plot helper.
man/dot-today_odds_plot_nhl.Rd Generated docs for internal NHL today-odds plot helper.
man/dot-simplify_frontend_result.Rd Generated docs for result simplification helper.
man/dot-resolve_frontend_leagues.Rd Generated docs for league selector normalization helper.
man/dot-ratings_pwhl.Rd Generated docs for internal PWHL ratings helper.
man/dot-ratings_nhl.Rd Generated docs for internal NHL ratings helper.
man/dot-pwhl_prediction_summary.Rd Generated docs for converting PWHL sims into saved snapshots.
man/dot-president_odds_pwhl.Rd Generated docs for internal PWHL first-place plot helper.
man/dot-president_odds_nhl.Rd Generated docs for internal NHL first-place plot helper.
man/dot-point_predict_pwhl.Rd Generated docs for internal PWHL points plot helper.
man/dot-point_predict_nhl.Rd Generated docs for internal NHL points plot helper.
man/dot-playoff_odds_pwhl.Rd Generated docs for internal PWHL playoff plot helper.
man/dot-playoff_odds_nhl.Rd Generated docs for internal NHL playoff plot helper.
man/dot-league_predictions.Rd Generated docs for per-league prediction-history loader.
man/dot-frontend_value_for_league.Rd Generated docs for helper selecting league-specific inputs.
man/dot-frontend_prediction_dirs.Rd Generated docs for helper computing NHL/PWHL prediction directories.
man/dot-daily_summary_nhl.Rd Generated docs for internal NHL daily summary helper.
man/dailySummary.Rd Documents new league-aware daily summary entry point.
NEWS.md Announces the new dual-league front-end API behavior.
Comments suppressed due to low confidence (2)

R/graphics.R:45

  • Passing teamColours = HockeyModel::pwhlTeamColours fixes division lookup, but the facet levels are still hard-coded to the four NHL divisions. PWHL teams all have Division == "PWHL", so this coerces every facet value to NA and the shared points-history plot no longer labels/groups the PWHL data correctly.
  all_predictions$Division <- getTeamDivisions(
    all_predictions$Team,
    teamColours = teamColours
  )
  # Set divisions to logical order
  all_predictions$facet <- factor(
    x = all_predictions$Division,
    levels = c("Pacific", "Central", "Metropolitan", "Atlantic")

R/graphics.R:145

  • The playoff-history wrapper now passes PWHL team metadata, but the facet ordering is still limited to NHL division names. For PWHL predictions this turns every Division into NA, so the new shared PWHL playoff plot loses its intended grouping/labeling.
  all_predictions$Division <- getTeamDivisions(
    all_predictions$Team,
    teamColours = teamColours
  )
  # Set divisions to logical order
  all_predictions$facet <- factor(
    x = all_predictions$Division,
    levels = c("Pacific", "Central", "Metropolitan", "Atlantic")
  )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread man/pointPredict.Rd Outdated
Comment thread R/main.R Outdated
Comment thread R/main.R Outdated
Comment thread R/graphics.R
Comment thread man/playoffOdds.Rd Outdated
Comment thread man/presidentOdds.Rd Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
pbulsink and others added 2 commits May 4, 2026 05:58
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@pbulsink pbulsink marked this pull request as draft May 4, 2026 09:58
Agent-Logs-Url: https://github.com/pbulsink/HockeyModel/sessions/ff7f7bb3-d413-4f03-ad4e-30110ea00223

Co-authored-by: pbulsink <5419974+pbulsink@users.noreply.github.com>
Comment thread R/main.R Outdated
Copilot AI requested a review from pbulsink May 5, 2026 00:22
@pbulsink pbulsink marked this pull request as ready for review May 5, 2026 01:39
@pbulsink pbulsink merged commit 898684a into master May 5, 2026
8 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.

PWHL Posting Code

3 participants