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

Dep Card: Decision Summary #787

Merged
merged 25 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
31fbfa5
update some stuff...
aclark02-arcus Jun 4, 2024
639ea9d
Merge branch 'ac-774' into ac-774-p2
aclark02-arcus Jun 4, 2024
cf9fa21
remove redundant line of code
aclark02-arcus Jun 4, 2024
4ff9eea
add vignette and fix issues with code to get the dep card rendering c…
aclark02-arcus Jun 5, 2024
ca98179
update loaded2_db object in test-packageDependencies.R to include dec…
aclark02-arcus Jun 5, 2024
4cc7ed9
Merge branch 'dev' into ac-774-p2
aclark02-arcus Jun 5, 2024
ded09af
change layout of pcakge deps tab
aclark02-arcus Jun 5, 2024
5e5de05
Update package dependency layout in reports and fix redundancy in dow…
aclark02-arcus Jun 5, 2024
ceff7a5
remove old redundant code
aclark02-arcus Jun 5, 2024
ce79874
fix one failing test and add global variables
aclark02-arcus Jun 5, 2024
7e3d99b
update wordlist
aclark02-arcus Jun 5, 2024
ffe957c
remove rougue tibble::tibble() call, and use dplyr:: prefix there and…
aclark02-arcus Jun 5, 2024
75b844d
Re-build manifest file
actions-user Jun 5, 2024
07cf149
fix type class in html reports
aclark02-arcus Jun 6, 2024
3c1e88f
reconfigure pdf report and get_depends_data()
aclark02-arcus Jun 6, 2024
81a0399
fix global var without binding
aclark02-arcus Jun 6, 2024
5c03dda
fix merge conflict with dev
aclark02-arcus Jun 6, 2024
45c824d
Re-build manifest file
actions-user Jun 6, 2024
ca81eaa
update get_metric_data() to include 'type' column
aclark02-arcus Jun 10, 2024
88d7fff
Merge branch 'ac-774-p2' of https://github.com/pharmaR/riskassessment…
aclark02-arcus Jun 10, 2024
1e5bcc1
fix missing 'type' field in mm_data
aclark02-arcus Jun 10, 2024
7e98214
Re-build manifest file
actions-user Jun 10, 2024
2b739e2
Increment version number to 3.0.0.9024
aclark02-arcus Jun 12, 2024
eeebb1e
remove print statements
aclark02-arcus Jun 12, 2024
e45bb6a
Re-build manifest file
actions-user Jun 12, 2024
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: riskassessment
Title: A web app designed to interface with the `riskmetric` package
Version: 3.0.0.9023
Version: 3.0.0.9024
Authors@R: c(
person("Aaron", "Clark", role = c("aut", "cre"), email = "[email protected]"),
person("Robert", "Krajcik", role = "aut", email = "[email protected]"),
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
* Updated 'About' page to highlight individual contributors on the project, leveraging `bslib` cards.
* Allow users to specify decisions in the CSV upload file (#663)
* Fix bug causing application to crash when trying to delete zero packages (#781)
* Add `Decision` column to Package Dependencies tab so that users (#774)
* Add `Decision` column to Package Dependencies tab's table output (#774)
* Add `Decision Summary` card to Package Dependencies tab (#774)



Expand Down
11 changes: 11 additions & 0 deletions R/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ utils::globalVariables(
'day_month_year',
'decision',
'decision_by',
'dec_cat',
'dec_cat_sum',
'dec_cat_pct',
'dec_cat_disp',
'dec_id',
'decision_cat_disp',
'decision_cat_sum',
'decision_date',
'decision_id',
'description',
'description',
'downloads',
Expand All @@ -60,6 +66,8 @@ utils::globalVariables(
'Name',
'new_role',
'new_weight',
'non_base',
'non_base_sum',
'old_role',
'package',
'Package',
Expand All @@ -84,6 +92,9 @@ utils::globalVariables(
'upld_cat_disp',
'upld_cat_pct',
'upld_cat_sum',
'upld_non_base',
'upld_non_base_sum',
'upld_non_base_pct',
'upper_limit',
'user_role',
'Version',
Expand Down
20 changes: 7 additions & 13 deletions R/mod_downloadHandler.R
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,15 @@ mod_downloadHandler_server <- function(id, pkgs, user, metric_weights){
downloads_plot <- build_comm_plotly(comm_data)
metric_tbl <- dbSelect("select * from metric", db_name = golem::get_golem_options('assessment_db_name'))

dep_metrics <- get_depends_data(this_pkg, session$userData$suggests(), db_name = golem::get_golem_options("assessment_db_name"))
dep_metrics <- get_depends_data(this_pkg,
session$userData$suggests(),
db_name = golem::get_golem_options("assessment_db_name"),
loaded2_db = session$userData$loaded2_db(),
repo_pkgs = session$userData$repo_pkgs()
)

dep_cards <- build_dep_cards(data = dep_metrics, loaded = session$userData$loaded2_db()$name, toggled = session$userData$suggests())

dep_table <-
if (nrow(dep_metrics) == 0) {
dplyr::tibble(package = character(), type = character(), version = character(), score = character(), decision = character())
} else {
purrr::map_df(dep_metrics$name, ~get_versnScore(.x, session$userData$loaded2_db(), session$userData$repo_pkgs())) %>%
right_join(dep_metrics, by = "name") %>%
select(package, type, version, score, decision) %>%
mutate(decision = if_else(is.na(decision) | toupper(decision) == "NA", "", decision)) %>%
arrange(package, type) %>%
distinct()
}

# Render the report, passing parameters to the rmd file.
rmarkdown::render(
Expand All @@ -321,7 +315,7 @@ mod_downloadHandler_server <- function(id, pkgs, user, metric_weights){
com_metrics_raw = comm_data,
downloads_plot_data = downloads_plot,
dep_cards = dep_cards,
dep_table = dep_table,
dep_table = dep_metrics |> select(-decision_id),
metric_tbl = metric_tbl
)
)
Expand Down
189 changes: 113 additions & 76 deletions R/mod_packageDependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,62 @@ packageDependenciesServer <- function(id, selected_pkg, user, credentials, paren
req(pkgref())
tryCatch(
expr = {
depends(pkgref()$dependencies[[1]] %>% dplyr::as_tibble() %>%
mutate(package = stringr::str_replace(package, "\n", " ")) %>%
mutate(name = stringr::str_extract(package, "^((([[A-z]]|[.][._[A-z]])[._[A-z0-9]]*)|[.])")))
deep_ends <- pkgref()$dependencies[[1]] %>% dplyr::as_tibble() %>%
mutate(package = stringr::str_replace(package, "\n", " ")) %>%
mutate(name = stringr::str_extract(package, "^((([[A-z]]|[.][._[A-z]])[._[A-z0-9]]*)|[.])"))

deps_decision_data <- purrr::map_df(deep_ends$name, ~get_versnScore(.x, session$userData$loaded2_db(), session$userData$repo_pkgs()))
if(nrow(deps_decision_data) == 0) {
deps_w_decision <- dplyr::tibble(name = character(0), version = character(0),
score = character(0), decision = character(0), decision_id = character(0))
} else {
deps_w_decision <- deps_decision_data
}
depends(
deps_w_decision %>%
right_join(deep_ends, by = "name") %>%
select(package, type, name, version, score, decision, decision_id) %>%
arrange(name, type) %>%
distinct()
)
},
error = function(e) {
msg <- paste("Detailed dependency information is not available for package", selected_pkg$name())
rlang::warn(msg)
rlang::warn(paste("info:", e))
depends(dplyr::tibble(package = character(0), type = character(0), name = character(0)))
depends(dplyr::tibble(package = character(0), type = character(0), name = character(0),
version = character(0), score = character(0), decision = character(0),
decision_id = character(0)))
}
)
tryCatch(
expr = {
suggests(pkgref()$suggests[[1]] %>% dplyr::as_tibble()%>%
mutate(package = stringr::str_replace(package, "\n", " ")) %>%
mutate(name = stringr::str_extract(package, "^((([[A-z]]|[.][._[A-z]])[._[A-z0-9]]*)|[.])")))
shrug_jests <- pkgref()$suggests[[1]] %>% dplyr::as_tibble()%>%
mutate(package = stringr::str_replace(package, "\n", " ")) %>%
mutate(name = stringr::str_extract(package, "^((([[A-z]]|[.][._[A-z]])[._[A-z0-9]]*)|[.])"))

sugg_decision_data <- purrr::map_df(shrug_jests$name, ~get_versnScore(.x, session$userData$loaded2_db(), session$userData$repo_pkgs()))
if(nrow(sugg_decision_data) == 0) {
suggs_w_decision <- dplyr::tibble(name = character(0), version = character(0),
score = character(0), decision = character(0), decision_id = character(0))
} else {
suggs_w_decision <- sugg_decision_data
}
suggests(
suggs_w_decision %>%
right_join(shrug_jests, by = "name") %>%
select(package, type, name, version, score, decision, decision_id) %>%
arrange(name, type) %>%
distinct()
)
},
error = function(e) {
msg <- paste("Detailed suggests information is not available for package", selected_pkg$name())
rlang::warn(msg)
rlang::warn(paste("info:", e))
suggests(dplyr::tibble(package = character(0), type = character(0), name = character(0)))
suggests(dplyr::tibble(package = character(0), type = character(0), name = character(0),
version = character(0), score = character(0), decision = character(0),
decision_id = character(0)))
}
)
# this is so the dependencies is also a 0x2 tibble like suggests
Expand Down Expand Up @@ -115,10 +149,10 @@ packageDependenciesServer <- function(id, selected_pkg, user, credentials, paren
if (toggled() == 0L || nrow(suggests()) == 0) {
return(dplyr::tibble(package = character(0), type = character(0), name = character(0)))
} else {
pkginfo <- suggests() %>% as_tibble()
pkginfo <- suggests() %>% dplyr::as_tibble()
}
} else {
pkginfo <- dplyr::bind_rows(depends(), suggests()) %>% as_tibble()
pkginfo <- dplyr::bind_rows(depends(), suggests()) %>% dplyr::as_tibble()
}
pkginfo <- pkginfo %>%
mutate(package = stringr::str_replace(package, "\n", " ")) %>%
Expand All @@ -139,10 +173,9 @@ packageDependenciesServer <- function(id, selected_pkg, user, credentials, paren
}
}

purrr::map_df(pkginfo$name, ~get_versnScore(.x, session$userData$loaded2_db(), session$userData$repo_pkgs())) %>%
right_join(pkginfo, by = "name") %>%
pkginfo %>%
select(package, type, name, version, score, decision) %>%
arrange(name, type) %>%
arrange(name, type) %>%
distinct()

}, ignoreInit = TRUE)
Expand Down Expand Up @@ -198,74 +231,78 @@ packageDependenciesServer <- function(id, selected_pkg, user, credentials, paren
br(), br(),
div(id = "dep_infoboxes", metricGridUI(NS(id, 'metricGrid'))),
br(),
fluidRow(
column(4,
tags$strong(
glue::glue("First-order dependencies for package: ", {selected_pkg$name()})
)
div(style = "padding-left: 40px;",
HTML(glue::glue("<span class='h3 center txtasis'>FIRST-ORDER DEPENDENDENCIES OF {selected_pkg$name()}</span><br>")),
br(),
fluidRow(
column(4, ""),
column(3,
shinyWidgets::materialSwitch(
inputId = ns("incl_suggests"),
label = "Include Suggests",
value = toggled(),
inline = TRUE,
status = "success"
)
),
column(2,
if (pkg_updates$render_upload) {
actionButton(
inputId = ns("update_all_packages"),
label = "Upload all",
icon = icon("fas fa-upload", class = "fa-regular", lib = "font-awesome"),
size = "xs",
style = "height:30px; padding-top:1px;"
)
}
)
),
column(2,
shinyWidgets::materialSwitch(
inputId = ns("incl_suggests"),
label = "Include Suggests",
value = toggled(),
inline = TRUE,
status = "success"
)
br(),
# remove DT "search:" rectangle
tags$head(
tags$style(type = "text/css", ".dataTables_filter {display: none; }")
),
column(2,
if (pkg_updates$render_upload) {
actionButton(
inputId = ns("update_all_packages"),
label = "Upload all",
icon = icon("fas fa-upload", class = "fa-regular", lib = "font-awesome"),
size = "xs",
style = "height:30px; padding-top:1px;"
)
}
)
),
br(),
# remove DT "search:" rectangle
tags$head(
tags$style(type = "text/css", ".dataTables_filter {display: none; }")
),
fluidRow(
column(
width = 8,
DT::renderDataTable(server = FALSE, {
datatable_custom(data_table(), custom_dom = "lftpi")
})
)
),
br(), br(),
h3(glue::glue("All reverse Dependencies: {length(revdeps())}"), style = "text-align: left;"),
br(),
fluidRow(
column(
width = 8,
h4(glue::glue("Reverse Dependencies available in database: {nrow(table_revdeps_local()) %||% 0}"), style = "text-align: left;"),
br(),
DT::renderDataTable({
datatable_custom(
table_revdeps_local() |> select(-decision_id),
colnames = c("Package", "Version", "Score", "Decision", "Review Package"),
hide_names = NULL
fluidRow(
column(
width = 9,
DT::renderDataTable(server = FALSE, {
datatable_custom(data_table(), custom_dom = "lftpi")
})
)
),
br(), br(),

HTML(glue::glue("<span class='h3 center txtasis'>REVERSE DEPENDENDENCIES OF {selected_pkg$name()}</span><br>")),
# h3("Reverse Dependencies", style = "text-align: left;"),
br(),
fluidRow(
column(
width = 9,
h4(glue::glue("Available in database: {nrow(table_revdeps_local()) %||% 0}"), style = "text-align: left;"),
br(),
DT::renderDataTable({
datatable_custom(
table_revdeps_local() |> select(-decision_id),
colnames = c("Package", "Version", "Score", "Decision", "Review Package"),
hide_names = NULL
)
}),
br(), br(),
h4(glue::glue("All reverse Dependencies: {length(revdeps())}"), style = "text-align: left;"),
br(),
wellPanel(
renderText(revdeps() %>% sort()),
style = "max-height: 500px; overflow: auto"
)
}),
br(), br(),
wellPanel(
renderText(revdeps() %>% sort()),
style = "max-height: 500px; overflow: auto"
)
),
br(), br(),
fluidRow(div(id = "comments_for_dep",
if ("general_comment" %in% unlist(credentials$privileges[user$role], use.names = FALSE)) addCommentUI(NS(id, 'add_comment')),
viewCommentsUI(NS(id, 'view_comments')))
)
),
br(), br(),
fluidRow(div(id = "comments_for_dep",
if ("general_comment" %in% unlist(credentials$privileges[user$role], use.names = FALSE)) addCommentUI(NS(id, 'add_comment')),
viewCommentsUI(NS(id, 'view_comments')))
)
) # taglist
) # taglist
) #div
}
}) # renderUI

Expand Down
21 changes: 7 additions & 14 deletions R/mod_reportPreview.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ reportPreviewServer <- function(id, selected_pkg, maint_metrics, com_metrics,
DT::renderDataTable({
req(selected_pkg$name())

datatable_custom(dep_table(), pLength = list(-1), PlChange = FALSE,
datatable_custom(dep_metrics() |> select(-decision_id, -name), custom_dom = "t", pLength = list(-1), PlChange = FALSE,
colnames = c("Package", "Type", "Version", "Score", "Decision"))

}
Expand Down Expand Up @@ -450,7 +450,12 @@ reportPreviewServer <- function(id, selected_pkg, maint_metrics, com_metrics,
})

dep_metrics <- eventReactive(list(selected_pkg$name(), session$userData$suggests()), {
get_depends_data(selected_pkg$name(), session$userData$suggests(), db_name = golem::get_golem_options("assessment_db_name"))
get_depends_data(selected_pkg$name(),
session$userData$suggests(),
db_name = golem::get_golem_options("assessment_db_name"),
loaded2_db = session$userData$loaded2_db(),
repo_pkgs = session$userData$repo_pkgs()
)
})

dep_cards <- eventReactive(dep_metrics(), {
Expand All @@ -461,18 +466,6 @@ reportPreviewServer <- function(id, selected_pkg, maint_metrics, com_metrics,
# Package Dependencies metrics cards.
metricGridServer("dep_metricGrid", metrics = dep_cards)

dep_table <- eventReactive(dep_metrics(), {
req(dep_metrics())

if (nrow(dep_metrics()) == 0)
return(dplyr::tibble(package = character(), type = character(), version = character(), score = character()))

purrr::map_df(dep_metrics()$name, ~get_versnScore(.x, session$userData$loaded2_db(), session$userData$repo_pkgs())) %>%
right_join(dep_metrics(), by = "name") %>%
select(package, type, version, score, decision) %>%
arrange(package, type) %>%
distinct()
})

output$communityMetrics_ui <- renderUI({
req(selected_pkg$name())
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ datatable_custom <- function(
# Hiding name from DT table.
# The - 1 is because js uses 0 index instead of 1 like R
target <- which(names(data) %in% hide_names) - 1

formattable::as.datatable(
formattable::formattable(
data,
Expand Down
Loading