sportsdataverse / cfbfastR

An R package to quickly obtain clean and tidy college football play by play data
https://cfbfastR.sportsdataverse.org
Other
72 stars 8 forks source link

```cfbd_team_info``` has ```year``` as parameter but real CFBD API endpoint does not #97

Open avkrishnamurthy opened 6 months ago

avkrishnamurthy commented 6 months ago

The cfbd_team_info function in cfbd_teams.R receives conference, only_fbs, and year as arguments. However, only conference and only_fbs work. year is not a query parameter according to CFBDATA. As such, this ends up not doing anything when trying to filter for different years. This can be misleading and does not actually have any functionality.

To Reproduce Call cfbfastR::cfbd_team_info(year=2019) and cfbfastR::cfbd_team_info(year=2023) and view results. They will be the same.

Expected behavior The call with year=2019 should give a list of teams that are active in 2019, and the call with year=2023 should give a list of teams that are active in 2023.

Screenshots

Screenshot 2024-01-27 at 3 54 42 PM Screenshot 2024-01-27 at 3 54 27 PM

The first screenshot shows the swaggerUI docs for the CFBDATA API. As seen, there is no query parameter for year, only conference.

The second screenshot shows the source code for the teams endpoint in the cfbdata codebase. There is no filter for year, only for conference. This can be seen here https://github.com/CFBD/cfb-api/blob/main/app/team/team.controller.js

Kazink36 commented 6 months ago

I'm not able to reproduce your error. cfbfastR::cfbd_team_info(year=2019) returns a 130 row dataframe and cfbfastR::cfbd_team_info(year=2023) returns a 133 row dataframe with new rows for Jacksonville State, James Madison, and Sam Houston State, who all made the move to fbs in that time frame.

The cfbd_team_info function access both the /teams endpoint AND the /teams/fbs endpoint depending on the only_fbs parameter. only_fbs defaults to TRUE which points to the teams/fbs endpoint, which does take the year parameter. I tested with cfbfastR::cfbd_team_info(year=2010, only_fbs = TRUE) which returns a 120 row dataframe with info like Utah being in the Mountain West and Arizona State being in the Pac-10. cfbfastR::cfbd_team_info(year=2010, only_fbs = TRUE) returns a 1818 row dataframe with all teams in the database in their current conference, not where they were in 2010

avkrishnamurthy commented 6 months ago

Sorry, I mistakenly wrote the wrong function call. I called cfbfastR::cfbd_team_info(only_fbs=FALSE, year=2019) and cfbfastR::cfbd_team_info(only_fbs=FALSE, year=2023). I believe that when only_fbs=FALSE, the year argument does nothing. I did not test with only_fbs=TRUE, so based on what you are saying I think it must be working for that case. As you mentioned though, when calling with only_fbs=TRUE, it only returns information as if it were the current year (like Cincinnati in the Big 12). I'm not sure if this is the intended behavior or not but it misled me when I was trying to use it.

Regardless, I'm not sure what can be done from a cfbfastR perspective, as it seems the /teams endpoint does not support the year parameter. Maybe it could be explicitly stated in the docs that the year argument is only supported with only_fbs=TRUE