Skip to content

Commit

Permalink
filter out empty drafts from sleeper ff_draft
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSydlowski committed Jan 3, 2024
1 parent a9430cb commit bc68a6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/sleeper_draft.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ ff_draft.sleeper_conn <- function(conn, ...) {
}

.sleeper_currentdraft <- function(draft_id) {
picks <- glue::glue("draft/{draft_id}/picks") %>%
picks_content <- glue::glue("draft/{draft_id}/picks") %>%
sleeper_getendpoint() %>%
purrr::pluck("content") %>%
purrr::pluck("content")

# Check length of picks_content object to filter out empty drafts
if(length(picks_content) == 0) return(data.frame(franchise_id = integer(),
player_id = character()))

picks <-
picks_content %>%
tibble::tibble() %>%
tidyr::hoist(1, "round","pick_no", "draft_slot", "roster_id", "player_id", "metadata") %>%
tidyr::hoist("metadata", "auction_amount" = "amount") %>%
Expand Down

0 comments on commit bc68a6a

Please sign in to comment.