Skip to content

Commit

Permalink
Return list of current team rosters
Browse files Browse the repository at this point in the history
TODO: Add `scoringPeriodId` argument to get previous rosters?

Progress to #24
  • Loading branch information
k5cents committed Aug 15, 2021
1 parent 61b6f59 commit 40e058b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 3 additions & 3 deletions R/roster.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ out_roster <- function(entry, t = NULL) {
id = player$id,
firstName = player$firstName,
lastName = player$lastName,
proTeam = fflr::nfl_teams$abbrev[match(player$proTeamId, fflr::nfl_teams$team)],
proTeam = nfl_teams$abbrev[match(player$proTeamId, nfl_teams$team)],
PositionId = pos_abbrev(player$defaultPositionId),
injuryStatus = injury_status,
proj = proj_dbl,
score = score_dbl,
projectedScore = proj_dbl,
actualScore = score_dbl,
percentStarted = player$ownership$percentStarted,
percentOwned = player$ownership$percentOwned,
percentChange = round(player$ownership$percentChange, digits = 3)
Expand Down
6 changes: 4 additions & 2 deletions man/team_roster.Rd

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

18 changes: 18 additions & 0 deletions tests/testthat/test-roster.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
test_that("All current team rosters as list", {
r <- team_roster(leagueId = "42654852")
expect_type(r, "list")
expect_length(r, 4)
expect_s3_class(r[[1]], "data.frame")
expect_length(r[[1]], 15)
expect_s3_class(r[[1]]$slot, "factor")
})

test_that("All final period team rosters as list of list", {
rh <- team_roster(leagueId = "252353", leagueHistory = TRUE)
expect_gt(length(rh), 4)
expect_length(rh[[1]], 8)
expect_length(rh[[2]], 10)
expect_type(rh, "list")
expect_type(rh[[1]], "list")
expect_s3_class(rh[[1]][[1]], "data.frame")
})

0 comments on commit 40e058b

Please # to comment.