Skip to content

Commit

Permalink
don't release empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Nov 13, 2024
1 parent 528379d commit 6ae6b43
Showing 1 changed file with 77 additions and 61 deletions.
138 changes: 77 additions & 61 deletions R/update_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ release_stats <- function(season){
)
attr(stats_week_team, "nflfastR_version") <- as.character(packageVersion("nflfastR"))

nflversedata::nflverse_save(
data_frame = stats_week_player,
file_name = glue::glue("stats_player_week_{season}"),
nflverse_type = "player stats: week level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)

nflversedata::nflverse_save(
data_frame = stats_week_team,
file_name = glue::glue("stats_team_week_{season}"),
nflverse_type = "team stats: week level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
if (nrow(stats_week_player) > 0){
nflversedata::nflverse_save(
data_frame = stats_week_player,
file_name = glue::glue("stats_player_week_{season}"),
nflverse_type = "player stats: week level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
}

if (nrow(stats_week_team) > 0){
nflversedata::nflverse_save(
data_frame = stats_week_team,
file_name = glue::glue("stats_team_week_{season}"),
nflverse_type = "team stats: week level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
}

# PLAYER SEASON LEVEL SUMMARY ################################################

Expand Down Expand Up @@ -59,29 +63,35 @@ release_stats <- function(season){
)
attr(stats_regpost_player, "nflfastR_version") <- as.character(packageVersion("nflfastR"))

nflversedata::nflverse_save(
data_frame = stats_reg_player,
file_name = glue::glue("stats_player_reg_{season}"),
nflverse_type = "player stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)

nflversedata::nflverse_save(
data_frame = stats_post_player,
file_name = glue::glue("stats_player_post_{season}"),
nflverse_type = "team stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)

nflversedata::nflverse_save(
data_frame = stats_regpost_player,
file_name = glue::glue("stats_player_regpost_{season}"),
nflverse_type = "team stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
if (nrow(stats_reg_player) > 0){
nflversedata::nflverse_save(
data_frame = stats_reg_player,
file_name = glue::glue("stats_player_reg_{season}"),
nflverse_type = "player stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
}

if (nrow(stats_post_player) > 0){
nflversedata::nflverse_save(
data_frame = stats_post_player,
file_name = glue::glue("stats_player_post_{season}"),
nflverse_type = "team stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
}

if (nrow(stats_regpost_player) > 0){
nflversedata::nflverse_save(
data_frame = stats_regpost_player,
file_name = glue::glue("stats_player_regpost_{season}"),
nflverse_type = "team stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
}

# TEAM SEASON LEVEL SUMMARY ##################################################

Expand Down Expand Up @@ -109,29 +119,35 @@ release_stats <- function(season){
)
attr(stats_regpost_team, "nflfastR_version") <- as.character(packageVersion("nflfastR"))

nflversedata::nflverse_save(
data_frame = stats_reg_team,
file_name = glue::glue("stats_team_reg_{season}"),
nflverse_type = "player stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)

nflversedata::nflverse_save(
data_frame = stats_post_team,
file_name = glue::glue("stats_team_post_{season}"),
nflverse_type = "team stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)

nflversedata::nflverse_save(
data_frame = stats_regpost_team,
file_name = glue::glue("stats_team_regpost_{season}"),
nflverse_type = "team stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
if (nrow(stats_reg_team) > 0){
nflversedata::nflverse_save(
data_frame = stats_reg_team,
file_name = glue::glue("stats_team_reg_{season}"),
nflverse_type = "player stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
}

if (nrow(stats_post_team) > 0){
nflversedata::nflverse_save(
data_frame = stats_post_team,
file_name = glue::glue("stats_team_post_{season}"),
nflverse_type = "team stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
}

if (nrow(stats_regpost_team) > 0){
nflversedata::nflverse_save(
data_frame = stats_regpost_team,
file_name = glue::glue("stats_team_regpost_{season}"),
nflverse_type = "team stats: season level",
release_tag = "player_stats",
file_types = c("rds", "csv", "parquet", "qs", "csv.gz")
)
}

cli::cli_progress_done()
invisible(NULL)
Expand Down

0 comments on commit 6ae6b43

Please sign in to comment.