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

Fix Rescoring/Reweighting Bug #693

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.9000
Version: 3.0.0.9001
Authors@R: c(
person("Aaron", "Clark", role = c("aut", "cre"), email = "[email protected]"),
person("Robert", "Krajcik", role = "aut", email = "[email protected]"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# riskassessment (development version)
* Fixes bug that doesn't reset decision by and date fields when re-scoring/re-weighting packages (#680)

# riskassessment 3.0.0

Expand Down
2 changes: 1 addition & 1 deletion R/mod_reweightView.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ reweightViewServer <- function(id, user, decision_list, credentials) {
pkg <- dbSelect("SELECT DISTINCT name AS pkg_name FROM package WHERE decision_id IS NOT NULL")
if (nrow(pkg) > 0) {
for (i in 1:nrow(pkg)) {
dbUpdate("UPDATE package SET decision_id = NULL where name = {pkg$pkg_name[i]}")
dbUpdate("UPDATE package SET decision_id = NULL, decision_by = NULL, decision_date = NULL where name = {pkg$pkg_name[i]}")
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-reweightView.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test_that("reweightView works", {
# Set decision
dbUpdate(
"UPDATE package
SET decision_id = 1
SET decision_id = 1, decision_by = 'tester', decision_date = 'TODAY'
WHERE name = 'dplyr'",
app_db_loc
)
Expand All @@ -78,7 +78,7 @@ test_that("reweightView works", {
app$click(selector = "#confirmation_id button")

expect_equal(nrow(dbSelect("select * from comments", db_backup)), 2)
expect_equal(dbSelect("select * from package", db_backup)[["decision_id"]], 1)
expect_equal(dbSelect("select decision_id, decision_by, decision_date from package", db_backup) |> unlist(use.names = FALSE), c("1", "tester", "TODAY"))

app$click("reweightInfo-update_pkg_risk")
app$wait_for_idle()
Expand All @@ -90,7 +90,7 @@ test_that("reweightView works", {

expect_equal(nrow(dbSelect("select * from comments where comment_type = 'o'", db_backup)), 0)
expect_equal(nrow(dbSelect("select * from comments", db_backup)), 3)
expect_equal(dbSelect("select * from package", db_backup)[["decision"]], NULL)
expect_equal(dbSelect("select decision_id, decision_by, decision_date from package", db_backup) |> unlist(use.names = FALSE), rep(NA_character_, 3))

metric_weights <- app$get_value(export = "metric_weights")
curr_new_wts <- app$get_value(export = "reweightInfo-curr_new_wts")
Expand Down
Loading