Skip to content

Commit

Permalink
add gh query code for #3
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Feb 7, 2024
1 parent a97e5f4 commit 9017d4f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 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.0.0.011
Version: 0.0.0.012
Authors@R:
person(given = "First",
family = "Last",
Expand Down
75 changes: 74 additions & 1 deletion R/gh-queries.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
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.0.0.011",
"version": "0.0.0.012",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit 9017d4f

Please sign in to comment.