From cb22f105b63c8a1fb39b659018e98394728d02be Mon Sep 17 00:00:00 2001 From: Jon Bryant Date: Tue, 8 Jul 2025 17:59:26 -0400 Subject: [PATCH] Removed return and fixed dtime The return() function looks like it came from when it was a module and it still had the dtime_est for the old db. The sensor_test_table shows but won't be filled in because there's nothing in the db yet. --- .gitignore | 4 ++++ SensorApp/app.R | 21 ++++++--------------- SensorHub.Rproj | 13 +++++++++++++ 3 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 .gitignore create mode 100644 SensorHub.Rproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/SensorApp/app.R b/SensorApp/app.R index 753fb9a..4326ba5 100644 --- a/SensorApp/app.R +++ b/SensorApp/app.R @@ -37,7 +37,7 @@ options(DT.options = list(pageLength = 15)) #set db connection #using a pool connection so separate connnections are unified #gets environmental variables saved in local or pwdrstudio environment -poolConn <- dbPool(odbc(), dsn = "mars14_datav2", uid = Sys.getenv("shiny_uid"), pwd = Sys.getenv("shiny_pwd")) +poolConn <- dbPool(odbc::odbc(), dsn = "mars14_datav2", uid = Sys.getenv("shiny_uid"), pwd = Sys.getenv("shiny_pwd")) #disconnect from db on stop @@ -80,7 +80,7 @@ sensor_issue_lookup <- dbGetQuery(poolConn, "select * from fieldwork.tbl_sensor_ #Sensor Serial Number List hobo_list_query <- "select inv.sensor_serial, inv.sensor_model, inv.date_purchased, ow.smp_id, ow.ow_suffix from fieldwork.viw_inventory_sensors_full inv - left join fieldwork.tbl_deployment d on d.inventory_sensors_uid = inv.inventory_sensors_uid AND d.collection_dtime_est is NULL + left join fieldwork.tbl_deployment d on d.inventory_sensors_uid = inv.inventory_sensors_uid AND d.collection_dtime is NULL left join fieldwork.tbl_ow ow on ow.ow_uid = d.ow_uid" hobo_list <- odbc::dbGetQuery(poolConn, hobo_list_query) sensor_serial <- hobo_list$sensor_serial @@ -244,14 +244,14 @@ server <- function(input, output, session) { rv$history_dt <- reactive(odbc::dbGetQuery(poolConn, history_query) %>% select(sensor_serial, smp_site_name, ow_suffix, type, term, - deployment_dtime_est, collection_dtime_est, + deployment_dtime, collection_dtime, project_name, notes) %>% - dplyr::mutate("Deployment Time" = lubridate::as_date(deployment_dtime_est), - "Collection Time" = lubridate::as_date(collection_dtime_est)) %>% + dplyr::mutate("Deployment Time" = lubridate::as_date(deployment_dtime), + "Collection Time" = lubridate::as_date(collection_dtime)) %>% dplyr::filter(sensor_serial == input$serial_no)) rv$sensor_history_display <- reactive(rv$history_dt() %>% - dplyr::select(-project_name,-deployment_dtime_est,-collection_dtime_est) %>% + dplyr::select(-project_name,-deployment_dtime,-collection_dtime) %>% rename("Serial Number" = "sensor_serial", "SMP ID/Site Name" = "smp_site_name", "Location" = "ow_suffix", @@ -509,15 +509,6 @@ server <- function(input, output, session) { } ) - #2.8 return values ------ - return( - list( - refresh_serial_no = reactive(rv$refresh_serial_no), - serial_no = reactive(input$serial_no), - sensor_serial = reactive(rv$sensor_table$sensor_serial) - ) - ) - # Add/Edit Sensor Test tab ---- rv$sensor_tests <- reactive(dbGetQuery(poolConn, "SELECT * FROM fieldwork.tbl_sensor_tests INNER JOIN fieldwork.tbl_sensor_test_type_lookup USING(test_type_lookup_uid)")) diff --git a/SensorHub.Rproj b/SensorHub.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/SensorHub.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX