From d5c4c114f8987a31b75552e0c4ca10883c488f11 Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Thu, 20 Jul 2023 11:07:31 -0400 Subject: [PATCH 01/22] make community metric table entry consistent with build_comm_cards function --- inst/sql_queries/initialize_metric_table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/sql_queries/initialize_metric_table.sql b/inst/sql_queries/initialize_metric_table.sql index aae7b6430..c8f790c1e 100644 --- a/inst/sql_queries/initialize_metric_table.sql +++ b/inst/sql_queries/initialize_metric_table.sql @@ -12,4 +12,4 @@ VALUES ('bugs_status', 'Bugs Closure Rate', '% of the last 30 bugs closed', 1, 0, 'maintenance', 1), ('license', 'License', "Package's license", 0, 0, 'maintenance', 1), ('covr_coverage', 'Test Coverage', '% of objects tested', 1, 0, 'maintenance', 1), -('downloads_1yr', 'Downloads', 'Number of package downloads in the last year', 0, 0, 'community', 1); \ No newline at end of file +('downloads_last_year', 'Package Downloads', 'Number of downloads in last 12 months', 0, 0, 'community', 1); \ No newline at end of file From d8ab473706f8f2e832010efbf4f20248e40fef0c Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Thu, 20 Jul 2023 12:31:59 -0400 Subject: [PATCH 02/22] add test for id in metric names --- R/mod_metricBox.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/mod_metricBox.R b/R/mod_metricBox.R index a8ea4fa98..e9ca23264 100644 --- a/R/mod_metricBox.R +++ b/R/mod_metricBox.R @@ -31,6 +31,7 @@ metricBoxServer <- function(id, title, desc, value, icon_class = "text-success") { moduleServer(id, function(input, output, session) { + metric <- dbSelect("select * from metric", db_name = golem::get_golem_options('assessment_db_name')) # Render metric. output$metricBox_ui <- renderUI({ @@ -65,6 +66,9 @@ metricBoxServer <- function(id, title, desc, value, icon_class <- "text-info" } + # add asterisk to desc if the id is not in the metric table + desc = ifelse(id %in% metric$name, desc, paste0(desc, "*")) + # define some styles prior to building card card_style = "max-width: 400px; max-height: 250px; padding-left: 5%; padding-right: 5%;" # overflow-y: scroll; auto_font_out <- auto_font(value, txt_max = val_max_nchar, From dfc4c1fb198d4492661c3af25ea204f534b55abe Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Thu, 20 Jul 2023 12:32:39 -0400 Subject: [PATCH 03/22] add comment about asterisked cards --- R/mod_metricGrid.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/mod_metricGrid.R b/R/mod_metricGrid.R index f6d802e61..ccbe57615 100644 --- a/R/mod_metricGrid.R +++ b/R/mod_metricGrid.R @@ -37,7 +37,8 @@ metricGridServer <- function(id, metrics) { fluidRow(style = "padding-right: 10px", class = "card-group", map(column_vector_grid_split, - ~ column(width= 4,map(.x,~ metricBoxUI(session$ns(metrics()$name[.x]))))) + ~ column(width= 4,map(.x,~ metricBoxUI(session$ns(metrics()$name[.x]))))), + tags$em("* = Provided for additional context. Not a {riskmetric} assessment, so they will not impact risk score.") ) }) From 401cc4ffe3cdd0abf2d395b38aaec7d97a5fb1bb Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Thu, 20 Jul 2023 13:07:14 -0400 Subject: [PATCH 04/22] Remove plot_ly warning message about markers --- R/utils.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index 9b4f5fd16..3abb91c16 100644 --- a/R/utils.R +++ b/R/utils.R @@ -492,8 +492,9 @@ build_comm_plotly <- function(data = NULL, pkg_name = NULL) { x = ~day_month_year, y = ~downloads, name = "# Downloads", type = 'scatter', - mode = 'lines+markers', line = list(color = '#1F9BCF'), - marker = list(color = '#1F9BCF'), + mode = 'lines', + line = list(color = '#1F9BCF'), + # marker = list(color = '#1F9BCF'), hoverinfo = "text", text = ~glue::glue('No. of Downloads: {format(downloads, big.mark = ",")} {month} {year}')) %>% From 76fcb1c39a88670b58d722c142356386007d74c3 Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Thu, 20 Jul 2023 13:13:19 -0400 Subject: [PATCH 05/22] add NEWS.md entry --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index f0f8d860a..7887b789f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * Download source tarball when uploading package to database * Expand privileges to include commenting on metrics and packages (#564) * Allow users to explore source contents of package (#574) +* Identify non-riskmetric cards (#573) # riskassessment 1.0.0 From 4399dca8d7895f065ad3743cfbcdd33b222060a2 Mon Sep 17 00:00:00 2001 From: AARON-CLARK Date: Fri, 21 Jul 2023 09:02:48 -0400 Subject: [PATCH 06/22] Increment version number to 1.0.0.9009 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9dfbb60e7..0dd598017 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: riskassessment Title: A web app designed to interface with the `riskmetric` package -Version: 1.0.0.9008 +Version: 1.0.0.9009 Authors@R: c( person("Aaron", "Clark", role = c("aut", "cre"), email = "aaron.clark@biogen.com"), person("Robert", "Krajcik", role = "aut", email = "robert.krajcik@biogen.com"), From eacb0eca6c3d6121205d2e1b597359783917ae49 Mon Sep 17 00:00:00 2001 From: Robert-Krajcik <75215958+Robert-Krajcik@users.noreply.github.com> Date: Fri, 21 Jul 2023 10:56:23 -0400 Subject: [PATCH 07/22] Update R/mod_metricGrid.R Co-authored-by: Aaron Clark --- R/mod_metricGrid.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/mod_metricGrid.R b/R/mod_metricGrid.R index f9a13b356..6a4b73f2a 100644 --- a/R/mod_metricGrid.R +++ b/R/mod_metricGrid.R @@ -38,7 +38,7 @@ metricGridServer <- function(id, metrics) { fluidRow(style = "padding-right: 10px", class = "card-group", map(column_vector_grid_split, ~ column(width= 4,map(.x,~ metricBoxUI(session$ns(metrics()$name[.x]))))), - tags$em("* = Provided for additional context. Not a {riskmetric} assessment, so they will not impact risk score.") + tags$em("* Provided for additional context. Not a {riskmetric} assessment, so this measure will not impact the risk score.") ) }) From 9029d73b406851d09279b508fed2f9b72783d83e Mon Sep 17 00:00:00 2001 From: Robert-Krajcik <75215958+Robert-Krajcik@users.noreply.github.com> Date: Fri, 21 Jul 2023 10:57:31 -0400 Subject: [PATCH 08/22] Update inst/sql_queries/initialize_metric_table.sql Co-authored-by: Aaron Clark --- inst/sql_queries/initialize_metric_table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/sql_queries/initialize_metric_table.sql b/inst/sql_queries/initialize_metric_table.sql index c8f790c1e..266976e5c 100644 --- a/inst/sql_queries/initialize_metric_table.sql +++ b/inst/sql_queries/initialize_metric_table.sql @@ -12,4 +12,4 @@ VALUES ('bugs_status', 'Bugs Closure Rate', '% of the last 30 bugs closed', 1, 0, 'maintenance', 1), ('license', 'License', "Package's license", 0, 0, 'maintenance', 1), ('covr_coverage', 'Test Coverage', '% of objects tested', 1, 0, 'maintenance', 1), -('downloads_last_year', 'Package Downloads', 'Number of downloads in last 12 months', 0, 0, 'community', 1); \ No newline at end of file +('downloads_1yr ', 'Package Downloads', 'Number of downloads in last 12 months', 0, 0, 'community', 1); \ No newline at end of file From d5d9629915e13503ee4cba8fce10d4456f5f38ac Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Fri, 21 Jul 2023 10:59:00 -0400 Subject: [PATCH 09/22] revert plotly::plot_ly to use lines+markers --- R/utils.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index a5520915e..a257e01ab 100644 --- a/R/utils.R +++ b/R/utils.R @@ -638,9 +638,9 @@ build_comm_plotly <- function(data = NULL, pkg_name = NULL) { x = ~day_month_year, y = ~downloads, name = "# Downloads", type = 'scatter', - mode = 'lines', + mode = 'lines+markers', line = list(color = '#1F9BCF'), - # marker = list(color = '#1F9BCF'), + marker = list(color = '#1F9BCF'), hoverinfo = "text", text = ~glue::glue( 'No. of Downloads: {format(downloads, big.mark = ",")} From 9e9e8e4c09ea325f7f7730226b2625c48eb91cf5 Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Fri, 21 Jul 2023 11:06:20 -0400 Subject: [PATCH 10/22] use title instead of desc for flagging non-riskmetric cards --- R/mod_metricBox.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/mod_metricBox.R b/R/mod_metricBox.R index 71c16906c..2f437464c 100644 --- a/R/mod_metricBox.R +++ b/R/mod_metricBox.R @@ -67,7 +67,7 @@ metricBoxServer <- function(id, title, desc, value, } # add asterisk to desc if the id is not in the metric table - desc = ifelse(id %in% metric$name, desc, paste0(desc, "*")) + title = ifelse(title %in% metric$long_name, title, paste0(title, "*")) # define some styles prior to building card card_style <- "max-width: 400px; max-height: 250px; padding-left: 5%; padding-right: 5%;" # overflow-y: scroll; From 657bf612adf6091bd2875c81995218230fcdb2ed Mon Sep 17 00:00:00 2001 From: Robert-Krajcik <75215958+Robert-Krajcik@users.noreply.github.com> Date: Mon, 24 Jul 2023 09:28:36 -0400 Subject: [PATCH 11/22] Update inst/sql_queries/initialize_metric_table.sql Co-authored-by: Aaron Clark --- inst/sql_queries/initialize_metric_table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/sql_queries/initialize_metric_table.sql b/inst/sql_queries/initialize_metric_table.sql index 266976e5c..67dab095c 100644 --- a/inst/sql_queries/initialize_metric_table.sql +++ b/inst/sql_queries/initialize_metric_table.sql @@ -12,4 +12,4 @@ VALUES ('bugs_status', 'Bugs Closure Rate', '% of the last 30 bugs closed', 1, 0, 'maintenance', 1), ('license', 'License', "Package's license", 0, 0, 'maintenance', 1), ('covr_coverage', 'Test Coverage', '% of objects tested', 1, 0, 'maintenance', 1), -('downloads_1yr ', 'Package Downloads', 'Number of downloads in last 12 months', 0, 0, 'community', 1); \ No newline at end of file +('downloads_1yr', 'Package Downloads', 'Number of downloads in last 12 months', 0, 0, 'community', 1); \ No newline at end of file From 9af81f6ca815cb1a686f64bf4437d08d8e154658 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Fri, 11 Aug 2023 11:09:26 -0400 Subject: [PATCH 12/22] Add back developer credentials --- R/run_app.R | 21 +++++++++++++++++++++ R/utils_startup.R | 2 ++ 2 files changed, 23 insertions(+) diff --git a/R/run_app.R b/R/run_app.R index cac789b79..6f201d1d7 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -43,6 +43,25 @@ run_app <- function( } } + # Note that this overrides other credential set up + login_creds <- NULL + pre_auth_user <- NULL + if (isFALSE(getOption("golem.app.prod"))) { + arg_lst <- as.list(match.call()) + + login_creds <- list(user_id = "", + user_pwd = "cxk1QEMYSpYcrNB") + if (!is.null(arg_lst$pre_auth_user)) { + pre_auth_user <- arg_lst$pre_auth_user + if (isTRUE(pre_auth_user) || pre_auth_user == "admin") { + login_creds$user_id <- "admin" + } else { + login_creds$user_id <- pre_auth_user + } + credentials_db_name <- gsub("\\.sqlite", "_dev\\.sqlite", credentials_db_name) + } + } + # Run the app with_golem_options( app = shinyApp( @@ -56,6 +75,8 @@ run_app <- function( golem_opts = list(app_version = app_ver, credentials_db_name = credentials_db_name, assessment_db_name = assessment_db_name, + pre_auth_user = pre_auth_user, + login_creds = login_creds, decision_categories = decision_categories, ...) ) diff --git a/R/utils_startup.R b/R/utils_startup.R index e473d26be..d2fdc2d66 100644 --- a/R/utils_startup.R +++ b/R/utils_startup.R @@ -213,6 +213,8 @@ initialize_raa <- function(assess_db, cred_db, decision_cat) { check_credentials(db_config[["credentials"]]) + if (isFALSE(getOption("golem.app.prod")) && !is.null(golem::get_golem_options('pre_auth_user')) && !file.exists(credentials_db)) create_credentials_dev_db(credentials_db) + # Create package db & credentials db if it doesn't exist yet. if(!file.exists(assessment_db)) create_db(assessment_db) if(!file.exists(credentials_db)) { From d36ed1a58ce0342391bb8a57ee07ecd4c6c93e42 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Fri, 11 Aug 2023 11:14:47 -0400 Subject: [PATCH 13/22] Initialize developmental branch of V2.0.0 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d6c0458cc..95b1b2de5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: riskassessment Title: A web app designed to interface with the `riskmetric` package -Version: 2.0.0 +Version: 2.0.0.9000 Authors@R: c( person("Aaron", "Clark", role = c("aut", "cre"), email = "aaron.clark@biogen.com"), person("Robert", "Krajcik", role = "aut", email = "robert.krajcik@biogen.com"), diff --git a/NEWS.md b/NEWS.md index 9dd973553..47ab01219 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# riskassessment (development version) + # riskassessment 2.0.0 ### Enhancements From 004db7f48954859130fb972d56b73ce0033a36fe Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Mon, 14 Aug 2023 09:44:08 -0400 Subject: [PATCH 14/22] issue msg if any non-metric cards exist, excluding databaseView --- R/mod_metricBox.R | 8 +++++--- R/mod_metricGrid.R | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/R/mod_metricBox.R b/R/mod_metricBox.R index 2f437464c..66c883b4f 100644 --- a/R/mod_metricBox.R +++ b/R/mod_metricBox.R @@ -21,7 +21,7 @@ metricBoxUI <- function(id) { #' #' #' @import dplyr -#' @importFrom stringr str_sub +#' @importFrom stringr str_sub str_extract #' @importFrom glue glue #' @keywords internal #' @@ -66,8 +66,10 @@ metricBoxServer <- function(id, title, desc, value, icon_class <- "text-info" } - # add asterisk to desc if the id is not in the metric table - title = ifelse(title %in% metric$long_name, title, paste0(title, "*")) + # add asterisk to title if it is not in the metric table + # skip databaseView cards + title = if_else(stringr::str_extract(session$ns(id), "\\w+") != "databaseView" + & !title %in% metric$long_name, paste0(title, "*"), title) # define some styles prior to building card card_style <- "max-width: 400px; max-height: 250px; padding-left: 5%; padding-right: 5%;" # overflow-y: scroll; diff --git a/R/mod_metricGrid.R b/R/mod_metricGrid.R index 16e30dd1d..f93858b5c 100644 --- a/R/mod_metricGrid.R +++ b/R/mod_metricGrid.R @@ -17,21 +17,24 @@ metricGridUI <- function(id) { #' @keywords internal #' #' @import dplyr +#' @importFrom stringr str_extract metricGridServer <- function(id, metrics) { moduleServer(id, function(input, output, session) { + metric <- dbSelect("select * from metric", db_name = golem::get_golem_options('assessment_db_name')) output$grid <- renderUI({ req(nrow(metrics()) > 1) # need at least two cards to make a metric grid UI - + columns <- 3 - rows <- ceiling(nrow(metrics()) / columns) column_vector_grid_split <- split(seq_len(nrow(metrics())), rep(1:columns, length.out = nrow(metrics()))) fluidRow(style = "padding-right: 10px", class = "card-group", map(column_vector_grid_split, ~ column(width= 4,map(.x,~ metricBoxUI(session$ns(metrics()$name[.x]))))), - tags$em("* Provided for additional context. Not a {riskmetric} assessment, so this measure will not impact the risk score.") + if(any(!(metrics()$title %in% metric$long_name)) & stringr::str_extract(session$ns(id), "\\w+") != "databaseView") { + tags$em("* Provided for additional context. Not a {riskmetric} assessment, so this measure will not impact the risk score.") + } ) }) From 279b28dc9a0dd4a2acb1e5ddeb8c96a5c84df21e Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Mon, 14 Aug 2023 10:12:14 -0400 Subject: [PATCH 15/22] update roxygen2 comment for type on mod_metricBox --- R/mod_metricBox.R | 1 + man/metricBoxServer.Rd | 2 ++ 2 files changed, 3 insertions(+) diff --git a/R/mod_metricBox.R b/R/mod_metricBox.R index 66c883b4f..8fc34f28a 100644 --- a/R/mod_metricBox.R +++ b/R/mod_metricBox.R @@ -18,6 +18,7 @@ metricBoxUI <- function(id) { #' @param succ_icon icon used if is_true. #' @param unsucc_icon icon used if not is_true. #' @param icon_class string type of icon +#' @param type string to color the icon ("information" or "danger") #' #' #' @import dplyr diff --git a/man/metricBoxServer.Rd b/man/metricBoxServer.Rd index ea29e31d3..75b3d6def 100644 --- a/man/metricBoxServer.Rd +++ b/man/metricBoxServer.Rd @@ -35,6 +35,8 @@ metricBoxServer( \item{unsucc_icon}{icon used if not is_true.} \item{icon_class}{string type of icon} + +\item{type}{string to color the icon ("information" or "danger")} } \description{ Server logic for the 'Metric Box' module From 3c6873b1521c52bd12cc04a7e8febc38dd6d02a1 Mon Sep 17 00:00:00 2001 From: Robert Krajcik Date: Mon, 14 Aug 2023 12:46:30 -0400 Subject: [PATCH 16/22] add code to reportHtml.Rmd, also update params for pdf and docx --- R/mod_downloadHandler.R | 5 ++++- inst/report_downloads/reportDocx.Rmd | 1 + inst/report_downloads/reportHtml.Rmd | 19 +++++++++++++++---- inst/report_downloads/reportPdf.Rmd | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/R/mod_downloadHandler.R b/R/mod_downloadHandler.R index 428d696f9..a8f049047 100644 --- a/R/mod_downloadHandler.R +++ b/R/mod_downloadHandler.R @@ -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( @@ -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/ diff --git a/inst/report_downloads/reportDocx.Rmd b/inst/report_downloads/reportDocx.Rmd index 16f44b79d..837142da6 100644 --- a/inst/report_downloads/reportDocx.Rmd +++ b/inst/report_downloads/reportDocx.Rmd @@ -26,6 +26,7 @@ params: com_metrics: NA com_metrics_raw: NA downloads_plot_data: NA + metric_tbl: NA --- diff --git a/inst/report_downloads/reportHtml.Rmd b/inst/report_downloads/reportHtml.Rmd index 157ca06e0..d48153dbb 100644 --- a/inst/report_downloads/reportHtml.Rmd +++ b/inst/report_downloads/reportHtml.Rmd @@ -29,6 +29,7 @@ params: com_metrics: NA com_metrics_raw: NA downloads_plot_data: NA + metric_tbl: NA ---