Skip to content

Commit

Permalink
Merge pull request #693 from pharmaR/jt-680-fix_rescoring_bug
Browse files Browse the repository at this point in the history
Fix Rescoring/Reweighting Bug
  • Loading branch information
Robert-Krajcik authored Nov 13, 2023
2 parents 04781c5 + a1dd116 commit 659be64
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
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

0 comments on commit 659be64

Please sign in to comment.