-
Notifications
You must be signed in to change notification settings - Fork 0
/
pull_request_report_age.pp
193 lines (172 loc) · 4.55 KB
/
pull_request_report_age.pp
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
dashboard "pull_request_open_age_report" {
title = "GitHub Open Pull Request Age Report"
tags = merge(local.pull_request_common_tags, {
type = "Report"
category = "Age"
})
container {
card {
query = query.open_pull_request_count
width = 2
}
card {
query = query.open_pull_request_24_hours_count
width = 2
type = "info"
}
card {
query = query.open_pull_request_30_days_count
width = 2
type = "info"
}
card {
query = query.open_pull_request_30_90_days_count
width = 2
type = "info"
}
card {
query = query.open_pull_request_90_365_days_count
width = 2
type = "info"
}
card {
query = query.open_pull_request_1_year_count
width = 2
type = "info"
}
}
container {
table {
title = "Open Pull Requests"
query = query.open_pull_request_table
column "url" {
display = "none"
}
column "author_url" {
display = "none"
}
column "repo_url" {
display = "none"
}
column "PR" {
href = "{{.'url'}}"
wrap = "all"
}
column "Author" {
href = "{{.'author_url'}}"
}
column "Repository" {
href = "{{.'repo_url'}}"
}
}
}
}
query "open_pull_request_count" {
sql = <<-EOQ
SELECT
count(*) as value,
'Open PRs' as label
FROM
github_my_repository r
JOIN github_pull_request p ON p.repository_full_name = r.name_with_owner
WHERE
p.state = 'OPEN'
AND r.url LIKE 'https://github.com/UKHSA-Internal/edap%'
EOQ
}
query "open_pull_request_24_hours_count" {
sql = <<-EOQ
SELECT
'< 24 Hours' as label,
count(p.*) as value
FROM
github_my_repository r
JOIN github_pull_request p ON p.repository_full_name = r.name_with_owner
WHERE
p.state = 'OPEN'
AND p.created_at > now() - '1 days'::interval
AND r.url LIKE 'https://github.com/UKHSA-Internal/edap%'
EOQ
}
query "open_pull_request_30_days_count" {
sql = <<-EOQ
SELECT
'1-30 Days' as label,
count(p.*) as value
FROM
github_my_repository r
JOIN github_pull_request p ON p.repository_full_name = r.name_with_owner
WHERE
p.state = 'OPEN'
AND p.created_at between symmetric now() - '1 days' :: interval AND now() - '30 days' :: interval
AND r.url LIKE 'https://github.com/UKHSA-Internal/edap%'
EOQ
}
query "open_pull_request_30_90_days_count" {
sql = <<-EOQ
SELECT
'30-90 Days' as label,
count(p.*) as value
FROM
github_my_repository r
JOIN github_pull_request p ON p.repository_full_name = r.name_with_owner
WHERE
p.state = 'OPEN'
AND p.created_at between symmetric now() - '30 days' :: interval AND now() - '90 days' :: interval
AND r.url LIKE 'https://github.com/UKHSA-Internal/edap%'
EOQ
}
query "open_pull_request_90_365_days_count" {
sql = <<-EOQ
SELECT
'90-365 Days' as label,
count(p.*) as value
FROM
github_my_repository r
JOIN github_pull_request p ON p.repository_full_name = r.name_with_owner
WHERE
p.state = 'OPEN'
AND p.created_at between symmetric now() - '90 days' :: interval AND now() - '365 days' :: interval
AND r.url LIKE 'https://github.com/UKHSA-Internal/edap%'
EOQ
}
query "open_pull_request_1_year_count" {
sql = <<-EOQ
SELECT
'> 1 Year' as label,
count(p.*) as value
FROM
github_my_repository r
JOIN github_pull_request p ON p.repository_full_name = r.name_with_owner
WHERE
p.state = 'OPEN'
AND p.created_at <= now() - '1 year' :: interval
AND r.url LIKE 'https://github.com/UKHSA-Internal/edap%'
EOQ
}
query "open_pull_request_table" {
sql = <<-EOQ
SELECT
'#' || number || ' ' || title as "PR",
repository_full_name as "Repository",
now()::date - p.created_at::date as "Age in Days",
now()::date - p.updated_at::date as "Days Since Last Update",
mergeable as "Mergeable State",
author ->> 'login' as "Author",
author ->> 'url' as "author_url",
case
when author_association = 'NONE' then 'External'
else initcap(author_association)
end as "Author Association",
p.url,
r.url as repo_url
FROM
github_my_repository r
JOIN github_pull_request p ON p.repository_full_name = r.name_with_owner
WHERE
p.state = 'OPEN'
AND r.url LIKE 'https://github.com/UKHSA-Internal/edap%'
ORDER BY
"Age in Days" desc
EOQ
}