Skip to content

Commit

Permalink
Merge pull request #42 from kiernann/v2.2.0
Browse files Browse the repository at this point in the history
Update package for 2023 season
  • Loading branch information
k5cents authored Sep 12, 2023
2 parents b44d595 + a4f435b commit 142d16e
Show file tree
Hide file tree
Showing 28 changed files with 1,811 additions and 1,769 deletions.
29 changes: 10 additions & 19 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
Expand All @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
Expand All @@ -29,30 +29,21 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v1

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
upload-snapshots: true
39 changes: 27 additions & 12 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
tags: ['*']
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: pkgdown
extra-packages: any::pkgdown, local::.
needs: website

- name: Deploy package
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
32 changes: 26 additions & 6 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
Expand All @@ -15,16 +15,36 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: covr
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: covr::codecov()
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
10 changes: 4 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
Package: fflr
Title: Retrieve ESPN Fantasy Football Data
Version: 2.1.0.9101
Version: 2.2.0
Authors@R:
person(given = "Kiernan",
family = "Nicholls",
role = c("aut", "cre", "cph"),
email = "[email protected]")
person("Kiernan", "Nicholls", , "[email protected]", role = c("aut", "cre", "cph"))
Description: Format the raw data from the ESPN fantasy football API
<https://fantasy.espn.com/apis/v3/games/ffl/> as data frames.
Retrieve data on public leagues, rosters, athletes, and matches.
Expand All @@ -15,6 +12,7 @@ Depends:
Imports:
httr (>= 1.4.2),
jsonlite (>= 1.7.2),
stats,
tibble (>= 3.1.3)
Suggests:
knitr (>= 1.34),
Expand All @@ -29,4 +27,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ importFrom(httr,user_agent)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)
importFrom(jsonlite,unbox)
importFrom(stats,median)
importFrom(tibble,as_tibble)
importFrom(tibble,tibble)
8 changes: 5 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# fflr (development version)
# fflr 2.2.0

* **Package has been updated for the 2023 season!**
* Functions now use `seasonId = 2023` by default in `ffl_api()`.
* Update objects with latest data from 2023 season.
* Fix `nfl_players` to include actually all of the players.
* Adjust the free agent information in `nfl_teams`.
* Add more function tests.
* Add `bonusWin` column to `live_scoring()`.

# fflr 2.1.0

* **Package has been updated for the 2022 season!**
* Functions now use `seasonId = 2022` by default in `ffl_api()`.
* Functions now use `seasonId = 2022` by default in `ffl_api()`.

# fflr 2.0.2

Expand Down
4 changes: 2 additions & 2 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' be called? If `TRUE`, a list of results is returned, with one element for
#' each historical year of the league.
#' @param seasonId Integer year of NFL season. By default, the season is
#' currently set to 2022. Use a recent year or set `leagueHistory` to `TRUE`
#' currently set to 2023. Use a recent year or set `leagueHistory` to `TRUE`
#' to obtain all past data.
#' @param scoringPeriodId Integer week of NFL season. By default, `NULL` will
#' use the current week (see [ffl_week()]). Scoring periods are always one
Expand All @@ -29,7 +29,7 @@
#' @keywords internal
#' @export
ffl_api <- function(leagueId = ffl_id(), view = NULL, leagueHistory = FALSE,
seasonId = 2022, scoringPeriodId = NULL, ...) {
seasonId = 2023, scoringPeriodId = NULL, ...) {
dots <- list(..., scoringPeriodId = scoringPeriodId)
age_path <- ifelse(
test = isTRUE(leagueHistory),
Expand Down
20 changes: 11 additions & 9 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' 2022 NFL Players
#' 2023 NFL Players
#'
#' All available ESPN fantasy football players as of the 2022 season, week 1.
#' All available ESPN fantasy football players as of the 2023 season, week 1.
#'
#' @format A data frame with 1,102 rows and 11 variables:
#' \describe{
Expand All @@ -14,15 +14,17 @@
#' \item{height}{Height in integer inches}
#' \item{age}{Current age in integer year}
#' \item{dateOfBirth}{Date of birth}
#' \item{birthPlace}{Place of birth}
#' \item{debutYear}{Season debuted in league}
#' \item{draftSelection}{Overall pick number in the NFL draft}
#' ...
#' }
#' @source \url{http://sports.core.api.espn.com/v2/sports/football/leagues/nfl/seasons/2022/athletes/}
#' @source \url{http://sports.core.api.espn.com/v2/sports/football/leagues/nfl/seasons/2023/athletes/}
"nfl_players"

#' 2022 NFL Teams
#' 2023 NFL Teams
#'
#' The 32 professional NFL teams as of the 2022 season.
#' The 32 professional NFL teams as of the 2023 season.
#'
#' @format A data frame with 33 rows and 6 columns:
#' \describe{
Expand All @@ -34,12 +36,12 @@
#' \item{conference}{NFL conference}
#' ...
#' }
#' @source \url{https://fantasy.espn.com/apis/v3/games/ffl/seasons/2022?view=proTeamSchedules_wl}
#' @source \url{https://fantasy.espn.com/apis/v3/games/ffl/seasons/2023?view=proTeamSchedules_wl}
"nfl_teams"

#' 2022 NFL Schedule
#' 2023 NFL Schedule
#'
#' The 2022 NFL season schedule by team, as of September 10th.
#' The 2023 NFL season schedule by team, as of September 10th.
#'
#' @format A data frame with 544 rows and 6 variables:
#' \describe{
Expand All @@ -52,5 +54,5 @@
#' \item{date}{Matchup start date and time}
#' ...
#' }
#' @source \url{https://fantasy.espn.com/apis/v3/games/ffl/seasons/2022?view=proTeamSchedules_wl}
#' @source \url{https://fantasy.espn.com/apis/v3/games/ffl/seasons/2023?view=proTeamSchedules_wl}
"nfl_schedule"
10 changes: 6 additions & 4 deletions R/fflr.R → R/fflr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
#'
#' The fflr package parses the JSON data returned by the ESPN v3 API into tidy
#' data frames for easy analysis. The package also includes data objects for the
#' NFL with players, teams, and the 2022 schedule. The league must first be made
#' NFL with players, teams, and the 2023 schedule. The league must first be made
#' viewable to the public by the league manager, which can be done on the basic
#' settings page on the ESPN website. Functions can then take the numeric league
#' ID found in the URL to return data from the API. This league ID can be set as
#' a global option named "fflr.leagueId" with `options()`.
#'
#' @docType package
#' @name fflr
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
#> NULL
1 change: 1 addition & 0 deletions R/live.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @examples
#' live_scoring(leagueId = "42654852", yetToPlay = FALSE)
#' @importFrom tibble tibble
#' @importFrom stats median
#' @family scoring functions
#' @export
live_scoring <- function(leagueId = ffl_id(), yetToPlay = FALSE,
Expand Down
2 changes: 1 addition & 1 deletion R/outlook.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ player_outlook <- function(leagueId = ffl_id(), limit = 50) {
all_get <- httr::RETRY(
verb = "GET",
url = paste0(
"https://fantasy.espn.com/apis/v3/games/ffl/seasons/2022/segments/0/leagues/",
"https://fantasy.espn.com/apis/v3/games/ffl/seasons/2023/segments/0/leagues/",
leagueId
),
query = list(view = "kona_player_info"),
Expand Down
18 changes: 9 additions & 9 deletions R/players.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ list_players <- function(leagueId = ffl_id(),
verb = "GET",
url = paste0(
"https://fantasy.espn.com",
"/apis/v3/games/ffl/seasons/2022/segments/0/leagues/",
"/apis/v3/games/ffl/seasons/2023/segments/0/leagues/",
leagueId
),
query = list(view = "kona_player_info"),
Expand Down Expand Up @@ -260,11 +260,11 @@ fantasy_filter <- function(sort, position, status, injured, scoringPeriodId,
filterStatsForTopScoringPeriodIds = list(
value = U(2),
additionalValue = c(
"002022",
"102022",
"002023",
"102023",
"002020",
paste0("112022", scoringPeriodId),
"022022"
paste0("112023", scoringPeriodId),
"022023"
)
)
)
Expand Down Expand Up @@ -314,7 +314,7 @@ filter_sort <- function(sort = "ROST", scoringPeriodId) {
sortAppliedStatTotal = list( # PROJ
sortAsc = FALSE,
sortPriority = 1,
value = paste0("112022", scoringPeriodId)
value = paste0("112023", scoringPeriodId)
),
sortAppliedStatTotalForScoringPeriodId = list( # SCORE
sortAsc = FALSE,
Expand Down Expand Up @@ -346,12 +346,12 @@ filter_sort <- function(sort = "ROST", scoringPeriodId) {
sortAppliedStatTotal = list( # FPTS
sortAsc = FALSE,
sortPriority = 1,
value = "002022"
value = "002023"
),
sortAppliedStatAverage = list( # AVG
sortAsc = FALSE,
sortPriority = 1,
value = "002022"
value = "002023"
),
sortAppliedStatTotalForScoringPeriodId = list( # LAST
sortAsc = FALSE,
Expand Down Expand Up @@ -400,7 +400,7 @@ player_info <- function(playerId) {
dat <- try_json(
url = paste0(
"http://sports.core.api.espn.com/",
"v2/sports/football/leagues/nfl/seasons/2022/athletes/", playerId
"v2/sports/football/leagues/nfl/seasons/2023/athletes/", playerId
)
)
out <- list(
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
Loading

0 comments on commit 142d16e

Please sign in to comment.