Skip to content

Commit

Permalink
Add findAuthorsQcers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmcd18 authored and andersone1 committed Oct 31, 2024
1 parent 742cbb6 commit 01ea408
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
27 changes: 27 additions & 0 deletions R/findAuthorsQcers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#' @noRd
findAuthorsQcers <- function(.repoHistory, .qcLog) {

qclog <-
.qcLog %>%
dplyr::transmute(file, rev = as.character(revf), reviewer) %>%
dplyr::filter(rev != "0") %>%
dplyr::distinct()

rH_qclog <-
.repoHistory %>%
dplyr::left_join(qclog, by = c("file", "rev")) %>%
dplyr::arrange(file, -as.numeric(rev)) %>%
dplyr::group_by(file) %>%
tidyr::fill(reviewer, .direction = "down") %>%
dplyr::ungroup()

out <- list()

out$authors <- rH_qclog %>% dplyr::filter(is.na(reviewer) | author != reviewer)

out$qcers <- rH_qclog %>% dplyr::filter(author == reviewer)

stopifnot(nrow(.repoHistory) == nrow(out$authors) + nrow(out$qcers))

return(out)
}
23 changes: 23 additions & 0 deletions tests/testthat/test-findAuthorsQcers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
create_test_svn()

review::logAccept("script/data-assembly/da-functions.R")

qclog <- logRead()
df_history <- repoHistory()

authors_qcers <- findAuthorsQcers(.repoHistory = df_history, .qcLog = qclog)

test_that("findAuthorsQcers works as expected", {

expect_equal(length(authors_qcers), 2)
expect_equal(names(authors_qcers), c("authors", "qcers"))
expect_true(inherits(authors_qcers, "list"))
expect_true(inherits(authors_qcers$authors, "data.frame"))

expect_true(all(authors_qcers$qcers$author == authors_qcers$qcers$reviewer))
expect_true(all(is.na(authors_qcers$authors$reviewer) |
authors_qcers$authors$author != authors_qcers$authors$reviewer))

expect_true(nrow(authors_qcers$authors %>% dplyr::distinct(file, rev)) == nrow(authors_qcers$authors))

})

0 comments on commit 01ea408

Please sign in to comment.