From 962ba687c6d29d0bc550fec70949a9c579aa34c4 Mon Sep 17 00:00:00 2001 From: Hook Date: Wed, 4 Dec 2024 11:27:40 -0500 Subject: [PATCH 1/2] resolved issue 174 --- R/mod_TADA_summary.R | 2 ++ R/utils_track_progress.R | 46 +++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/R/mod_TADA_summary.R b/R/mod_TADA_summary.R index 5f8127e59..617150912 100644 --- a/R/mod_TADA_summary.R +++ b/R/mod_TADA_summary.R @@ -205,7 +205,9 @@ mod_TADA_summary_server <- function(id, tadat) { setwd(tempdir()) datafile_name <- paste0(tadat$default_outfile, ".xlsx") progress_file_name <- paste0(tadat$default_outfile, "_prog.RData") + print(111) desc <- writeNarrativeDataFrame(tadat) + print(222) dfs <- list(Data = EPATADA::TADA_OrderCols(tadat$raw), Parameterization = desc) writeFile(tadat, progress_file_name) diff --git a/R/utils_track_progress.R b/R/utils_track_progress.R index 3a1e8c54a..18a4b9aa4 100644 --- a/R/utils_track_progress.R +++ b/R/utils_track_progress.R @@ -23,7 +23,7 @@ writeFile <- function(tadat, filename) { nd_mult <- tadat$nd_mult od_mult <- tadat$od_mult field_sel <- tadat$field_sel - + save( original_source, job_id, @@ -56,24 +56,24 @@ writeFile <- function(tadat, filename) { readFile <- function(tadat, filename) { load(filename, verbose = FALSE) tadat$load_progress_file <- filename - + # Confirm compatibility job_id <- job_id if (!is.null(m2f)) { tadat$m2f <- m2f } - - + + if (!is.null(selected_flags)) { tadat$selected_flags <- selected_flags shinyjs::enable(selector = '.nav li a[data-value="Flag"]') } - + # Enable tabs if certain fields are not null if (!is.null(selected_filters)) { shinyjs::enable(selector = '.nav li a[data-value="Filter"]') } - + tadat$original_source <- original_source tadat$job_id <- job_id tadat$example_data <- example_data @@ -106,12 +106,14 @@ invalidFile <- function(trigger) { writeNarrativeDataFrame <- function(tadat) { - # sampleMedia needs to be a single string for this part + # sampleMedia and siteType need to be a single string for this part + # Others? Automatic check? tadat$sampleMedia <- paste(tadat$sampleMedia, collapse = " ") + tadat$siteType <- paste(tadat$siteType, collapse = " ") df <- data.frame(Parameter = character(), Value = character()) df[nrow(df) + 1, ] <- c("TADA Shiny Job ID", tadat$job_id) df[nrow(df) + 1, ] <- c("Original data source: ", tadat$original_source) - + # Data Query Tab if (tadat$original_source == "Example") { df[nrow(df) + 1, ] <- c("Example data file", tadat$example_data) @@ -146,6 +148,7 @@ writeNarrativeDataFrame <- function(tadat) { tadat$endDate ) ) + for (i in seq_len(nrow(query_params))) { if (!is.null(query_params[i, "value"])) { df[nrow(df) + 1, ] <- query_params[i, ] @@ -159,32 +162,33 @@ writeNarrativeDataFrame <- function(tadat) { } + # Flagging Tab for (flag in tadat$selected_flags) { df[nrow(df) + 1, ] <- c("Selected Flag", flag) } - - + + if (!is.null(tadat$m2f)) { df[nrow(df) + 1, ] <- c("Depth unit conversion", tadat$m2f) } else { df[nrow(df) + 1, ] <- c("Depth unit conversion", "None") } - # Filtering tab - for (row in 1:nrow(tadat$selected_filters)) { - df[nrow(df) + 1, ] <- c( - "Selected Filter", - paste0( + if (nrow(tadat$selected_filters) > 0) { + for (row in 1:nrow(tadat$selected_filters)) { + val <- paste0( tadat$selected_filters[row, "Filter"], ": ", tadat$selected_filters[row, "Field"], " = ", tadat$selected_filters[row, "Value"] ) - ) - } + new_entry <- c("Selected Filter", val) + df[nrow(df) + 1, ] <- new_entry + } + } # Censored Data tab if (is.null(tadat$nd_mult)) { @@ -193,8 +197,10 @@ writeNarrativeDataFrame <- function(tadat) { if (is.null(tadat$od_mult)) { tadat$od_mult <- "n/a" } - df[nrow(df) + 1, ] <- c("Non-Detect Handling Method", sub("x", tadat$nd_mult, tadat$nd_method)) - df[nrow(df) + 1, ] <- c("Over-Detect Handling Method", sub("x", tadat$od_mult, tadat$od_method)) - + df[nrow(df) + 1, ] <- c("Non-Detect Handling Method", + sub("x", tadat$nd_mult, tadat$nd_method)) + df[nrow(df) + 1, ] <- c("Over-Detect Handling Method", + sub("x", tadat$od_mult, tadat$od_method)) + return(df) } From 226542df3c2e33b7b06eb6d728e9207d98fe302e Mon Sep 17 00:00:00 2001 From: cristinamullin <46969696+cristinamullin@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:26:23 -0500 Subject: [PATCH 2/2] add note --- R/mod_TADA_summary.R | 4 ++-- R/utils_track_progress.R | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/R/mod_TADA_summary.R b/R/mod_TADA_summary.R index 617150912..d6c82ba74 100644 --- a/R/mod_TADA_summary.R +++ b/R/mod_TADA_summary.R @@ -205,9 +205,9 @@ mod_TADA_summary_server <- function(id, tadat) { setwd(tempdir()) datafile_name <- paste0(tadat$default_outfile, ".xlsx") progress_file_name <- paste0(tadat$default_outfile, "_prog.RData") - print(111) + # print(111) desc <- writeNarrativeDataFrame(tadat) - print(222) + # print(222) dfs <- list(Data = EPATADA::TADA_OrderCols(tadat$raw), Parameterization = desc) writeFile(tadat, progress_file_name) diff --git a/R/utils_track_progress.R b/R/utils_track_progress.R index 18a4b9aa4..2fcba082a 100644 --- a/R/utils_track_progress.R +++ b/R/utils_track_progress.R @@ -176,6 +176,7 @@ writeNarrativeDataFrame <- function(tadat) { } # Filtering tab + # skips the recording of selected filters in the progress file if the filters haven't been selected yet if (nrow(tadat$selected_filters) > 0) { for (row in 1:nrow(tadat$selected_filters)) { val <- paste0(