Skip to content

Commit

Permalink
Add scoringPeriodId argument to some functions
Browse files Browse the repository at this point in the history
Close #32
  • Loading branch information
k5cents committed Oct 15, 2021
1 parent 46e8217 commit ff4ed25
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
4 changes: 3 additions & 1 deletion R/activity.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
#' @examples
#' recent_activity(leagueId = "42654852", scoringPeriodId = 2)
#' @export
recent_activity <- function(leagueId = ffl_id(), leagueHistory = FALSE, ...) {
recent_activity <- function(leagueId = ffl_id(), leagueHistory = FALSE,
scoringPeriodId = NULL, ...) {
dat <- ffl_api(
leagueId = leagueId,
leagueHistory = leagueHistory,
view = c("mTransactions2", "mTeam"),
scoringPeriodId = scoringPeriodId,
...
)
tm <- out_team(dat$teams, trim = TRUE)
Expand Down
11 changes: 6 additions & 5 deletions R/best.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
#' Uses the roster settings for each league to find the best possible
#' combinations of players to score the most fantasy points.
#'
#' If `scoringPeriodId` is the current week (the default), then actual scoring
#' might be incomplete (see `projectedScore` argument).
#'
#' @inheritParams ffl_api
#' @param scoringPeriodId The scoring period for which rosters will be
#' optimized. If `scoringPeriodId` is the current week (the default), then
#' actual scoring might be incomplete (see `projectedScore` below).
#' @param useScore One of "projectedScore" or "actualScore" (default).
#' @examples
#' best_roster(leagueId = "42654852", scoringPeriodId = 1)
#' @return A dataframe (or list) with optimal rosters.
#' @export
best_roster <- function(leagueId = ffl_id(), scoringPeriodId = ffl_week(),
useScore = c("actualScore", "projectedScore"), ...) {
best_roster <- function(leagueId = ffl_id(),
useScore = c("actualScore", "projectedScore"),
scoringPeriodId = NULL, ...) {
useScore <- match.arg(useScore, c("actualScore", "projectedScore"))
dat <- ffl_api(
leagueId = leagueId,
Expand Down
4 changes: 3 additions & 1 deletion R/roster.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
#' team_roster(leagueId = "42654852", scoringPeriodId = 1)
#' @return A dataframe (or list) with league teams.
#' @export
team_roster <- function(leagueId = ffl_id(), leagueHistory = FALSE, ...) {
team_roster <- function(leagueId = ffl_id(), leagueHistory = FALSE,
scoringPeriodId = NULL, ...) {
dat <- ffl_api(
leagueId = leagueId,
leagueHistory = leagueHistory,
view = c("mRoster", "mTeam"),
scoringPeriodId = scoringPeriodId,
...
)
if (leagueHistory) {
Expand Down
14 changes: 9 additions & 5 deletions man/best_roster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion man/team_roster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ff4ed25

Please sign in to comment.