From a4478d095398ed64163677b04f9e200e75b4e672 Mon Sep 17 00:00:00 2001 From: Jakob Eschler Date: Sat, 21 Sep 2024 00:03:52 +0200 Subject: [PATCH 1/3] added transaction type WAIVER to mfl_transaction() --- R/mfl_transactions.R | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/R/mfl_transactions.R b/R/mfl_transactions.R index d61d07d5..a9c7b969 100644 --- a/R/mfl_transactions.R +++ b/R/mfl_transactions.R @@ -37,7 +37,8 @@ ff_transactions.mfl_conn <- function(conn, transaction_type = "*", ...) { injured_reserve = .mfl_transactions_injuredreserve, taxi_squad = .mfl_transactions_taxisquad, bbid_waiver = .mfl_transactions_bbid_waiver, - trade = .mfl_transactions_trade + trade = .mfl_transactions_trade, + fcfs_waiver = .mfl_transactions_fcfs_waiver ) players_endpoint <- mfl_players(conn) %>% @@ -274,8 +275,39 @@ ff_transactions.mfl_conn <- function(conn, transaction_type = "*", ...) { dplyr::arrange(dplyr::desc(.data$timestamp)) } +## WAIVER - FCFS ## +# Create a tibble where each waiver fcfs transaction is represented on one line +#' @noRd +#' @keywords internal + +.mfl_transactions_fcfs_waiver <- function(df_transactions) { + fcfs_transactions <- df_transactions %>% + dplyr::filter(.data$type == "WAIVER") + + if (nrow(fcfs_transactions) == 0) { + return(NULL) + } + + parsed_fcfs <- fcfs_transactions %>% + dplyr::select("timestamp", "type", "dropped", "added", "franchise", "comments") %>% + dplyr::mutate_at(c("added", "dropped"), ~ stringr::str_replace(.x, ",$", "")) %>% + tidyr::pivot_longer(c("added", "dropped"), names_to = "type_desc", values_to = "player_id") %>% + tidyr::separate_rows("player_id", sep = ",") %>% + dplyr::filter(.data$player_id != "") + + parsed_fcfs %>% + dplyr::select( + "timestamp", + "type", + "franchise", + "type_desc", + "player_id", + "comments" + ) %>% + dplyr::arrange(dplyr::desc(.data$timestamp)) +} + ## Will need to write functions to parse each of these, then row bind them back together afterwards. -# WAIVER - FCFS # BBID_AUTO_PROCESS_WAIVERS # WAIVER_REQUEST # BBID_WAIVER_REQUEST From 818776748d27d7d9c74748a1790d246f7740b04f Mon Sep 17 00:00:00 2001 From: Jakob Eschler Date: Sat, 21 Sep 2024 00:09:11 +0200 Subject: [PATCH 2/3] version bumb & changelogg addition --- DESCRIPTION | 2 +- NEWS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7b6f98ad..5bb6f8c0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: ffscrapr Title: API Client for Fantasy Football League Platforms -Version: 1.4.8.19 +Version: 1.4.8.20 Authors@R: c(person(given = "Tan", family = "Ho", diff --git a/NEWS.md b/NEWS.md index 4b6a9844..6f4e962f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -30,6 +30,7 @@ row per player-team-season (v1.4.8.13) (thanks @john-b-edwards!) - [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) +- `mfl_transactions()` now processes `transaction_type = "WAIVER"` (1.4.8.20) (#438) # ffscrapr 1.4.8 From 55da72d83b0c17e26c1dfdd83bc7e47d03e7a361 Mon Sep 17 00:00:00 2001 From: tanho63 Date: Wed, 9 Oct 2024 15:40:16 +0000 Subject: [PATCH 3/3] Document --- man/dp_clean_names.Rd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/man/dp_clean_names.Rd b/man/dp_clean_names.Rd index 909524a7..2e6dbae1 100644 --- a/man/dp_clean_names.Rd +++ b/man/dp_clean_names.Rd @@ -17,6 +17,8 @@ dp_cleannames(...) \item{\code{lowercase}}{defaults to FALSE - if TRUE, converts to lowercase} \item{\code{convert_lastfirst}}{defaults to TRUE - converts names from "Last, First" to "First Last"} \item{\code{use_name_database}}{uses internal name database to do common substitutions (Mitchell Trubisky to Mitch Trubisky etc)} + \item{\code{convert_to_ascii}}{If \code{TRUE}, will transliterate to latin-ascii via the +stringi package. Defaults to \code{TRUE} if the stringi package is installed.} }} } \value{