From de8a30ef8aeae865d101b1d60a6e35a9f0e16ee2 Mon Sep 17 00:00:00 2001 From: mpadge Date: Tue, 19 Mar 2024 17:49:33 +0100 Subject: [PATCH] add 'add_editor_airtable_data' fn for #7 --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/editors-airtable.R | 29 +++++++++++++++++++++++++++++ codemeta.json | 2 +- man/add_editor_airtable_data.Rd | 18 ++++++++++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 man/add_editor_airtable_data.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 2558bea..c3a657c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dashboard Title: What the Package Does (One Line, Title Case) -Version: 0.0.7.003 +Version: 0.0.7.004 Authors@R: person(given = "First", family = "Last", diff --git a/NAMESPACE b/NAMESPACE index e8d4133..80a7e1c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(add_editor_airtable_data) export(editor_status) export(editor_vacation_status) export(review_status) diff --git a/R/editors-airtable.R b/R/editors-airtable.R index 30b25ee..337c245 100644 --- a/R/editors-airtable.R +++ b/R/editors-airtable.R @@ -32,3 +32,32 @@ editor_vacation_status <- function () { editors_on_vacation <- edvac$github [which (edvac$away)] ed_status$status [ed_status$editor %in% editors_on_vacation] <- "ON LEAVE" } + +#' Add additional columns to 'editors' data from rOpenSci's airtable database. +#' +#' @param editors The `data.frame` of editors returned as the "status" component +#' from \link{editor_status}. +#' @return A modified version of `editors` with additional columns. +#' @export +add_editor_airtable_data <- function (editors) { + rev_prod <- airtabler::airtable ( + base = "app8dssb6a7PG6Vwj", table = "reviewers-prod" + ) + fields <- list ("github", "name", "other_langs", "domain_expertise") + rev_prod <- rev_prod$`reviewers-prod`$select_all (fields = fields) + + editors$other_langs <- editors$domain_expertise <- NA_character_ + index <- match (editors$editor, rev_prod$github) + + editors$other_langs <- rev_prod$other_langs [index] + editors$other_langs <- vapply (editors$other_langs, function (i) { + paste0 (i [which (!i == "English")], collapse = ", ") + }, character (1L)) + + editors$domain_expertise <- rev_prod$domain_expertise [index] + editors$domain_expertise <- vapply (editors$domain_expertise, function (i) { + paste0 (i [which (!grepl ("^Other", i))], collapse = ", ") + }, character (1L)) + + return (editors) +} diff --git a/codemeta.json b/codemeta.json index 3c8ce17..f7e8112 100644 --- a/codemeta.json +++ b/codemeta.json @@ -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.0.7.003", + "version": "0.0.7.004", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", diff --git a/man/add_editor_airtable_data.Rd b/man/add_editor_airtable_data.Rd new file mode 100644 index 0000000..3f1997a --- /dev/null +++ b/man/add_editor_airtable_data.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/editors-airtable.R +\name{add_editor_airtable_data} +\alias{add_editor_airtable_data} +\title{Add additional columns to 'editors' data from rOpenSci's airtable database.} +\usage{ +add_editor_airtable_data(editors) +} +\arguments{ +\item{editors}{The `data.frame` of editors returned as the "status" component +from \link{editor_status}.} +} +\value{ +A modified version of `editors` with additional columns. +} +\description{ +Add additional columns to 'editors' data from rOpenSci's airtable database. +}