Skip to content

Commit

Permalink
add eic_airtable_data fn for #33
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Apr 29, 2024
1 parent 8af0e7c commit e8ccea9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dashboard
Title: What the Package Does (One Line, Title Case)
Version: 0.2.1
Version: 0.2.1.001
Authors@R:
person(given = "First",
family = "Last",
Expand Down
48 changes: 43 additions & 5 deletions R/editors-airtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ editor_vacation_status <- function (airtable_id) {
return (edvac)
}

eic_rev_prod_table <- function (airtable_id) {
rev_prod <- airtabler::airtable (
base = airtable_id, table = "reviewers-prod"
)
rev_prod <-
rev_prod$`reviewers-prod`$select_all (fields = list ("github", "name"))
}
m_eic_rev_prod_table <- memoise::memoise (eic_rev_prod_table)

edvac_status_airtable <- function (airtable_id) {
editor_vacation <- airtabler::airtable (
base = airtable_id, table = "editor-vacation-status"
Expand All @@ -51,11 +60,7 @@ edvac_status_airtable <- function (airtable_id) {
)
edvac <- editor_vacation [which (index), ]

rev_prod <- airtabler::airtable (
base = airtable_id, table = "reviewers-prod"
)
rev_prod <-
rev_prod$`reviewers-prod`$select_all (fields = list ("github", "name"))
rev_prod <- m_eic_rev_prod_table (airtable_id)
rev_prod <- rev_prod [match (edvac$editor, rev_prod$id), ]
edvac$github <- rev_prod$github
edvac$name <- rev_prod$name
Expand Down Expand Up @@ -111,3 +116,36 @@ add_editor_airtable_data <- function (editors, airtable_id) {

return (editors)
}

eic_airtable_data <- function (airtable_id) {

eic_table <- airtabler::airtable (
base = airtable_id, table = "editor-in-chief-rotation"
)
eic <- eic_table$`editor-in-chief-rotation`$select_all ()

eic$period_start <- as.Date (eic$period_start)
eic$period_end <- as.Date (eic$period_end)
eic <- eic [order (eic$period_start), ]

today <- Sys.Date ()
i_now <- i_next <- which (eic$period_start <= today & eic$period_end >= today)
if (nrow (eic) > i_now) {
i_now <- i_now + 0:1
}
eic_current <- eic [i_now, ] # Current and next EiC
eic_names <- unlist (eic_current$acting_eic_name)
eic_ids <- eic_current$acting_eic
eic_start_dates <- eic_current$period_start

rev_prod <- m_eic_rev_prod_table (airtable_id)
eic_in_rev_table <- match (eic_ids, rev_prod$id)
eic_github <- rev_prod$github [eic_in_rev_table]

data.frame (
name = eic_names,
github = eic_github,
start_date = eic_start_dates,
what = c ("current", "next") [seq_along (eic_names)]
)
}
3 changes: 3 additions & 0 deletions R/editors.R
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ editor_status <- function (quiet = FALSE, aggregation_period = "quarter") {
# Add additional columns from airtable data:
status <- add_editor_airtable_data (status, airtable_base_id)

eic <- eic_airtable_data (airtable_base_id)

# Then editor timelines
month <- name <- NULL # Suppress no visible binding notes
process_timeline <- function (dat, what = "issues_total") {
Expand All @@ -388,6 +390,7 @@ editor_status <- function (quiet = FALSE, aggregation_period = "quarter") {

return (list (
status = status,
eic = eic,
timeline_total = timeline_total,
timeline_new = timeline_new,
reviews = ed_rev
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "dashboard: What the Package Does (One Line, Title Case)",
"codeRepository": "https://github.com/ropensci-review-tools/dashboard",
"license": "https://spdx.org/licenses/MIT",
"version": "0.2.1",
"version": "0.2.1.001",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit e8ccea9

Please sign in to comment.