Skip to content

Commit

Permalink
Added get_reviewers and need_reviewers functions
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Feb 7, 2025
1 parent 645f399 commit e871971
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 39 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export(get_articles_path)
export(get_assignments)
export(get_latest)
export(get_md_from_pdf)
export(get_reviewers)
export(get_submissions)
export(get_unassigned)
export(invite_reviewer)
Expand All @@ -70,6 +71,7 @@ export(major_revision)
export(make_proof)
export(match_keywords)
export(minor_revision)
export(need_reviewers)
export(new_id)
export(online_metadata)
export(online_metadata_for_article)
Expand Down
124 changes: 85 additions & 39 deletions R/late.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
#' Find late AEs for submissions being handled by a given editor
#'
#' This should be run regularly and AEs chased up if they are late.
#'
#' @param editor The editor handling the submissions
#'
#' @return A data frame of AEs who are late in handling a paper.
#' @details The number of stars has the following meaning:
#' \itemize{
#' \item 1 star: not responded in more than 12 weeks;
#' \item 2 stars: not responded in more than 18 weeks;
#' \item 3 stars: not responded in more than 24 weeks;
#' }
#' Please chase up late AEs.
#' @export

late_aes <- function(editor) {
articles <- get_assignments(editor) |>
get_latest()
articles <- articles[articles$status == "with AE", ]
if (NROW(articles) == 0L) {
warning("No articles are with AEs")
return(NULL)
}
# Add stars
days <- Sys.Date() - as.Date(articles$date)
nstars <- unlist(lapply(days, function(u) sum(u > c(12L, 18L, 24L) * 7)))
articles$stars <- stringr::str_dup("*", nstars)
output <- dplyr::arrange(articles, date) |> as.data.frame()
# Replace AE initials with name
aes <- AEs()
output$ae <- aes[match(output$ae, aes$initials), "name"]
# Return
output[output$stars != "", c("id", "date", "ae", "stars")]
}

#' Find all reviewers for submissions being handled by a given editor
#'
#' @param editor The editor or associate editor handling the submissions
#'
#' @return A data frame of reviewers
#' @export

get_reviewers <- function(editor) {
articles <- get_assignments(editor) |>
get_latest()
articles <- articles[articles$status == "out for review", ]
if (NROW(articles) == 0L) {
warning("No articles are out for review")
return(NULL)
} else {
articles[c("id", "reviewers")] |>
tidyr::unnest(reviewers)
}
}

#' Find late reviewers for submissions being handled by a given editor
#'
#' This should be run regularly and reviewers chased up if they are late.
Expand All @@ -17,21 +73,15 @@
#' @export

late_reviewers <- function(editor) {
articles <- get_assignments(editor) |>
get_latest()
articles <- articles[articles$status == "out for review", ]
if (NROW(articles) == 0L) {
warning("No articles are out for review")
reviewers <- get_reviewers(editor)
if(is.null(reviewers)) {
return(NULL)
}
reviewers <- articles[c("id", "reviewers")] |>
tidyr::unnest(reviewers)
invited <- stringr::str_detect(reviewers$comment, ".*Invited [0-9]*\\-[0-9]*\\-[0-9]*$") &
!is.na(reviewers$comment)
agreed <- stringr::str_detect(reviewers$comment, ".*Agreed [0-9]*\\-[0-9]*\\-[0-9]*$") &
!is.na(reviewers$comment)
status <- last_reviewer_status(reviewers$comment)
invited <- status == "Invited" & !is.na(reviewers$comment)
agreed <- status == "Agreed" & !is.na(reviewers$comment)
output <- dplyr::arrange(reviewers[invited | agreed, ], comment)
agreed <- stringr::str_detect(output$comment, ".*Agreed [0-9]*\\-[0-9]*\\-[0-9]*$")
agreed <- last_reviewer_status(output$comment) == "Agreed"
dates <- stringr::str_extract(output$comment, "[0-9]*\\-[0-9]*\\-[0-9]*$") |>
as.Date()
days <- Sys.Date() - dates
Expand All @@ -44,38 +94,34 @@ late_reviewers <- function(editor) {
output[output$stars != "", c("id", "name", "status", "stars")]
}

#' Find late AEs for submissions being handled by a given editor
#' Find articles that need reviewers for submissions being handled by a given editor.
#'
#' This should be run regularly and AEs chased up if they are late.
#' Returns all articles with fewer than 2 invited reviewers.
#' This should be run regularly and new reviewers appointed if necessary.
#'
#' @param editor The editor handling the submissions
#' @param editor The editor or associate editor handling the submissions
#'
#' @return A data frame of AEs who are late in handling a paper.
#' @details The number of stars has the following meaning:
#' \itemize{
#' \item 1 star: not responded in more than 12 weeks;
#' \item 2 stars: not responded in more than 18 weeks;
#' \item 3 stars: not responded in more than 24 weeks;
#' }
#' Please chase up late AEs.
#' @return A data frame of papers needing more reviewers
#' @export

late_aes <- function(editor) {
articles <- get_assignments(editor) |>
get_latest()
articles <- articles[articles$status == "with AE", ]
if (NROW(articles) == 0L) {
warning("No articles are with AEs")
need_reviewers <- function(editor) {
reviewers <- get_reviewers(editor)
if(is.null(reviewers)) {
return(NULL)
}
# Add stars
days <- Sys.Date() - as.Date(articles$date)
nstars <- unlist(lapply(days, function(u) sum(u > c(12L, 18L, 24L) * 7)))
articles$stars <- stringr::str_dup("*", nstars)
output <- dplyr::arrange(articles, date) |> as.data.frame()
# Replace AE initials with name
aes <- AEs()
output$ae <- aes[match(output$ae, aes$initials), "name"]
# Return
output[output$stars != "", c("id", "date", "ae", "stars")]
reviewers <- dplyr::filter(reviewers, !is.na(reviewers$comment))
# Extract last status
status <- last_reviewer_status(reviewers$comment)
reviewers[!status %in% c("Declined","Abandoned"),] |>
dplyr::select(id) |>
dplyr::count(id) |>
dplyr::filter(n < 2)
}

# Extract last reviewer status from string
last_reviewer_status <- function(string) {
# Remove last date
status <- stringr::str_remove(string, " [0-9]*\\-[0-9]*\\-[0-9]*$")
# Extract last status
stringr::str_extract(status, "[a-zA-Z]*$")
}
17 changes: 17 additions & 0 deletions man/get_reviewers.Rd

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

18 changes: 18 additions & 0 deletions man/need_reviewers.Rd

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

0 comments on commit e871971

Please sign in to comment.