Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visning av autoreport-data fra db-tabell #60

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
docker-compose.yml
renovate.json
dev/
^\.lintr$
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 17 additions & 7 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
)
),
Expand Down
23 changes: 9 additions & 14 deletions R/autoreport.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
}


Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions R/run_app.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' Run the rapadm Shiny Application
#'
#' @param browser Open app in browser window
#'
#' @return An object representing the rapadm app
#' @export

Expand Down
4 changes: 2 additions & 2 deletions man/calendar_autoreport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/run_app.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading