Skip to content

Commit

Permalink
update write_tests_xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
lizihao-anu committed Aug 23, 2024
1 parent 962f7a3 commit 0746ee6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion R/process_tests_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ process_tests_episode_file <- function(data, year) {
recid = TRUE
) %>%
dplyr::arrange(.data[["recid"]]) %>%
write_tests_xlsx(sheet_name = "ep_file", year, workbook_name = "ep_file")
write_tests_xlsx(sheet_name = stringr::str_glue({"ep_file_{year}"}), workbook_name = "ep_file")

return(comparison)
}
Expand Down
2 changes: 1 addition & 1 deletion R/process_tests_individual_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ process_tests_individual_file <- function(data, year) {
old_data = produce_individual_file_tests(old_data),
new_data = produce_individual_file_tests(data)
) %>%
write_tests_xlsx(sheet_name = "indiv_file", year, workbook_name = "indiv_file")
write_tests_xlsx(sheet_name = stringr::str_glue({"indiv_file_{year}"}), workbook_name = "indiv_file")

return(comparison)
}
Expand Down
47 changes: 36 additions & 11 deletions R/write_tests_xlsx.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,42 @@ write_tests_xlsx <- function(comparison_data,
"cross_year"
)) {
# Set up the workbook ----
tests_workbook_name <- dplyr::case_when(
is.null(year) & workbook_name == "ep_file" ~ stringr::str_glue(latest_update(), "_ep_file_tests"),
!is.null(year) & workbook_name == "ep_file" ~ stringr::str_glue(latest_update(), "_{year}_ep_file_tests"),
is.null(year) & workbook_name == "indiv_file" ~ stringr::str_glue(latest_update(), "_indiv_file_tests"),
!is.null(year) & workbook_name == "indiv_file" ~ stringr::str_glue(latest_update(), "_{year}_indiv_file_tests"),
is.null(year) & workbook_name == "lookup" ~ stringr::str_glue(latest_update(), "_lookups_tests"),
is.null(year) & workbook_name == "sandpit" ~ stringr::str_glue(latest_update(), "_sandpit_extract_tests"),
is.null(year) & workbook_name == "cross_year" ~ stringr::str_glue(latest_update(), "_cross_year_tests"),
!is.null(year) & workbook_name == "sandpit" ~ stringr::str_glue(latest_update(), "_sandpit_extract_tests"),
!is.null(year) & workbook_name == "extract" ~ stringr::str_glue(latest_update(), "_{year}_extract_tests")
)
if (workbook_name == "ep_file") {
if (is.null(year)) {
tests_workbook_name <-
stringr::str_glue(latest_update(), "_ep_file_tests")
}
}
if (workbook_name == "indiv_file") {
if (is.null(year)) {
tests_workbook_name <-
stringr::str_glue(latest_update(), "_indiv_file_tests")
}
}
if (workbook_name == "lookup") {
if (is.null(year)) {
tests_workbook_name <-
stringr::str_glue(latest_update(), "_lookups_tests")
}
}
if (workbook_name == "sandpit") {
tests_workbook_name <-
stringr::str_glue(latest_update(), "_sandpit_extract_tests")
}
if (workbook_name == "cross_year") {
if (is.null(year)) {
tests_workbook_name <-
stringr::str_glue(latest_update(), "_cross_year_tests")
}
}
if (workbook_name == "extract") {
if (is.null(year)) {
} else{
tests_workbook_name <-
stringr::str_glue(latest_update(), "_{year}_extract_tests")
}
}


tests_workbook_path <- fs::path(
get_slf_dir(),
Expand Down

0 comments on commit 0746ee6

Please sign in to comment.