Skip to content

Commit

Permalink
allow rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Aug 22, 2023
1 parent c9f118e commit d4f911a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^.*\.Rproj$
^\.Rproj\.user$
9 changes: 8 additions & 1 deletion .github/workflows/update_ngs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
11 changes: 1 addition & 10 deletions R/ngs_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion R/update_ngs.R
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
4 changes: 4 additions & 0 deletions ngs-data.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ LaTeX: pdfLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source

0 comments on commit d4f911a

Please sign in to comment.