Skip to content

Commit

Permalink
Visning av autoreport-data fra db-tabell
Browse files Browse the repository at this point in the history
Tidligere var autoreport-data i database lagret som et json-objekt. Planen er å helller lagre det som flat tabell
  • Loading branch information
arnfinn committed Dec 2, 2024
1 parent 98d3d25 commit ae7245d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,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

0 comments on commit ae7245d

Please sign in to comment.