-
Notifications
You must be signed in to change notification settings - Fork 1
/
04-issues-analyze.R
151 lines (133 loc) · 4.54 KB
/
04-issues-analyze.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
source("00-global.R")
issues_tbl <- qs::qread("03-issues_tbl.qs")
issues_comments_tbl <- qs::qread("03-issues_comments_tbl.qs")
issues_tbl |>
count(issue_author_association)
my_issues_tbl <-
issues_tbl |>
transmute(
repo,
issue_url,
number,
state,
issue_created_at,
issue_closed_at,
issue_user_login = user$login,
issue_author_association,
issue_author_is_member = (issue_author_association == "MEMBER"),
issue_is_pr = !is.na(pull_request$url),
issue_html_url,
)
my_issues_tbl |>
nrow() |>
as.character() |>
writeLines("all-issues.txt")
my_issues_tbl |>
select(issue_created_at) |>
filter(lubridate::year(issue_created_at) >= 2022) |>
nrow() |>
as.character() |>
writeLines("new-issues.txt")
issues_comments_tbl |>
count(author_association)
my_issues_comments_tbl <-
issues_comments_tbl |>
transmute(
id,
issue_url,
user_login = user$login,
author_is_member = (author_association == "MEMBER"),
created_at
)
issues_vs_first_member_comment <-
my_issues_comments_tbl |>
filter(author_is_member) |>
filter(row_number() == 1, .by = issue_url) |>
full_join(my_issues_tbl, join_by(issue_url))
issues_vs_first_member_comment |>
count(issue_author_is_member, author_is_member, state)
# Unresponded issues
issues_vs_first_member_comment |>
filter(!issue_author_is_member & is.na(author_is_member) & state == "open") |>
pull() |>
# walk(browseURL)
identity()
# Slow issues
issues_vs_first_member_comment |>
mutate(time = as.numeric(created_at - issue_created_at) / 86400) |>
filter(clock::get_year(issue_created_at) >= 2022) |>
filter(!issue_is_pr) |>
filter(time >= 14) |>
pull(issue_html_url) |>
# walk(browseURL)
identity()
my_issues_tbl |>
filter(!issue_is_pr) |>
mutate(year = lubridate::year(issue_created_at)) |>
mutate(issue_author_association = factor(issue_author_association, levels = c("MEMBER", "CONTRIBUTOR", "NONE"))) |>
ggplot(aes(factor(year), fill = issue_author_association)) +
geom_bar() +
labs(
x = "Year",
y = "Number of issues",
fill = "Author association",
title = "Issues opened per year"
) +
theme(axis.text.x = element_text(angle = 90, hjust = 0, vjust = 0.5))
ggsave("issues_per_year.png", width = 10, height = 6, dpi = "retina", scale = 0.8)
issues_vs_first_member_comment |>
filter(!issue_author_is_member) |>
mutate(new = clock::get_year(issue_created_at) >= 2022) |>
mutate(time = as.numeric(created_at - issue_created_at) / 86400) |>
filter(!is.na(time)) |>
mutate(time_bin = santoku::chop(
trunc(time),
as.integer(c(0, 1, 4, 7, 14)),
labels = santoku::lbl_glue("<{r}", last = ">{l}")
)) |>
count(new, issue_is_pr, time_bin) |>
mutate(issue_is_pr = ifelse(issue_is_pr, "Pull requests", "Issues")) |>
mutate(new = ifelse(new, "2022 and later", "Before 2022")) |>
ggplot(aes(time_bin, n)) +
geom_col() +
scale_y_continuous() +
labs(
x = "Time to first response (days)",
y = "Number of issues",
title = "Time to first response for issues and pull requests",
) +
facet_grid(vars(new), vars(issue_is_pr), scales = "free_y")
ggsave("time_to_first_response.png", width = 10, height = 6, dpi = "retina", scale = 0.8)
issues_vs_first_member_comment |>
filter(!issue_author_is_member) |>
mutate(new = clock::get_year(issue_created_at) >= 2022) |>
mutate(time = as.numeric(issue_closed_at - issue_created_at) / 86400) |>
mutate(human = (issue_user_login != "github-actions[bot]")) |>
filter(!is.na(time)) |>
mutate(time_bin = santoku::chop(
trunc(time),
as.integer(c(0, 1, 4, 7, 14, 28, 90, 180, 360)),
labels = santoku::lbl_glue("<{r}", last = ">{l}")
)) |>
count(new, issue_is_pr, human, time_bin) |>
mutate(issue_is_pr = ifelse(issue_is_pr, "Pull requests", "Issues")) |>
mutate(new = ifelse(new, "2022 and later", "Before 2022")) |>
mutate(human = ifelse(human, "Human", "Bot")) |>
ggplot(aes(time_bin, n, fill = human)) +
geom_col() +
scale_y_continuous() +
labs(
x = "Time to close (days)",
y = "Number of issues",
fill = "Issue author",
title = "Time to close for issues and pull requests",
) +
facet_grid(vars(new), vars(issue_is_pr), scales = "free_y")
ggsave("time_to_close.png", width = 10, height = 6, dpi = "retina", scale = 0.8)
issues_vs_first_non_member_comment <-
my_issues_comments_tbl |>
full_join(my_issues_tbl, join_by(issue_url)) |>
filter(issue_user_login != user_login) |>
filter(row_number() == 1, .by = issue_url) |>
mutate(new = clock::get_year(issue_created_at) >= 2022) |>
count(new, author_is_member)