Skip to content

Commit

Permalink
fixed ff_rosters() franchise_id for sleeper (#436)
Browse files Browse the repository at this point in the history
* fix for #435

- replaced roster_id with owner_id from sleeper api

* revert sleeper_rosters()

* added new column to sleeper_userleagues() with roster_id

* updated version number and changelog
  • Loading branch information
jak3sch authored Sep 9, 2024
1 parent 60b57fd commit 72cba2d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: ffscrapr
Title: API Client for Fantasy Football League Platforms
Version: 1.4.8.18
Version: 1.4.8.19
Authors@R:
c(person(given = "Tan",
family = "Ho",
Expand Down Expand Up @@ -57,5 +57,5 @@ LazyData: true
VignetteBuilder:
knitr
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ row per player-team-season (v1.4.8.13) (thanks @john-b-edwards!)
- Bugfix espn `ff_starters()` to return less than or equal to max week (v1.4.8.16)
- [BREAKING] `mfl_players()` and `sleeper_players()` outputs now try to return
more standardized column types (v1.4.8.17)
- `sleeper_userleagues()` output has a new column roster_id which is the same ID as franchise_id in `sleeper_rosters()` (1.4.8.19) (#436)

# ffscrapr 1.4.8

Expand Down
17 changes: 16 additions & 1 deletion R/sleeper_userleagues.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ ff_userleagues.sleeper_conn <- function(conn = NULL, user_name = NULL, season =
dplyr::mutate(
league_id = as.character(league_id),
franchise_name = purrr::map_chr(.data$league_id, .sleeper_userteams, user_id),
franchise_id = user_id
franchise_id = user_id,
roster_id = purrr::map_int(.data$league_id, .sleeper_rosterid, user_id)
)

return(df_leagues)
Expand Down Expand Up @@ -75,3 +76,17 @@ sleeper_userleagues <- function(user_name, season = NULL) {

return(df_teams)
}

#' Get Roster ID
#' @noRd

.sleeper_rosterid <- function(league_id, user_id) {
df_teams <- sleeper_getendpoint(glue::glue("league/{league_id}/rosters")) %>%
purrr::pluck("content") %>%
tibble::tibble() %>%
tidyr::hoist(1, "owner_id", "roster_id") %>%
dplyr::filter(.data$owner_id == user_id) %>%
dplyr::pull("roster_id")

return(df_teams)
}

0 comments on commit 72cba2d

Please sign in to comment.