Skip to content

Commit

Permalink
Revert "fixed the zip file issue, na filters in desc tab"
Browse files Browse the repository at this point in the history
This reverts commit b6f00b9.
  • Loading branch information
triphook committed Jan 3, 2024
1 parent b6f00b9 commit b6b0844
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 61 deletions.
4 changes: 2 additions & 2 deletions R/mod_TADA_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ mod_TADA_summary_server <- function(id, tadat) {
desc <- writeNarrativeDataFrame(tadat)
dfs <-
list(Data = TADA::TADA_OrderCols(tadat$raw), Parameterization = desc)
writeProgressFile(tadat, progress_file_name)
writeFile(tadat, progress_file_name)
writexl::write_xlsx(dfs, path = datafile_name)
utils::zip(zipfile = fname,
files = c(datafile_name, progress_file_name))
Expand All @@ -210,7 +210,7 @@ mod_TADA_summary_server <- function(id, tadat) {
# paste0(tadat$job_id, '.Rdata')
# },
# content = function(file) {
# writeProgressFile(tadat, file)
# writeFile(tadat, file)
# }
# )

Expand Down
2 changes: 1 addition & 1 deletion R/mod_data_flagging.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mod_data_flagging_ui <- function(id) {
ns("m2f"),
label = "",
choices = c("feet", "inches", "meters"),
selected = "meters",
selected = character(0),
inline = TRUE
)
))
Expand Down
32 changes: 16 additions & 16 deletions R/mod_query_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod_query_data_ui <- function(id) {
shiny::fluidRow(column(
4,
shiny::dateInput(
ns("startDate"),
ns("startdate"),
"Start Date",
format = "yyyy-mm-dd",
startview = "year"
Expand All @@ -70,7 +70,7 @@ mod_query_data_ui <- function(id) {
column(
4,
shiny::dateInput(
ns("endDate"),
ns("enddate"),
"End Date",
format = "yyyy-mm-dd",
startview = "year"
Expand Down Expand Up @@ -233,7 +233,7 @@ mod_query_data_server <- function(id, tadat) {
shiny::observe({
shiny::req(input$progress_file)
# user uploaded data
readProgressFile(tadat, input$progress_file$datapath)
readFile(tadat, input$progress_file$datapath)
})

# if user presses example data button, make tadat$raw the nutrients dataset contained within the TADA package.
Expand Down Expand Up @@ -347,9 +347,9 @@ mod_query_data_server <- function(id, tadat) {
tadat$sampleMedia <- input$media
}
if (is.null(input$proj)) {
tadat$proj <- "null"
tadat$project <- "null"
} else {
tadat$proj <- input$proj
tadat$project <- input$proj
}
if (is.null(input$org)) {
tadat$organization <- "null"
Expand All @@ -362,17 +362,17 @@ mod_query_data_server <- function(id, tadat) {
tadat$siteid <- input$siteid
# siteid = stringr::str_trim(unlist(strsplit(input$siteids,",")))
}
if (length(input$endDate) == 0) {
if (length(input$enddate) == 0) {
# ensure if date is empty, the query receives a proper input ("null")
tadat$endDate <- "null"
tadat$enddate <- "null"
} else {
tadat$endDate <- as.character(input$endDate)
tadat$enddate <- as.character(input$enddate)
}
if (length(input$startDate) == 0) {
if (length(input$startdate) == 0) {
# ensure if date is empty, the query receives a proper start date. Might want a warning message instead.
tadat$startDate <- "1800-01-01"
tadat$startdate <- "1800-01-01"
} else {
tadat$startDate <- as.character(input$startDate)
tadat$startdate <- as.character(input$startdate)
}
# a modal that pops up showing it's working on querying the portal
shinybusy::show_modal_spinner(
Expand All @@ -392,10 +392,10 @@ mod_query_data_server <- function(id, tadat) {
characteristicName = tadat$characteristicName,
characteristicType = tadat$characteristicType,
sampleMedia = tadat$sampleMedia,
proj = tadat$proj,
project = tadat$project,
organization = tadat$organization,
startDate = tadat$startDate,
endDate = tadat$endDate,
startDate = tadat$startdate,
endDate = tadat$enddate,
applyautoclean = TRUE
)

Expand Down Expand Up @@ -439,8 +439,8 @@ mod_query_data_server <- function(id, tadat) {
shiny::updateSelectizeInput(session, "media", selected = tadat$sampleMedia)
shiny::updateSelectizeInput(session, "proj", selected = tadat$proj)
shiny::updateSelectizeInput(session, "org", selected = tadat$organization)
shiny::updateDateInput(session, "startDate", value = tadat$startDate)
shiny::updateDateInput(session, "endDate", value = tadat$endDate)
shiny::updateDateInput(session, "startdate", value = tadat$startDate)
shiny::updateDateInput(session, "enddate", value = tadat$endDate)
}
}

Expand Down
4 changes: 3 additions & 1 deletion R/mod_review_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ mod_review_data_server <- function(id, tadat) {
shiny::observeEvent(input$review_go, {
removals <- tadat$removals
sel <- which(removals == TRUE, arr.ind = TRUE)
print(length(sel))
# Bombing here
if (length(sel) > 0) {
removals[sel] <- names(removals)[sel[, "col"]]
removals[removals == FALSE] <- ""
Expand Down Expand Up @@ -94,7 +96,7 @@ mod_review_data_server <- function(id, tadat) {
if (nrow(rem_reas) > 0) {
review_things$rem_reas <- rem_reas
} else{
review_things$rem_reas <- data.frame(Reason="No Removals", Count=0)
review_things$rem_reas <- data.frame(Reason="No Removals", Count=1)
}
})

Expand Down
76 changes: 35 additions & 41 deletions R/utils_track_progress.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
writeProgressFile <- function(tadat, filename) {

writeFile <- function(tadat, filename) {
original_source = tadat$original_source
job_id = tadat$job_id
statecode = tadat$statecode
Expand All @@ -17,8 +18,7 @@ writeProgressFile <- function(tadat, filename) {
org_table <- tadat$org_table
selected_flags <- tadat$selected_flags
m2f <- tadat$m2f
selected_filters <-
tadat$selected_filters[c("Field", "Value", "Filter")]
selected_filters <- tadat$selected_filters[c("Field", "Value", "Filter")]
nd_method <- tadat$nd_method
od_method <- tadat$od_method
nd_mult <- tadat$nd_mult
Expand Down Expand Up @@ -53,30 +53,30 @@ writeProgressFile <- function(tadat, filename) {

}

readProgressFile <- function(tadat, filename) {
readFile <- function(tadat, filename) {
load(filename, verbose = FALSE)
checkFlagColumns(tadat$raw)
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"]')
} else {
print("No flags selected")
}

# 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 @@ -109,15 +109,14 @@ invalidFile <- function(trigger) {


writeNarrativeDataFrame <- function(tadat) {
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)
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)
df[nrow(df) + 1, ] = c("Example data file", tadat$example_data)
} else if (tadat$original_source == "Query") {
tadat$sampleMedia = paste(tadat$sampleMedia, collapse = ", ")
query_params = data.frame(
param = c(
"State Code",
Expand Down Expand Up @@ -150,58 +149,53 @@ writeNarrativeDataFrame <- function(tadat) {
)
for (i in seq_len(nrow(query_params))) {
if (!is.null(query_params[i, "value"])) {
df[nrow(df) + 1,] = query_params[i, ]
df[nrow(df) + 1, ] = query_params[i,]
}
}
}

# Overview Tab
for (row in 1:nrow(tadat$org_table)) {
df[nrow(df) + 1,] = c(paste0("Organization Rank ", row), tadat$org_table[row, 'OrganizationFormalName'])
df[nrow(df) + 1, ] = c(paste0("Organization Rank ", row), tadat$org_table[row, 'OrganizationFormalName'])
}


# Flagging Tab
for (flag in tadat$selected_flags) {
df[nrow(df) + 1,] = c("Selected Flag", flag)
df[nrow(df) + 1, ] = c("Selected Flag", flag)
}


if (!is.null(tadat$m2f)) {
df[nrow(df) + 1,] = c("Depth unit conversion", tadat$m2f)
df[nrow(df) + 1, ] = c("Depth unit conversion", tadat$m2f)
} else {
df[nrow(df) + 1,] = c("Depth unit conversion", "None")
df[nrow(df) + 1, ] = c("Depth unit conversion", "None")
}


# Filtering tab
if (nrow(tadat$selected_filters) > 0) {
for (row in 1:nrow(tadat$selected_filters)) {
df[nrow(df) + 1,] = c(
"Selected Filter",
paste0(
tadat$selected_filters[row, 'Filter'],
": ",
tadat$selected_filters[row, 'Field'],
" = ",
tadat$selected_filters[row, 'Value']
)
for (row in 1:nrow(tadat$selected_filters)) {
df[nrow(df) + 1, ] = c(
"Selected Filter",
paste0(
tadat$selected_filters[row, 'Filter'],
": ",
tadat$selected_filters[row, 'Field'],
" = ",
tadat$selected_filters[row, 'Value']
)
print(df[nrow(df) + 1,])
}
)
}

# Censored Data tab
if (is.null(tadat$nd_mult)) {
if (is.null(tadat$nd_mult)){
tadat$nd_mult = "n/a"
}
if (is.null(tadat$od_mult)) {
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 b6b0844

Please sign in to comment.