Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

espn_mbb_scoreboard() only returns spring games #150

Open
markjrieke opened this issue Oct 17, 2024 · 0 comments
Open

espn_mbb_scoreboard() only returns spring games #150

markjrieke opened this issue Oct 17, 2024 · 0 comments

Comments

@markjrieke
Copy link

Found a couple bugs with espn_mbb_scoreboard():

  • Passing in a season number only returns scoreboard for spring games (1/1/{season} onwards)
  • You can return fall games by passing in a specific date (e.g., `"20231108"), but this fails for the 2002 season
# only returns data for Jan 1 of the calendar year onwards
season_scores <- hoopR::espn_mbb_scoreboard(2024)
min(season_scores$game_date)
#> [1] "2024-01-01"
# can get fall games by passing in specific dates as a string
day_scores <- hoopR::espn_mbb_scoreboard("20231108")
unique(day_scores$game_date)
#> [1] "2023-11-08"
# this workaround errors out for the 2002 season!
day_scores_2002 <- hoopR::espn_mbb_scoreboard("20011108")
#> Error in max_year + 1: non-numeric argument to binary operator

Created on 2024-10-17 with reprex v2.1.0

In the function internals, this causes the issue:

  • max_year is cast to a character
  • Can't add an integer to a string!
max_year <- substr(Sys.Date(), 1, 4)
    if (!(as.integer(substr(season, 1, 4)) > 2001)) {
        message(paste("Error: Season must be between 2001 and", 
            max_year + 1))
    }

I'm not sure if my workaround of passing in a specific day as a string is expected user behavior. If it is, I can fork / fix the 2002 season issue directly. If not, it may be beneficial to enforce that season is an integer between 2002/current season as well as fixing the spring-only return. I suspect that the same behavior is also present in the wehoop package.

I have a local workaround to the workaround in the meantime --- thanks for the package in general, this is great!

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

No branches or pull requests

1 participant