Skip to content
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 NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## New features and changes

- `renderQCReport` Render a QC Report Document. (#135)
- `renderQCReport` render a QC report document. (#135)

- `logRemove` added to package to assist with removing files from the QC log. (#105)

Expand Down
4 changes: 2 additions & 2 deletions R/findAuthorsQcers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ findAuthorsQcers <- function(.repoHistory, .qcLog) {

qclog <-
.qcLog %>%
dplyr::transmute(file, rev = as.character(revf), reviewer) %>%
dplyr::transmute(file, rev = as.integer(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::arrange(file, -rev) %>%
dplyr::group_by(file) %>%
tidyr::fill(reviewer, .direction = "down") %>%
dplyr::ungroup()
Expand Down
13 changes: 6 additions & 7 deletions R/renderQCReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
#' @export
renderQCReport <- function(.output_dir = NULL) {

reportRes <- list()

reportRes$project <- basename(logRoot())

reportRes$logSum <- logSummary()

if (is.null(.output_dir)) {
.output_dir <- tempdir()
} else {
Expand All @@ -37,10 +31,15 @@ renderQCReport <- function(.output_dir = NULL) {
output_file <- paste0("qc-report-", Sys.Date(), ".pdf")
output_path <- file.path(.output_dir, output_file)

params_in <- list(
project = basename(logRoot()),
logSum = logSummary()
)

rmarkdown::render(
input = system.file("templates", "QCReport.Rmd", package = "review"),
output_file = output_path,
params = list(reportRes = reportRes),
params = params_in,
envir = new.env(),
quiet = TRUE
)
Expand Down
15 changes: 9 additions & 6 deletions R/renderQCSummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#'
#' The QC status of all scripts checked into SVN by each author will be displayed,
#' along with a high level summary of all scripts that need to be QCed.
#'
#' @param .dirs_exclude Character string (optional). Vector of directories to exclude in the summary (relative to log root).
#'
#' @param .output_dir Character string (optional). Path to the directory where the output PDF
#' should be saved. If not provided, the document will not be saved locally.
Expand All @@ -23,9 +21,7 @@
#' }
#'
#' @export
renderQCSummary <- function(.dirs_exclude = NULL, .output_dir = NULL) {

dirSummaryRes <- dirSummary(.dirs_exclude = .dirs_exclude)
renderQCSummary <- function(.output_dir = NULL) {

if (is.null(.output_dir)) {
.output_dir <- tempdir()
Expand All @@ -38,10 +34,17 @@ renderQCSummary <- function(.dirs_exclude = NULL, .output_dir = NULL) {
output_file <- paste0("qc-summary-", Sys.Date(), ".pdf")
output_path <- file.path(.output_dir, output_file)

params_in <- list(
project = basename(logRoot()),
repoHistory = repoHistory(),
qcLog = logRead(),
logPending = logPending()
)

rmarkdown::render(
input = system.file("templates", "QCSummary.Rmd", package = "review"),
output_file = output_path,
params = list(dirSummaryRes = dirSummaryRes),
params = params_in,
envir = new.env(),
quiet = TRUE
)
Expand Down
3 changes: 2 additions & 1 deletion R/repoHistory.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ repoHistory <- function() {
) %>%
dplyr::mutate(
date = as.Date(date),
file = sub('.', '', file) # Remove first character
file = sub('.', '', file),
rev = as.integer(rev)
)

}
16 changes: 8 additions & 8 deletions inst/templates/QCReport.Rmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
params:
reportRes: "`r list()`"
title: "QC Report"
subtitle: "`r params$reportRes$project`"
subtitle: "`r params$project`"
date: "`r format(Sys.time(), '%d %B, %Y %H:%M %Z')`"
params:
project: ""
logSum: NULL
output: pdf_document
header-includes:
- \usepackage{caption}
Expand All @@ -15,9 +16,7 @@ knitr::opts_chunk$set(echo = FALSE)

```{r message=FALSE, warning=FALSE}

log_summary_data <- params$reportRes$logSum

log_summary_data %>%
params$logSum %>%
dplyr::select(file, revf, headf, time) %>%
dplyr::mutate(
Status = dplyr::case_when(
Expand All @@ -31,10 +30,11 @@ log_summary_data %>%
dplyr::rename(
File = file,
`QCed...revision` = revf,
`Last modified...revision` = headf,
`Last...revision` = headf,
) %>%
dplyr::arrange(Status, as.numeric(`QCed...revision`)) %>%
pmtables::st_new() %>%
pmtables::st_left(File = pmtables::col_ragged(5)) %>%
pmtables::st_left(File = pmtables::col_ragged(8)) %>%
pmtables::stable_long() %>%
pmtables::st_asis()
```
201 changes: 104 additions & 97 deletions inst/templates/QCSummary.Rmd
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
---
params:
dirSummaryRes: "`r list()`"
title: "QC Summary"
subtitle: "`r params$dirSummaryRes$project`"
subtitle: "`r params$project`"
date: "`r format(Sys.time(), '%d %B, %Y %H:%M %Z')`"
params:
project: ""
repoHistory: NULL
qcLog: NULL
logPending: NULL
output:
pdf_document:
toc: true
toc_depth: 3
toc: true
toc_depth: 3
header-includes:
- \usepackage{caption}
- \usepackage{caption}
---

\captionsetup[table]{labelformat=empty}
Expand All @@ -18,116 +21,120 @@ header-includes:
knitr::opts_chunk$set(echo = FALSE)
```

```{r, include=FALSE}
dir_summary_data <- params$dirSummaryRes$data

qc_status <- params$dirSummaryRes$status

```

\newpage

# Summaries

\newpage

## QC Pending
# QC Pending

```{r, results='asis'}

needs_qc <-
qc_status %>%
dplyr::filter(Status == "In QC log, needs QC") %>%
dplyr::select(-Status)

if (nrow(needs_qc) == 0) {
needs_qc <- dplyr::tibble(Author = "None", File = "None")
}
latest_authors <-
params$repoHistory %>%
dplyr::group_by(file) %>%
dplyr::filter(rev == max(rev)) %>%
dplyr::ungroup() %>%
dplyr::select(file, author)

needs_qc <- params$qcLog %>% dplyr::filter(file %in% params$logPending$file)

needs_qc <-
if (nrow(needs_qc) == 0) {
dplyr::tibble(File = "No outstanding QC")
} else {
needs_qc %>%
dplyr::group_by(file) %>%
dplyr::summarize(
`Previous QCers` = paste(unique(reviewer), collapse = ", ")
) %>%
dplyr::ungroup() %>%
dplyr::mutate(
`Previous QCers` = gsub("anyone, ", "", `Previous QCers`, fixed = TRUE),
`Previous QCers` = ifelse(`Previous QCers` == "anyone", "none", `Previous QCers`)
) %>%
dplyr::left_join(latest_authors, by = "file") %>%
dplyr::select(
File = file,
`Last author` = author,
`Previous QCers`
)
}

needs_qc %>%
pmtables::st_new() %>%
pmtables::st_clear_reps("Author") %>%
pmtables::st_bold(cols = "Author") %>%
pmtables::st_left(`Previous QCers` = pmtables::col_ragged(4)) %>%
pmtables::st_left(File = pmtables::col_ragged(10)) %>%
pmtables::stable_long() %>%
pmtables::st_asis()

```

\newpage

## QC Up to Date
# Files Not in QC Log

```{r, results='asis'}

qc_up_to_date <-
qc_status %>%
dplyr::filter(Status == "QC up to date") %>%
dplyr::select(-Status)

if (nrow(qc_up_to_date) == 0) {
qc_up_to_date <- dplyr::tibble(Author = "None", File = "None")
at_risk_days <- 20

relevant_dirs <-
c(
"script"
)

relevant_file_types <-
c(
"R",
"Rmd",
"yaml",
"yml",
"ctl",
"cpp",
"cp",
"mod",
"stan",
"jl",
"qmd"
)

not_in_log <-
params$repoHistory %>%
dplyr::group_by(file) %>%
dplyr::filter(rev == max(rev)) %>%
dplyr::ungroup() %>%
dplyr::mutate(
top_dir = sapply(fs::path_split(file), function(x) x[1]),
`Last edit` = date,
`Days Since...Last Edit` = as.numeric(Sys.Date() - `Last edit`)
) %>%
dplyr::filter(
tools::file_ext(file) %in% relevant_file_types,
top_dir %in% relevant_dirs,
!(file %in% params$qcLog$file)
) %>%
dplyr::filter(`Days Since...Last Edit` <= at_risk_days) %>%
dplyr::select(
File = file,
`Last Author` = author,
`Days Since...Last Edit`
) %>%
dplyr::arrange(`Days Since...Last Edit`) %>%
dplyr::distinct()

if (nrow(not_in_log) == 0) {
not_in_log <-
dplyr::tibble(
File = paste0(
"No files that are not in the QC log were modified within the last ",
at_risk_days,
" days"
)
)
}

qc_up_to_date %>%

not_in_log %>%
pmtables::st_new() %>%
pmtables::st_clear_reps("Author") %>%
pmtables::st_bold(cols = "Author") %>%
pmtables::stable_long() %>%
pmtables::st_left(File = pmtables::col_ragged(10)) %>%
pmtables::stable_long(
lt_cap_text = "*Files in this table have been edited within the last (20) days"
) %>%
pmtables::st_asis()

```

\newpage

# Contributors


\newpage

```{r, results='asis'}
authors <-
dir_summary_data %>%
dplyr::filter(Directory != ".") %>%
dplyr::distinct(Author) %>%
dplyr::pull(Author)

for (author.i in authors) {

writeLines(paste0("## ", author.i))

directories.i <-
dir_summary_data %>%
dplyr::filter(Directory != ".") %>%
dplyr::filter(Author == author.i) %>%
dplyr::distinct(Directory) %>%
dplyr::pull(Directory)

if (length(directories.i) == 0) {
next
}

for (directory.i in directories.i) {

writeLines(paste0("### ", directory.i))

tab.i <-
dir_summary_data %>%
dplyr::filter(Author == author.i) %>%
dplyr::filter(Directory == directory.i) %>%
dplyr::select(File, `Latest edit`, QCer, Status) %>%
dplyr::arrange(Status) %>%
pmtables::st_new() %>%
pmtables::st_panel("Status") %>%
pmtables::stable_long()

pmtables::st_wrap(tab.i)

rm(tab.i)

writeLines("\n")
writeLines("\\newpage")
}

}

```
4 changes: 1 addition & 3 deletions man/renderQCSummary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading