Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/k5cents/fflr
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.Rmd
#	tests/testthat/test-live.R
#	tests/testthat/test-outlook.R
  • Loading branch information
k5cents committed May 3, 2024
2 parents b149cec + 51d8f83 commit 5afdea6
Show file tree
Hide file tree
Showing 17 changed files with 693 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If you’ve found a bug, please file an issue that illustrates the bug with a mi

### Pull request process

* Fork the package and clone onto your computer. If you haven't done this before, we recommend using `usethis::create_from_github("kiernann/fflr", fork = TRUE)`.
* Fork the package and clone onto your computer. If you haven't done this before, we recommend using `usethis::create_from_github("k5cents/fflr", fork = TRUE)`.

* Install all development dependences with `devtools::install_dev_deps()`, and then make sure the package passes R CMD check by running `devtools::check()`.
If R CMD check doesn't pass cleanly, it's a good idea to ask for help before continuing.
Expand Down
4 changes: 2 additions & 2 deletions .github/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Armed with your reprex, the next step is to figure out [where to ask](https://ww

* If it's a question: start with [community.rstudio.com](https://community.rstudio.com/), and/or StackOverflow. There are more people there to answer questions.

* If it's a bug: you're in the right place, [file an issue](https://github.com/kiernann/fflr/issues/new).
* If it's a bug: you're in the right place, [file an issue](https://github.com/k5cents/fflr/issues/new).

* If you're not sure: let the community help you figure it out!
If your problem _is_ a bug or a feature request, you can easily return here and report it.

Before opening a new issue, be sure to [search issues and pull requests](https://github.com/kiernann/fflr/issues) to make sure the bug hasn't been reported and/or already fixed in the development version.
Before opening a new issue, be sure to [search issues and pull requests](https://github.com/k5cents/fflr/issues) to make sure the bug hasn't been reported and/or already fixed in the development version.
By default, the search will be pre-populated with `is:issue is:open`.
You can [edit the qualifiers](https://help.github.com/articles/searching-issues-and-pull-requests/) (e.g. `is:pr`, `is:closed`) as needed.
For example, you'd simply remove `is:open` to search _all_ issues in the repo, open or closed.
Expand Down
9 changes: 6 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
Package: fflr
Title: Retrieve ESPN Fantasy Football Data
Version: 2.2.0.9002
Version: 2.2.4
Authors@R:
person("Kiernan", "Nicholls", , "kiernann@protonmail.com", role = c("aut", "cre", "cph"))
person("Kiernan", "Nicholls", email = "k5cents@gmail.com", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0002-9229-7897"))
Description: Format the raw data from the ESPN fantasy football API
<https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl> as data frames.
Retrieve data on public leagues, rosters, athletes, and matches.
License: MIT + file LICENSE
License: GPL (>= 3)
URL: https://k5cents.github.io/fflr/, https://github.com/k5cents/fflr
BugReports: https://github.com/k5cents/fflr/issues
Depends:
R (>= 2.10)
Imports:
Expand Down
2 changes: 0 additions & 2 deletions LICENSE

This file was deleted.

616 changes: 595 additions & 21 deletions LICENSE.md

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# fflr (development version)
# fflr 2.2.4

Fix tests for post-season API data formats.

# fflr 2.2.3

* Update maintainer email, website URL, and GitHub URL.
* Switch from MIT license to GPL-3

# fflr 2.2.2

* Adjust more tests for the end of the NFL season and changes to API.

# fflr 2.2.1

* Adjust tests for end of NFL season.
* The functions `league_members()` and `league_teams()` have been adjusted to
add new columns. The order of columns has also been rearranged to focus on
the output of each function (all teams or all members), since some teams can
Expand Down
2 changes: 1 addition & 1 deletion R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ try_json <- function(url, path = "", query = NULL, leagueHistory = NULL) {
),
query = query,
httr::accept_json(),
httr::user_agent("https://github.com/kiernann/fflr/"),
httr::user_agent("https://github.com/k5cents/fflr/"),
terminate_on = c(400:417)
)
if (httr::http_type(resp) != "application/json") {
Expand Down
14 changes: 14 additions & 0 deletions R/live.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ live_scoring <- function(leagueId = ffl_id(), yetToPlay = FALSE,
dat$schedule$away$totalProjectedPointsLive
)
)
if (all(is.na(s$totalProjectedPointsLive))) {
message("No live scoring available")
return(data.frame())
}
s <- s[!is.na(s$totalProjectedPointsLive), ]
s <- s[order(s$matchupId), ]
tm <- out_team(dat$teams, trim = TRUE)
Expand All @@ -55,6 +59,16 @@ live_scoring <- function(leagueId = ffl_id(), yetToPlay = FALSE,
s$bonusWin <- s$totalProjectedPointsLive > middle_point
}
if (yetToPlay) {
pro <- tryCatch(
expr = pro_schedule(),
error = function(e) {
return(NULL)
}
)
if (is.null(pro)) {
message("No pro schedule available to compare start times")
return(s)
}
r <- do.call(
"rbind",
lapply(
Expand Down
19 changes: 12 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The most recent development version can be installed from [GitHub][gh]:

```{r remote, eval=FALSE}
# install.packages("remotes")
remotes::install_github("kiernann/fflr")
remotes::install_github("k5cents/fflr")
```

## Usage
Expand Down Expand Up @@ -110,16 +110,21 @@ contributing, you agree to abide by its terms.
[life_link]: https://lifecycle.r-lib.org/articles/stages.html#stable
[cran_badge]: https://www.r-pkg.org/badges/version/fflr
[cran_link]: https://CRAN.R-project.org/package=fflr
[ga_badge]: https://github.com/kiernann/fflr/workflows/R-CMD-check/badge.svg
[ga_link]: https://github.com/kiernann/fflr/actions
[cov_badge]: https://img.shields.io/codecov/c/github/kiernann/fflr/master.svg
[cov_link]: https://app.codecov.io/gh/kiernann/fflr?branch=master'
[ga_badge]: https://github.com/k5cents/fflr/workflows/R-CMD-check/badge.svg
[ga_link]: https://github.com/k5cents/fflr/actions
[cov_badge]: https://codecov.io/gh/k5cents/fflr/graph/badge.svg?token=CMz6DIxJdH
[cov_link]: https://app.codecov.io/gh/k5cents/fflr?branch=master
[dl_badge]: https://cranlogs.r-pkg.org/badges/grand-total/fflr
<<<<<<< HEAD
[api]: https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/
[iss]: https://github.com/kiernann/fflr/issues
=======
[api]: https://fantasy.espn.com/apis/v3/games/ffl/
[iss]: https://github.com/k5cents/fflr/issues
>>>>>>> 51d8f8313cb57960ba168ad9b476f2d226482453
[cran]: https://cran.r-project.org/package=fflr
[gh]: https://github.com/kiernann/fflr
[coc]: https://kiernann.github.io/fflr/CODE_OF_CONDUCT.html
[gh]: https://github.com/k5cents/fflr
[coc]: https://k5cents.github.io/fflr/CODE_OF_CONDUCT.html
[help]: https://web.archive.org/web/20211105212446/https://support.espn.com/hc/en-us/articles/360000064451-Making-a-Private-League-Viewable-to-the-Public
[rprof]: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html
<!-- refs: end -->
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ experimental](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](ht
status](https://www.r-pkg.org/badges/version/fflr)](https://CRAN.R-project.org/package=fflr)
![Downloads](https://cranlogs.r-pkg.org/badges/grand-total/fflr)
[![Codecov test
coverage](https://img.shields.io/codecov/c/github/kiernann/fflr/master.svg)](https://app.codecov.io/gh/kiernann/fflr?branch=master')
coverage](https://codecov.io/gh/k5cents/fflr/graph/badge.svg?token=CMz6DIxJdH)](https://app.codecov.io/gh/k5cents/fflr?branch=master)
[![R build
status](https://github.com/kiernann/fflr/workflows/R-CMD-check/badge.svg)](https://github.com/kiernann/fflr/actions)
status](https://github.com/k5cents/fflr/workflows/R-CMD-check/badge.svg)](https://github.com/k5cents/fflr/actions)
<!-- badges: end -->

The fflr package is used to query the [ESPN Fantasy Football
Expand All @@ -22,7 +22,7 @@ football league members, teams, and individual athletes.

This package has been tested with a narrow subset of possible league
settings. If a function doesn’t work as intended, please file an [issue
on GitHub](https://github.com/kiernann/fflr/issues).
on GitHub](https://github.com/k5cents/fflr/issues).

## Installation

Expand All @@ -34,19 +34,19 @@ install.packages("fflr")
```

The most recent development version can be installed from
[GitHub](https://github.com/kiernann/fflr):
[GitHub](https://github.com/k5cents/fflr):

``` r
# install.packages("remotes")
remotes::install_github("kiernann/fflr")
remotes::install_github("k5cents/fflr")
```

## Usage

``` r
library(fflr)
packageVersion("fflr")
#> [1] '2.2.0'
#> [1] '2.2.3'
```

Data is only available for public leagues. See [this help
Expand Down Expand Up @@ -78,13 +78,13 @@ league_info()
#> <int> <int> <chr> <lgl> <int> <int>
#> 1 42654852 2023 FFLR Test League TRUE 4 17
league_teams()
#> # A tibble: 4 × 3
#> abbrev teamId memberId
#> <fct> <int> <chr>
#> 1 AUS 1 {22DFE7FF-9DF2-4F3B-9FE7-FF9DF2AF3BD2}
#> 2 BOS 2 {22DFE7FF-9DF2-4F3B-9FE7-FF9DF2AF3BD2}
#> 3 CHI 3 {22DFE7FF-9DF2-4F3B-9FE7-FF9DF2AF3BD2}
#> 4 DEN 4 {22DFE7FF-9DF2-4F3B-9FE7-FF9DF2AF3BD2}
#> # A tibble: 4 × 6
#> teamId abbrev name logo logoType memberId
#> <int> <fct> <chr> <chr> <chr> <chr>
#> 1 1 AUS Austin Astronauts https://g.espncdn.com/lm-static/logo-packs/cor… VECTOR {22DFE7…
#> 2 2 BOS Boston Buzzards https://g.espncdn.com/lm-static/logo-packs/cor… VECTOR {22DFE7…
#> 3 3 CHI Chicago Crowns https://g.espncdn.com/lm-static/logo-packs/cor… VECTOR {22DFE7…
#> 4 4 DEN Denver Devils https://g.espncdn.com/lm-static/logo-packs/cor… VECTOR {22DFE7…
```

The `scoringPeriodId` argument can be used to get data from past weeks.
Expand Down Expand Up @@ -136,7 +136,7 @@ nfl_teams
------------------------------------------------------------------------

The fflr project is released with a [Contributor Code of
Conduct](https://kiernann.github.io/fflr/CODE_OF_CONDUCT.html). By
Conduct](https://k5cents.github.io/fflr/CODE_OF_CONDUCT.html). By
contributing, you agree to abide by its terms.

<!-- refs: start -->
Expand Down
7 changes: 2 additions & 5 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Test environments

* local: ubuntu 22.04.4, R 4.1.2
* GitHub Actions (macos-latest, windows-latest, ubuntu-latest)
* https://github.com/kiernann/fflr/actions/runs/6161897291/job/16722168072
* https://github.com/k5cents/fflr/actions/runs/6161897291/job/16722168072
* win-builder: devel
* r-hub: windows-x86_64-devel, ubuntu-gcc-release, fedora-clang-devel
* <https://builder.r-hub.io/status/fflr_2.2.0.tar.gz-e6d5e9f3a306438d9f4b703c8ab75dcd>
Expand All @@ -11,7 +12,3 @@
## R CMD check results

0 errors | 0 warnings | 0 note

## Resubmission

* Fixed broken link to https://kiernann.com/fflr in README
3 changes: 1 addition & 2 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
COVID
Codecov
FPTS
FREEAGENT
Expand All @@ -9,6 +8,7 @@ Lifecycle
Matchup
ONTEAM
OPRK
ORCID
PRK
PROJ
README
Expand All @@ -18,7 +18,6 @@ TBD
Unnest
WR
actualScore
httr
leagueId
mRoster
mSettings
Expand Down
11 changes: 10 additions & 1 deletion man/fflr-package.Rd

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

6 changes: 4 additions & 2 deletions tests/testthat/test-best.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test_that("calculate best possible future roster", {
b <- best_roster(
leagueId = "42654852",
useScore = "projectedScore",
scoringPeriodId = ffl_week()
scoringPeriodId = 1
)
skip_empty(b)
b2 <- b[[2]]
Expand All @@ -27,5 +27,7 @@ test_that("calculate best possible future roster", {

start_wr <- b2$projectedScore[b2$lineupSlot == "WR"]
bench_wr <- b2$projectedScore[b2$lineupSlot == "BE" & b2$position == "WR"]
expect_gt(min(start_wr), max(bench_wr))
if (sum(start_wr) > 0) {
expect_gt(min(start_wr), max(bench_wr))
}
})
4 changes: 2 additions & 2 deletions tests/testthat/test-events.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ test_that("get NFL game schedule times", {
e <- pro_events()
skip_empty(e)
expect_s3_class(e, "data.frame")
expect_type(e$competitors, "list")
expect_length(e, 13)
# expect_type(e$competitors, "list")
expect_length(e, 7)
})

test_that("get NFL game scores", {
Expand Down
8 changes: 6 additions & 2 deletions tests/testthat/test-live.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
test_that("live scoring returns 1 row per team", {
<<<<<<< HEAD
l <- live_scoring(leagueId = "42654852", yetToPlay = TRUE, bonusWin = TRUE)
skip_empty(l)
=======
l <- live_scoring(leagueId = "42654852", yetToPlay = FALSE, bonusWin = TRUE)
>>>>>>> 51d8f8313cb57960ba168ad9b476f2d226482453
expect_s3_class(l, "data.frame")
expect_true("toPlay" %in% names(l))
expect_length(l, 8)
# expect_true("toPlay" %in% names(l))
expect_length(l, 7)
expect_equal(nrow(l), 4)
})
8 changes: 8 additions & 0 deletions tests/testthat/test-outlook.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@ test_that("get individual player outlook", {
limit = 1
)
expect_s3_class(o, "data.frame")
<<<<<<< HEAD
expect_length(o, 5)
=======
if (is.na(o$outlook)) {
expect_length(o, 5)
} else {
expect_length(o, 6)
}
>>>>>>> 51d8f8313cb57960ba168ad9b476f2d226482453
})

0 comments on commit 5afdea6

Please sign in to comment.