Skip to content

Commit

Permalink
Style code
Browse files Browse the repository at this point in the history
  • Loading branch information
lizihao-anu authored and github-actions[bot] committed Oct 7, 2024
1 parent e6b0fd3 commit 9d1d0bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 0 additions & 2 deletions R/create_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
21 changes: 13 additions & 8 deletions R/write_temp_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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)
}
}

0 comments on commit 9d1d0bd

Please sign in to comment.