From 9017d4fd7786ad2f5357ccdbae10237840a060b3 Mon Sep 17 00:00:00 2001 From: mpadge Date: Wed, 7 Feb 2024 12:21:56 +0100 Subject: [PATCH] add gh query code for #3 --- DESCRIPTION | 2 +- R/gh-queries.R | 75 +++++++++++++++++++++++++++++++++++++++++++++++++- codemeta.json | 2 +- 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e82607f..28dee7d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dashboard Title: What the Package Does (One Line, Title Case) -Version: 0.0.0.011 +Version: 0.0.0.012 Authors@R: person(given = "First", family = "Last", diff --git a/R/gh-queries.R b/R/gh-queries.R index 9bb06f1..6bd6d9c 100644 --- a/R/gh-queries.R +++ b/R/gh-queries.R @@ -6,7 +6,8 @@ get_gh_token <- function (token = "") { ) } -#' The GitHub GraphQL query. +#' The GitHub GraphQL query to extract information from all software-review +#' issues. #' #' @param org The GitHub organization. #' @param repo The GitHub repository. @@ -87,3 +88,75 @@ gh_issues_qry <- function (org = "ropensci", return (q) } + +#' The GitHub GraphQL query to extract members of 'editors' team +#' +#' @return The GraphQL query to pass to a `gh::gh_gql()` call. +#' @noRd +gh_editors_team_qry <- function (stats = FALSE) { + + team <- ifelse (stats, "stats-board", "editors") + + q <- paste0 ("{ + organization(login:\"ropensci\") { + team(slug: \"", team, "\") { + members(first: 100, membership: IMMEDIATE) { + nodes { + login + } + } + } + } + }") + + return (q) +} + +#' Reduced version of 'gh_issues_qry()' that only returns issue assignees (= +#' editors). +#' +#' @param org The GitHub organization. +#' @param repo The GitHub repository. +#' @param end_cursor The end cursor from the previous query. +#' +#' @return The GraphQL query to pass to a `gh::gh_gql()` call. +#' @noRd +gh_issue_assignees_qry <- function (org = "ropensci", + repo = "software-review", + end_cursor = NULL) { + + after_txt <- "" + if (!is.null (end_cursor)) { + after_txt <- paste0 (", after:\"", end_cursor, "\"") + } + + q <- paste0 ("{ + repository(owner:\"", org, "\", name:\"", repo, "\") { + issues (first: 100", after_txt, ") { + pageInfo { + hasNextPage + endCursor + } + edges { + node { + ... on Issue { + number + state + updatedAt + assignees (first: 100) { + nodes { + name + login + } + } + title + url + } + } + } + } + } + }") + + return (q) +} diff --git a/codemeta.json b/codemeta.json index 6a8037f..2d1ebc1 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.0.011", + "version": "0.0.0.012", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R",