From 780a7ae1af836aead7dcfd082a625f602798d704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Fri, 16 Aug 2024 14:44:38 +0200 Subject: [PATCH] refactor README code into scripts cc @mpadge --- README.Rmd | 96 +++++++--------------------- README.md | 6 +- scripts/airtable-get-data.R | 61 ++++++++++++++++++ scripts/airtable-get-editors.R | 12 ++++ scripts/airtable-get-eic.R | 6 ++ scripts/airtable-get-guest-editors.R | 1 + scripts/airtable-get-reviewers.R | 1 + 7 files changed, 105 insertions(+), 78 deletions(-) create mode 100644 scripts/airtable-get-data.R create mode 100644 scripts/airtable-get-editors.R create mode 100644 scripts/airtable-get-eic.R create mode 100644 scripts/airtable-get-guest-editors.R create mode 100644 scripts/airtable-get-reviewers.R diff --git a/README.Rmd b/README.Rmd index 6c7a4e8..1092913 100644 --- a/README.Rmd +++ b/README.Rmd @@ -15,7 +15,7 @@ knitr::opts_chunk$set( ) ``` -![ropensci](icon_lettering_color.png) +![](icon_lettering_color.png) # rOpenSci Software Peer Review @@ -94,92 +94,45 @@ on how to improve the process on our [forum](https://discuss.ropensci.org/) and rOpenSci's Software Peer Review process is run by our team of dedicated editors and reviewers. Information on the current team, and the current status of software peer review, can be seen on our [interactive dashboard](https://ropensci-review-tools.github.io/dashboard/). -```{r get-airtable-data, warning=FALSE, echo=FALSE} -if (Sys.getenv("AIRTABLE_API_KEY") == ""){ - Sys.setenv(AIRTABLE_API_KEY = params$AIRTABLE_API_KEY) -} -if (Sys.getenv("AIRTABLE_ID") == ""){ - Sys.setenv(AIRTABLE_ID = params$AIRTABLE_ID) -} - -at_eic <- airtabler::airtable(base = Sys.getenv("AIRTABLE_ID"), - table = "editor-in-chief-rotation") -eic <- at_eic$`editor-in-chief-rotation`$select_all() - -at_rev <- airtabler::airtable(base = Sys.getenv("AIRTABLE_ID"), - table = "reviewers-prod") -reviewers <- at_rev$`reviewers-prod`$select_all() - -at_guest <- airtabler::airtable(base = "app8dssb6a7PG6Vwj", - table = "guest-editors") -guest_editors <- at_guest$`guest-editors`$select_all() +```{r} +#| echo: false +#| results: 'asis' +source(file.path("scripts", "airtable-get-data.R"), local = knitr::knit_global()) + ``` + ### Editor-in-Chief -```{r eic, echo=FALSE, results='asis'} -eic$period_start <- as.Date(eic$period_start) -eic$period_end <- as.Date(eic$period_end) -today <- Sys.Date () -eic_now <- eic [which (eic$period_start <= today & eic$period_end >= today), ] -eic_name <- eic_now$acting_eic_name [[1]] -eic_id <- eic_now$acting_eic -eic_in_rev_table <- which(reviewers$id == eic_id) -eic_github <- reviewers$github[eic_in_rev_table] - -out <- paste0( - "We rotate our Editor-in-Chief, generally every three months. ", - "Our current Editor-in-Chief is [", eic_name, "](https://github.com/", - eic_github, ").\n" -) -cat(out, sep = "") +```{r} +#| echo: false +#| results: 'asis' +source(file.path("scripts", "airtable-get-eic.R"), local = knitr::knit_global()) + ``` ### Editorial team -```{r editors, echo=FALSE} -editor_index_all <- purrr::map_lgl(reviewers$editor, ~!is.null(.)) -editors_all <- reviewers[which(editor_index_all), c("name", "github", "Affiliation", "editor")] -editors_all <- editors_all [which(!editors_all$name == eic_name), ] -last_names <- humaniformat::last_name(trimws(editors_all$name)) -editors_all <- editors_all[order(last_names), ] - -editors_past <- editors_all[grep("Emeritus", editors_all$editor), ] -editors <- editors_all[which(!editors_all$name %in% editors_past$name), ] -``` Our current team of editors for software peer-review includes: -```{r gen_ed_out-fn, echo=FALSE} -gen_ed_out <- function(ed_dat) { - if (!"Affiliation" %in% names(ed_dat)) { - ed_dat$Affiliation <- NA_character_ - } - out <- gsub("(,\\sNA|\\s);", ";", paste0( - "- [", ed_dat$name, "](https://github.com/", ed_dat$github, "), ", - ed_dat$Affiliation, ";\n")) - out[length(out)] <- gsub(";\\n$", ".\n", out[length(out)]) - return(out) -} -``` -```{r editors-out, echo=FALSE, results='asis'} -cat(gen_ed_out(editors), sep = "") +```{r} +#| echo: false +#| results: 'asis' +source(file.path("scripts", "airtable-get-editors.R"), local = knitr::knit_global()) + ``` ### Reviewers and former editors We are grateful to the following individuals who have offered up their time and expertise to review packages submitted to rOpenSci. -```{r reviewers, echo=FALSE, results='asis'} -reviewers <- reviewers[purrr::map_lgl(reviewers$reviews, - ~!is.null(.)) & - !(reviewers$name %in% c(editors_all$name, "???")), ] -# get last names -last_names <- humaniformat::last_name(trimws(reviewers$name)) -reviewers <- reviewers[order(last_names), ] -reviewers$name[is.na(reviewers$name)] <- reviewers$github[is.na(reviewers$name)] -cat(paste0("[", reviewers$name, "](https://github.com/", reviewers$github, ")", collapse = " \U00B7 ")) +```{r} +#| echo: false +#| results: 'asis' +source(file.path("scripts", "airtable-get-reviewers.R"), local = knitr::knit_global()) + ``` We are also grateful to the following individuals who have previously served as editors. @@ -191,10 +144,5 @@ cat(gen_ed_out(editors_past), sep = "") And the following who have served as guest editors. ```{r guest-editors-out, echo=FALSE, results='asis'} -guest_editors <- guest_editors[!(guest_editors$name %in% - c(editors_all$name, eic_name, "???")), ] -# get last names -last_names <- humaniformat::last_name(trimws(guest_editors$name)) -guest_editors <- guest_editors[order(last_names), ] cat(gen_ed_out(guest_editors), sep = "") ``` diff --git a/README.md b/README.md index 4a892fe..0cd51f4 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ -
-ropensci - -
+![](icon_lettering_color.png) # rOpenSci Software Peer Review @@ -471,4 +468,5 @@ served as editors. And the following who have served as guest editors. - [Ana Laura Diedrichs](https://github.com/anadiedrichs); +- [Adam Sparks](https://github.com/adamhsparks); - [Hao Zhu](https://github.com/haozhu233). diff --git a/scripts/airtable-get-data.R b/scripts/airtable-get-data.R new file mode 100644 index 0000000..395c4d9 --- /dev/null +++ b/scripts/airtable-get-data.R @@ -0,0 +1,61 @@ +## setup ---- + +if (Sys.getenv("AIRTABLE_API_KEY") == ""){ + Sys.setenv(AIRTABLE_API_KEY = params$AIRTABLE_API_KEY) +} +if (Sys.getenv("AIRTABLE_ID") == ""){ + Sys.setenv(AIRTABLE_ID = params$AIRTABLE_ID) +} + +## all reviewers ---- +at_rev <- airtabler::airtable(base = Sys.getenv("AIRTABLE_ID"), + table = "reviewers-prod") +reviewers <- at_rev$`reviewers-prod`$select_all() + +## eic ---- + +at_eic <- airtabler::airtable(base = Sys.getenv("AIRTABLE_ID"), + table = "editor-in-chief-rotation") +eic <- at_eic$`editor-in-chief-rotation`$select_all() + +eic$period_start <- as.Date(eic$period_start) +eic$period_end <- as.Date(eic$period_end) +today <- Sys.Date () +eic_now <- eic [which (eic$period_start <= today & eic$period_end >= today), ] +eic_name <- eic_now$acting_eic_name [[1]] +eic_id <- eic_now$acting_eic +eic_in_rev_table <- which(reviewers$id == eic_id) +eic_github <- reviewers$github[eic_in_rev_table] + +## guest editors ---- + +at_guest <- airtabler::airtable(base = "app8dssb6a7PG6Vwj", + table = "guest-editors") + + +editor_index_all <- purrr::map_lgl(reviewers$editor, ~!is.null(.)) +editors_all <- reviewers[which(editor_index_all), c("name", "github", "Affiliation", "editor")] +editors_all <- editors_all [which(!editors_all$name == eic_name), ] +last_names <- humaniformat::last_name(trimws(editors_all$name)) +editors_all <- editors_all[order(last_names), ] + +editors_past <- editors_all[grep("Emeritus", editors_all$editor), ] +editors <- editors_all[which(!editors_all$name %in% editors_past$name), ] + +guest_editors <- at_guest$`guest-editors`$select_all() + +guest_editors <- airtabler::airtable(base = "app8dssb6a7PG6Vwj", + table = "guest-editors") +guest_editors <- guest_editors$`guest-editors`$select_all(fields = list("name", "github")) +guest_editors <- guest_editors[!(guest_editors$name %in% c(editors$name, "???")), ] +last_names <- humaniformat::last_name(trimws(guest_editors$name)) +guest_editors <- guest_editors[order(last_names), ] + +## reviewers that are not editors ---- + +reviewers <- reviewers[purrr::map_lgl(reviewers$reviews, + ~!is.null(.)) & + !(reviewers$name %in% c(editors_all$name, "???")), ] +last_names <- humaniformat::last_name(trimws(reviewers$name)) +reviewers <- reviewers[order(last_names), ] +reviewers$name[is.na(reviewers$name)] <- reviewers$github[is.na(reviewers$name)] diff --git a/scripts/airtable-get-editors.R b/scripts/airtable-get-editors.R new file mode 100644 index 0000000..6ff44b3 --- /dev/null +++ b/scripts/airtable-get-editors.R @@ -0,0 +1,12 @@ +gen_ed_out <- function(ed_dat) { + if (!"Affiliation" %in% names(ed_dat)) { + ed_dat$Affiliation <- NA_character_ + } + out <- gsub("(,\\sNA|\\s);", ";", paste0( + "- [", ed_dat$name, "](https://github.com/", ed_dat$github, "), ", + ed_dat$Affiliation, ";\n")) + out[length(out)] <- gsub(";\\n$", ".\n", out[length(out)]) + return(out) +} + +cat(gen_ed_out(editors), sep = "") \ No newline at end of file diff --git a/scripts/airtable-get-eic.R b/scripts/airtable-get-eic.R new file mode 100644 index 0000000..1fb8f9c --- /dev/null +++ b/scripts/airtable-get-eic.R @@ -0,0 +1,6 @@ +out <- paste0( + "We rotate our Editor-in-Chief, generally every three months. ", + "Our current Editor-in-Chief is [", eic_name, "](https://github.com/", + eic_github, ").\n" +) +cat(out, sep = "") \ No newline at end of file diff --git a/scripts/airtable-get-guest-editors.R b/scripts/airtable-get-guest-editors.R new file mode 100644 index 0000000..a862223 --- /dev/null +++ b/scripts/airtable-get-guest-editors.R @@ -0,0 +1 @@ +cat(paste0("[", guest_editors$name, "](https://github.com/", guest_editors$github, ")", collapse = " \U00B7 ")) diff --git a/scripts/airtable-get-reviewers.R b/scripts/airtable-get-reviewers.R new file mode 100644 index 0000000..bd48417 --- /dev/null +++ b/scripts/airtable-get-reviewers.R @@ -0,0 +1 @@ +cat(paste0("[", reviewers$name, "](https://github.com/", reviewers$github, ")", collapse = " \U00B7 ")) \ No newline at end of file