-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathairtable-get-data.R
More file actions
52 lines (40 loc) · 2.24 KB
/
airtable-get-data.R
File metadata and controls
52 lines (40 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
## 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(.) && !any(is.na(.)))
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|On\\sLeave", 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)]