Skip to content

Commit 1079e89

Browse files
authored
Merge pull request #101 from ropensci-review-tools/user-org
fix gh_user data when user has no orgs
2 parents 42629eb + ef1641b commit 1079e89

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: repometrics
22
Title: Metrics for Your Code Repository
3-
Version: 0.1.6.005
3+
Version: 0.1.6.006
44
Authors@R:
55
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265"))

R/data-gh-user.R

+28-20
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,39 @@ gh_user_general_internal <- function (login = "",
6565
)
6666

6767
orgs <- user$organizations$nodes
68-
org_name <- vapply (orgs, function (i) i$name, character (1L))
69-
org_gh_org <- vapply (orgs, function (i) i$resourcePath, character (1L))
70-
org_url <- vapply (orgs, function (i) i$url, character (1L))
71-
org_web_url <- vapply (
72-
orgs,
73-
function (i) null2na_char (i$websiteUrl),
74-
character (1L)
75-
)
76-
org_location <- vapply (
77-
orgs,
78-
function (i) null2na_char (i$location),
79-
character (1L)
80-
)
81-
org_num_members <- vapply (
82-
orgs,
83-
function (i) i$membersWithRole$totalCount,
84-
integer (1L)
85-
)
68+
69+
org_name <- org_gh_org <- org_url <-
70+
org_web_url <- org_location <- character (0L)
71+
org_num_members <- integer (0L)
72+
73+
if (length (orgs) > 0L) {
74+
75+
org_name <- vapply (orgs, function (i) i$name, character (1L))
76+
org_gh_org <- vapply (orgs, function (i) i$resourcePath, character (1L))
77+
org_url <- vapply (orgs, function (i) i$url, character (1L))
78+
org_web_url <- vapply (
79+
orgs,
80+
function (i) null2na_char (i$websiteUrl),
81+
character (1L)
82+
) |> null2na_char ()
83+
org_location <- vapply (
84+
orgs,
85+
function (i) null2na_char (i$location),
86+
character (1L)
87+
) |> null2na_char ()
88+
org_num_members <- vapply (
89+
orgs,
90+
function (i) i$membersWithRole$totalCount,
91+
integer (1L)
92+
)
93+
}
8694

8795
orgs <- data.frame (
8896
name = org_name,
8997
gh_org = org_gh_org,
9098
url = org_url,
91-
web_url = null2na_char (org_web_url),
92-
location = null2na_char (org_location),
99+
web_url = org_web_url,
100+
location = org_location,
93101
num_members = org_num_members
94102
)
95103

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/ropensci-review-tools/repometrics",
99
"issueTracker": "https://github.com/ropensci-review-tools/repometrics/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.1.6.005",
11+
"version": "0.1.6.006",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

0 commit comments

Comments
 (0)