Add dual-league main front-end dispatch for NHL and PWHL workflows#40
Merged
Conversation
Closed
Agent-Logs-Url: https://github.com/pbulsink/HockeyModel/sessions/65a0db38-55c0-4c4e-98ef-144d0b648673 Co-authored-by: pbulsink <5419974+pbulsink@users.noreply.github.com>
Agent-Logs-Url: https://github.com/pbulsink/HockeyModel/sessions/65a0db38-55c0-4c4e-98ef-144d0b648673 Co-authored-by: pbulsink <5419974+pbulsink@users.noreply.github.com>
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
pbulsink
approved these changes
May 4, 2026
Contributor
There was a problem hiding this comment.
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(), anddailySummary(). - 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::pwhlTeamColoursfixes division lookup, but the facet levels are still hard-coded to the four NHL divisions. PWHL teams all haveDivision == "PWHL", so this coerces every facet value toNAand 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
DivisionintoNA, 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.
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>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/pbulsink/HockeyModel/sessions/dbc8fa58-d03f-448b-b791-254973ef0795 Co-authored-by: pbulsink <5419974+pbulsink@users.noreply.github.com>
Agent-Logs-Url: https://github.com/pbulsink/HockeyModel/sessions/ff7f7bb3-d413-4f03-ad4e-30110ea00223 Co-authored-by: pbulsink <5419974+pbulsink@users.noreply.github.com>
pbulsink
requested changes
May 5, 2026
Agent-Logs-Url: https://github.com/pbulsink/HockeyModel/sessions/8b7ab2be-5398-4ea7-aa78-4e30f1766937 Co-authored-by: pbulsink <5419974+pbulsink@users.noreply.github.com>
pbulsink
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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
Add shared prediction support for PWHL
updatePredictions()now writes PWHL prediction snapshots under a dedicatedpwhl/subdirectory.Harden prediction-history loading
pwhl/subdirectory.Make shared plotting wrappers work cleanly for PWHL
Document the dual-league API surface
Example: