diff --git a/.Rbuildignore b/.Rbuildignore index 9eb783f..976b7d6 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,3 +6,4 @@ docker-compose.yml renovate.json dev/ +^\.lintr$ diff --git a/DESCRIPTION b/DESCRIPTION index f012ba9..4078b85 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,10 +21,11 @@ Description: Display configuration and monitoring logs and scheduled reports at License: GPL (>= 3) Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.1 +RoxygenNote: 7.3.2 Imports: bslib, dplyr, + DT, ggplot2, magrittr, rapbase, diff --git a/R/app_server.R b/R/app_server.R index f3950a0..06435e4 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -130,22 +130,32 @@ app_server <- function(input, output, session) { ) # Autoreport - ar <- rapbase::readAutoReportData() + ar <- rapbase::readAutoReportData(target = "db") far <- shiny::reactive({ shiny::req(input$fpackage, input$ftype, input$fowner, input$forganization) far <- ar if (input$fpackage != "no filter") { - far <- rapbase::filterAutoRep(far, "package", input$fpackage) + far <- rapbase::filterAutoRep( + far, + "package", + input$fpackage, + target = "db" + ) } if (input$ftype != "no filter") { - far <- rapbase::filterAutoRep(far, "type", input$ftype) + far <- rapbase::filterAutoRep(far, "type", input$ftype, target = "db") } if (input$fowner != "no filter") { - far <- rapbase::filterAutoRep(far, "owner", input$fowner) + far <- rapbase::filterAutoRep(far, "owner", input$fowner, target = "db") } if (input$forganization != "no filter") { - far <- rapbase::filterAutoRep(far, "organization", input$forganization) + far <- rapbase::filterAutoRep( + far, + "organization", + input$forganization, + target = "db" + ) } far }) @@ -183,8 +193,8 @@ app_server <- function(input, output, session) { plot(calendar_autoreport(far())) }) - output$autoreport_data <- shiny::renderText({ - yaml::as.yaml(far()) + output$autoreport_data <- DT::renderDT({ + far() }) # Staging diff --git a/R/app_ui.R b/R/app_ui.R index e58ae1a..5ba75bc 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -102,7 +102,7 @@ app_ui <- function() { shiny::h2("Auto reports running one year from now"), shiny::plotOutput("calendar"), shiny::h2("Auto report raw data"), - shiny::verbatimTextOutput("autoreport_data") + shiny::dataTableOutput("autoreport_data") ) ) ), diff --git a/R/autoreport.R b/R/autoreport.R index c3854f7..8fa8bf3 100644 --- a/R/autoreport.R +++ b/R/autoreport.R @@ -12,12 +12,7 @@ #' unique_autoreport(ar, "type") # c("A", "B") unique_autoreport <- function(data, entity) { - vals <- vector(mode = "character") - for (i in seq_len(length(data))) { - vals <- c(vals, data[[i]][[entity]]) - } - - unique(vals) + unique(data[[entity]]) } @@ -34,16 +29,16 @@ unique_autoreport <- function(data, entity) { calendar_autoreport <- function(data, pointRangeMax = 0) { - if (length(data) == 0) { - runDayOfYear <- vector() - } else if (length(data) == 1) { - runDayOfYear <- data[[1]]$runDayOfYear - } else { - runDayOfYear <- unlist( - sapply(data, "[[", "runDayOfYear"), - use.names = FALSE + + runDayOfYear <- vector() + + for (oneRun in data$runDayOfYear) { + runDayOfYear <- c( + runDayOfYear, + as.vector(as.integer(strsplit(oneRun, ",")[[1]])) ) } + stopifnot(is.integer(pointRangeMax) || pointRangeMax == 0) startDate <- Sys.Date() - as.numeric(strftime(Sys.Date(), format = "%d")) + 1 diff --git a/R/run_app.R b/R/run_app.R index c65baee..1b36a1e 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -1,5 +1,7 @@ #' Run the rapadm Shiny Application #' +#' @param browser Open app in browser window +#' #' @return An object representing the rapadm app #' @export diff --git a/man/calendar_autoreport.Rd b/man/calendar_autoreport.Rd index 52a1970..02715c2 100644 --- a/man/calendar_autoreport.Rd +++ b/man/calendar_autoreport.Rd @@ -11,8 +11,8 @@ calendar_autoreport(data, pointRangeMax = 0) run. May well contain repeating values} \item{pointRangeMax}{Integer to provide static range of geom_point as -\code{range(1:pointRangeMax)}. If set to 0 (default) the range of current data will be -used.} +\code{range(1:pointRangeMax)}. If set to 0 (default) the range of +current data will be used.} } \value{ a (gg)plot object diff --git a/man/run_app.Rd b/man/run_app.Rd index c66d4b7..3c3a905 100644 --- a/man/run_app.Rd +++ b/man/run_app.Rd @@ -4,7 +4,10 @@ \alias{run_app} \title{Run the rapadm Shiny Application} \usage{ -run_app() +run_app(browser = FALSE) +} +\arguments{ +\item{browser}{Open app in browser window} } \value{ An object representing the rapadm app