-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor README code into scripts cc @mpadge
- Loading branch information
Showing
7 changed files
with
105 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cat(paste0("[", guest_editors$name, "](https://github.com/", guest_editors$github, ")", collapse = " \U00B7 ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cat(paste0("[", reviewers$name, "](https://github.com/", reviewers$github, ")", collapse = " \U00B7 ")) |