diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 00000000..91114bf2 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,2 @@ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.github/workflows/update_ngs.yaml b/.github/workflows/update_ngs.yaml index 83f7490c..015de91c 100644 --- a/.github/workflows/update_ngs.yaml +++ b/.github/workflows/update_ngs.yaml @@ -3,6 +3,12 @@ on: # runs every day at 7:00 AM UTC = 3AM ET in jan, feb, sep-dec - cron: '0 7 * 1,2,9-12 *' workflow_dispatch: + inputs: + full_rebuild: + description: 'Full Rebuild' + required: true + default: false + type: boolean name: update_ngs @@ -12,8 +18,9 @@ jobs: runs-on: macOS-latest env: GITHUB_PAT: ${{ secrets.NFLVERSE_GH_TOKEN }} + NFLVERSE_REBUILD: ${{ inputs.full_rebuild }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-r@v2 - uses: r-lib/actions/setup-r-dependencies@v2 with: diff --git a/R/ngs_functions.R b/R/ngs_functions.R index 22267f19..58f2bb1b 100644 --- a/R/ngs_functions.R +++ b/R/ngs_functions.R @@ -128,16 +128,7 @@ upload_nflverse <- function(data_path = "data") { nflversedata::nflverse_upload("nextgen_stats") } -most_recent_season <- function() { - today <- Sys.Date() - current_year <- format(today, format = "%Y") |> as.integer() - current_month <- format(today, format = "%m") |> as.integer() - if (current_month >= 9){ - return(current_year) - } else { - return(current_year - 1) - } -} +most_recent_season <- nflreadr::most_recent_season passing_stats <- c( "avg_time_to_throw", diff --git a/R/update_ngs.R b/R/update_ngs.R index 080888a6..2da8c3bf 100644 --- a/R/update_ngs.R +++ b/R/update_ngs.R @@ -1,6 +1,11 @@ source("R/ngs_functions.R") -save_ngs_data(most_recent_season()) +if(Sys.getenv("NFLVERSE_REBUILD", "false") == "true"){ + seasons_to_update <- 2016:nflreadr::most_recent_season() +} else { + seasons_to_update <- nflreadr::most_recent_season() +} +save_ngs_data(seasons_to_update) purrr::walk(c("passing", "rushing", "receiving"), combine_ngs_data) diff --git a/ngs-data.Rproj b/ngs-data.Rproj index c8daeb91..6a3ede22 100644 --- a/ngs-data.Rproj +++ b/ngs-data.Rproj @@ -15,3 +15,7 @@ LaTeX: pdfLaTeX AutoAppendNewline: Yes StripTrailingWhitespace: Yes LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source