Skip to content

Commit

Permalink
Merge branch 'develop' into Manage-input-on-Censor-tab-#158
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesBisese committed Dec 5, 2024
2 parents bd49966 + ad04a79 commit 73a85df
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
2 changes: 2 additions & 0 deletions R/mod_TADA_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
47 changes: 27 additions & 20 deletions R/utils_track_progress.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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, ]
Expand All @@ -159,32 +162,34 @@ 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(
# 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(
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)) {
Expand All @@ -193,8 +198,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)
}

0 comments on commit 73a85df

Please sign in to comment.