diff --git a/R/create_episode_file.R b/R/create_episode_file.R index 5a5ae0fd8..804854271 100644 --- a/R/create_episode_file.R +++ b/R/create_episode_file.R @@ -38,9 +38,7 @@ create_episode_file <- function( episode_file <- dplyr::bind_rows(processed_data_list) %>% slfhelper::get_chi() %>% - write_temp_data(year, file_name = "ep_temp1", test_mode) %>% - create_cost_inc_dna() %>% apply_cost_uplift() %>% store_ep_file_vars( diff --git a/R/write_temp_data.R b/R/write_temp_data.R index a0fb0652d..753e5e110 100644 --- a/R/write_temp_data.R +++ b/R/write_temp_data.R @@ -11,22 +11,27 @@ write_temp_data <- function(data, year, file_name, test_mode) { full_file_name <- stringr::str_glue("{file_name}.parquet") - file_path <- file.path(get_year_dir(year), - full_file_name) %>% + file_path <- file.path( + get_year_dir(year), + full_file_name + ) %>% add_test_to_filename(test_mode) cli::cli_alert_info(stringr::str_glue("Writing {full_file_name} to disk started at {Sys.time()}")) write_file(data, - path = file_path) + path = file_path + ) return(data) } -read_temp_data <- function(year, file_name, test_mode){ +read_temp_data <- function(year, file_name, test_mode) { full_file_name <- stringr::str_glue("{file_name}.parquet") - file_path <- file.path(get_year_dir(year), - full_file_name) %>% + file_path <- file.path( + get_year_dir(year), + full_file_name + ) %>% add_test_to_filename(test_mode) return(read_file(file_path)) @@ -44,7 +49,7 @@ read_temp_data <- function(year, file_name, test_mode){ #' # Example usage #' file_path <- "/conf/folder1/folder2/data.csv" #' new_file_path <- add_test_to_filename(file_path) -#' print(new_file_path) # Outputs: "/conf/folder1/folder2/TEST-data.csv" +#' print(new_file_path) # Outputs: "/conf/folder1/folder2/TEST-data.csv" add_test_to_filename <- function(file_path, test_mode) { if (test_mode) { # Extract the directory and the file name separately @@ -58,7 +63,7 @@ add_test_to_filename <- function(file_path, test_mode) { new_file_path <- file.path(dir_path, new_file_name) return(new_file_path) - } else{ + } else { return(file_path) } }