Skip to content

Commit

Permalink
add code to reportHtml.Rmd, also update params for pdf and docx
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Krajcik committed Aug 14, 2023
1 parent 279b28d commit 3c6873b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion R/mod_downloadHandler.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ mod_downloadHandler_server <- function(id, pkgs, user, metric_weights){
comm_data <- get_comm_data(this_pkg)
comm_cards <- build_comm_cards(comm_data)
downloads_plot <- build_comm_plotly(comm_data)
metric_tbl <- dbSelect("select * from metric", db_name = golem::get_golem_options('assessment_db_name'))


# Render the report, passing parameters to the rmd file.
rmarkdown::render(
Expand All @@ -256,7 +258,8 @@ mod_downloadHandler_server <- function(id, pkgs, user, metric_weights){
maint_metrics = mm_data,
com_metrics = comm_cards,
com_metrics_raw = comm_data,
downloads_plot_data = downloads_plot
downloads_plot_data = downloads_plot,
metric_tbl = metric_tbl
)
)
fs <- c(fs, path) # Save all the reports/
Expand Down
1 change: 1 addition & 0 deletions inst/report_downloads/reportDocx.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ params:
com_metrics: NA
com_metrics_raw: NA
downloads_plot_data: NA
metric_tbl: NA
---

<!-- ![](raa-image.png){style="position:float-right; width:63px; height:52px;"} -->
Expand Down
19 changes: 15 additions & 4 deletions inst/report_downloads/reportHtml.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ params:
com_metrics: NA
com_metrics_raw: NA
downloads_plot_data: NA
metric_tbl: NA
---

<style type="text/css">
Expand All @@ -52,13 +53,15 @@ knitr::opts_chunk$set(echo = F, fig.width = 5.5, fig.height = 3.4)


```{r functions, echo=FALSE, include=FALSE, message=FALSE, warning=FALSE}
createCard <- function(title, desc, value, is_perc = FALSE, is_url = FALSE,
succ_icon = "check", unsucc_icon = "times",
icon_class = "text-success"){
# A str length of 41 chars tends to wrap to two rows and look quite nice
val_max_nchar <- 31
is_true <- !(value %in% c(0, "pkg_metric_error", "NA", "", 'FALSE'))
if(value %in% c("pkg_metric_error", "NA"))
value <- "Not found"
else if(is_perc)
Expand All @@ -83,6 +86,11 @@ createCard <- function(title, desc, value, is_perc = FALSE, is_url = FALSE,
icon_name <- "percent"
icon_class <- "text-info"
}
# add asterisk to title if it is not in the metric table
# There are no databaseView cards here.
title = if_else(!title %in% metric_tbl$long_name, paste0(title, "*"), title)
# overflow-y: scroll;
card_style <- "max-width: 400px; max-height: 250px; padding-left: 5%; padding-right: 5%;"
auto_font_out <- auto_font(value, txt_max = val_max_nchar,
Expand All @@ -108,7 +116,7 @@ createCard <- function(title, desc, value, is_perc = FALSE, is_url = FALSE,
createGrid <- function(metrics){
col_width <- 3
fluidRow(style = "padding-right: 10px", class = "card-group",
column(width = 4, {
lapply(X = seq(1, nrow(metrics), col_width), function(i){
Expand Down Expand Up @@ -148,8 +156,11 @@ createGrid <- function(metrics){
succ_icon = metrics$succ_icon[i],
icon_class = metrics$icon_class[i])
})
})
)
}),
if(any(!(metrics$title %in% metric$long_name))) {
tags$em("* Provided for additional context. Not a {riskmetric} assessment, so this measure will not impact the risk score.")
}
)
}
```

Expand Down
1 change: 1 addition & 0 deletions inst/report_downloads/reportPdf.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ params:
com_metrics: NA
com_metrics_raw: NA
downloads_plot_data: NA
metric_tbl: NA
---

<style type="text/css">
Expand Down

0 comments on commit 3c6873b

Please sign in to comment.