Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
Start app faster (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
yte0 authored Oct 27, 2020
1 parent d1f27dd commit f013cf8
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 37 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: qmongr
Title: Lightweight Quality Assessment of Norwegian Hospitals
Version: 0.18.3
Version: 0.18.4
Authors@R: c(
person(given = "Yohannes",
family = "Tesfay",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# qmongr 0.18.4

Show stuff from app faster, before data is loaded.

# qmongr 0.18.3

Favicon
Expand Down
2 changes: 1 addition & 1 deletion R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ add_external_resources <- function() {
rel = "stylesheet", type = "text/css", href = "www/fontawesome/css/v4-shims.min.css"
),
shiny::tags$link(
rel = "stylesheet", type = "text/css", href = "www/static/css/main.e193dd5b.chunk.css"
rel = "stylesheet", type = "text/css", href = "www/static/css/main.6aa8215a.chunk.css"
),
shiny::tags$script(src = "www/iframeResizer.contentWindow.min.js")
)
Expand Down
70 changes: 46 additions & 24 deletions R/quality_overview.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ NULL
#' @export
#' @importFrom shiny NS tagList
quality_overview_ui <- function(id) {
ns <- shiny::NS(id)
tagList(
shiny::tags$div(id = "root"),
shiny::htmlOutput(ns("json"))
shiny::tags$script(src = "www/static/js/2.295d41d0.chunk.js"),
shiny::tags$script(src = "www/static/js/main.9db8647e.chunk.js"),
shiny::tags$script(src = "www/static/js/runtime-main.7678d803.js")
)
}

Expand All @@ -32,28 +33,49 @@ quality_overview_ui <- function(id) {

quality_overview_server <- function(id) {
shiny::moduleServer(id, function(input, output, session) {
#All the processed data
app_data <- qmongr::get_data()
register_data <- app_data[["register_data"]]
grouped_by_hf <- app_data[["grouped_by_hf"]]
grouped_by_rhf <- app_data[["grouped_by_rhf"]]
grouped_by_hospital <- app_data[["grouped_by_hospital"]]
national_data <- app_data[["national_data"]]
tu_names <- app_data[["tu_names"]]
#data passed to js
output$json <- shiny::reactive({
paste(
"<script> var description = ",
jsonlite::toJSON(register_data$description, na = "null"), ";",
"var indicator_hosp =", jsonlite::toJSON(grouped_by_hospital), ";",
"var indicator_hf =", jsonlite::toJSON(grouped_by_hf), ";",
"var indicator_rhf =", jsonlite::toJSON(grouped_by_rhf), ";",
"var indicator_nat =", jsonlite::toJSON(national_data), ";",
"var tu_names =", jsonlite::toJSON(tu_names), ";",
"</script>",
shiny::tags$script(src = "www/static/js/2.e726af5f.chunk.js"),
shiny::tags$script(src = "www/static/js/main.8260245e.chunk.js"),
shiny::tags$script(src = "www/static/js/runtime-main.7678d803.js")
#All the processed data
app_data <- qmongr::get_data()
register_data <- app_data[["register_data"]]
grouped_by_hf <- app_data[["grouped_by_hf"]]
grouped_by_rhf <- app_data[["grouped_by_rhf"]]
grouped_by_hospital <- app_data[["grouped_by_hospital"]]
national_data <- app_data[["national_data"]]
tu_names <- app_data[["tu_names"]]

shiny::observe({
session$sendCustomMessage(
type = "tu_names",
message = jsonlite::toJSON(tu_names)
)
})
shiny::observe({
session$sendCustomMessage(
type = "description",
message = jsonlite::toJSON(register_data$description, na = "null")
)
})
shiny::observe({
session$sendCustomMessage(
type = "nation",
message = jsonlite::toJSON(national_data)
)
})
shiny::observe({
session$sendCustomMessage(
type = "hospital",
message = jsonlite::toJSON(grouped_by_hospital)
)
})
shiny::observe({
session$sendCustomMessage(
type = "hf",
message = jsonlite::toJSON(grouped_by_hf)
)
})
shiny::observe({
session$sendCustomMessage(
type = "rhf",
message = jsonlite::toJSON(grouped_by_rhf)
)
})
})
Expand Down

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

1 change: 1 addition & 0 deletions inst/app/www/static/css/main.6aa8215a.chunk.css.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion inst/app/www/static/css/main.e193dd5b.chunk.css.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/app/www/static/js/2.295d41d0.chunk.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion inst/app/www/static/js/2.e726af5f.chunk.js.map

This file was deleted.

2 changes: 0 additions & 2 deletions inst/app/www/static/js/main.8260245e.chunk.js

This file was deleted.

1 change: 0 additions & 1 deletion inst/app/www/static/js/main.8260245e.chunk.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions inst/app/www/static/js/main.9db8647e.chunk.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/app/www/static/js/main.9db8647e.chunk.js.map

Large diffs are not rendered by default.

Binary file modified tests/testthat/data/add_external_resources.rds
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/testthat/test-app_ui.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that("app_ui", {
config <- get_config()
ref_chr <- as.character(purrr::flatten(app_ui()))[4]
ref_chr <- as.character(purrr::flatten(app_ui()))[1]

expect_true(grepl("shiny-html-output", ref_chr, fixed = TRUE))
expect_true(grepl("head", ref_chr, fixed = TRUE))
})

0 comments on commit f013cf8

Please sign in to comment.