From ecc23b2bc7e9539cf72e9492b89db50b1fd95bda Mon Sep 17 00:00:00 2001 From: mpadge Date: Tue, 19 Mar 2024 17:26:20 +0100 Subject: [PATCH] add R/editors-airtable fn with ed_vacation_status for #7 --- DESCRIPTION | 9 ++++++--- NAMESPACE | 1 + R/editors-airtable.R | 34 ++++++++++++++++++++++++++++++++++ codemeta.json | 20 +++++++++++++------- man/editor_vacation_status.Rd | 15 +++++++++++++++ 5 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 R/editors-airtable.R create mode 100644 man/editor_vacation_status.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 499e70d..cae0ced 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dashboard Title: What the Package Does (One Line, Title Case) -Version: 0.0.7 +Version: 0.0.7.001 Authors@R: person(given = "First", family = "Last", @@ -9,15 +9,18 @@ Authors@R: Description: What the package does (one paragraph). URL: https://github.com/ropensci-review-tools/dashboard Imports: + airtabler, dplyr, gh, gt, lubridate, memoise, tidyr +Suggests: + testthat (>= 3.0.0) +Remotes: + bergant/airtabler License: MIT + file LICENSE Encoding: UTF-8 RoxygenNote: 7.3.1 -Suggests: - testthat (>= 3.0.0) Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index f1ad94c..e8d4133 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,5 @@ # Generated by roxygen2: do not edit by hand export(editor_status) +export(editor_vacation_status) export(review_status) diff --git a/R/editors-airtable.R b/R/editors-airtable.R new file mode 100644 index 0000000..eeb271e --- /dev/null +++ b/R/editors-airtable.R @@ -0,0 +1,34 @@ +#' Get current vacation status of all rOpenSci editors. +#' +#' @return A `data.frame` with one row per editor and information on current +#' vacation status obtained from rOpenSci's airtable database. +#' @export +editor_vacation_status <- function (quiet = FALSE) { + + editor_vacation <- airtabler::airtable ( + base = "app8dssb6a7PG6Vwj", table = "editor-vacation-status" + ) + fields <- list ("editor", "Action", "Start Date", "Return Date") + editor_vacation <- editor_vacation$`editor-vacation-status`$select_all (fields = fields) + index <- vapply (editor_vacation$editor, function (i) length (i) > 0L, logical (1L)) + edvac <- editor_vacation [which (index), ] + + rev_prod <- airtabler::airtable ( + base = "app8dssb6a7PG6Vwj", table = "reviewers-prod" + ) + rev_prod <- rev_prod$`reviewers-prod`$select_all (fields = list ("github", "name")) + rev_prod <- rev_prod [match (edvac$editor, rev_prod$id), ] + edvac$github <- rev_prod$github + edvac$name <- rev_prod$name + + edvac$away <- FALSE + s <- edvac$`Start Date` [2] + index <- (!is.na (edvac$`Start Date`) & is.na (edvac$`Return Date`)) | + as.Date (edvac$`Return Date`) > Sys.Date () + index [which (is.na (index))] <- FALSE + edvac$away [index] <- TRUE + + return (edvac) + editors_on_vacation <- edvac$github [which (edvac$away)] + ed_status$status [ed_status$editor %in% editors_on_vacation] <- "ON LEAVE" +} diff --git a/codemeta.json b/codemeta.json index d9769a8..ff427c3 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", + "version": "0.0.7.1", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", @@ -46,6 +46,12 @@ ], "softwareRequirements": { "1": { + "@type": "SoftwareApplication", + "identifier": "airtabler", + "name": "airtabler", + "sameAs": "https://github.com/bergant/airtabler" + }, + "2": { "@type": "SoftwareApplication", "identifier": "dplyr", "name": "dplyr", @@ -57,7 +63,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=dplyr" }, - "2": { + "3": { "@type": "SoftwareApplication", "identifier": "gh", "name": "gh", @@ -69,7 +75,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=gh" }, - "3": { + "4": { "@type": "SoftwareApplication", "identifier": "gt", "name": "gt", @@ -81,7 +87,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=gt" }, - "4": { + "5": { "@type": "SoftwareApplication", "identifier": "lubridate", "name": "lubridate", @@ -93,7 +99,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=lubridate" }, - "5": { + "6": { "@type": "SoftwareApplication", "identifier": "memoise", "name": "memoise", @@ -105,7 +111,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=memoise" }, - "6": { + "7": { "@type": "SoftwareApplication", "identifier": "tidyr", "name": "tidyr", @@ -119,5 +125,5 @@ }, "SystemRequirements": null }, - "fileSize": "39.933KB" + "fileSize": "41.907KB" } diff --git a/man/editor_vacation_status.Rd b/man/editor_vacation_status.Rd new file mode 100644 index 0000000..d3d38af --- /dev/null +++ b/man/editor_vacation_status.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/editors-airtable.R +\name{editor_vacation_status} +\alias{editor_vacation_status} +\title{Get current vacation status of all rOpenSci editors.} +\usage{ +editor_vacation_status(quiet = FALSE) +} +\value{ +A `data.frame` with one row per editor and information on current +vacation status obtained from rOpenSci's airtable database. +} +\description{ +Get current vacation status of all rOpenSci editors. +}