-
Notifications
You must be signed in to change notification settings - Fork 26
/
open_prs_sigs_milestones.sql
185 lines (185 loc) · 4.49 KB
/
open_prs_sigs_milestones.sql
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
with dtfrom as (
select '{{to}}'::timestamp - '1 year'::interval as dtfrom
), issues as (
select sub.issue_id,
sub.event_id,
sub.milestone_id,
sub.repo
from (
select distinct
id as issue_id,
dup_repo_name as repo,
last_value(event_id) over issues_ordered_by_update as event_id,
last_value(closed_at) over issues_ordered_by_update as closed_at,
last_value(milestone_id) over issues_ordered_by_update as milestone_id
from
gha_issues,
dtfrom
where
created_at >= dtfrom
and created_at < '{{to}}'
and updated_at < '{{to}}'
and is_pull_request = true
window
issues_ordered_by_update as (
partition by id
order by
updated_at asc,
event_id asc
range between current row
and unbounded following
)
) sub
where
sub.closed_at is null
), prs as (
select distinct i.issue_id,
i.event_id,
i.milestone_id,
i.repo
from (
select distinct id as pr_id,
last_value(closed_at) over prs_ordered_by_update as closed_at,
last_value(merged_at) over prs_ordered_by_update as merged_at
from
gha_pull_requests,
dtfrom
where
created_at >= dtfrom
and created_at < '{{to}}'
and updated_at < '{{to}}'
and event_id > 0
window
prs_ordered_by_update as (
partition by id
order by
updated_at asc,
event_id asc
range between current row
and unbounded following
)
) pr,
issues i,
gha_issues_pull_requests ipr
where
ipr.issue_id = i.issue_id
and ipr.pull_request_id = pr.pr_id
and pr.closed_at is null
and pr.merged_at is null
), prs_sigs as (
select sub2.issue_id,
sub2.repo,
case sub2.sig
when 'aws' then 'cloud-provider'
when 'azure' then 'cloud-provider'
when 'batchd' then 'cloud-provider'
when 'cloud-provider-aws' then 'cloud-provider'
when 'gcp' then 'cloud-provider'
when 'ibmcloud' then 'cloud-provider'
when 'openstack' then 'cloud-provider'
when 'vmware' then 'cloud-provider'
else sub2.sig
end as sig
from (
select sub.issue_id,
sub.repo,
sub.sig
from (
select pr.issue_id,
pr.repo,
lower(substring(il.dup_label_name from '(?i)sig/(.*)')) as sig
from
prs pr,
gha_issues_labels il
where
pr.event_id = il.event_id
and pr.issue_id = il.issue_id
) sub
where
sub.sig is not null
and sub.sig not in (
'apimachinery', 'api-machiner', 'cloude-provider', 'nework',
'scalability-proprosals', 'storge', 'ui-preview-reviewes',
'cluster-fifecycle', 'rktnetes'
)
and sub.sig not like '%use-only-as-a-last-resort'
) sub2
where
sub2.sig in (select sig_mentions_labels_name from tsig_mentions_labels)
), prs_milestones as (
select pr.issue_id,
pr.repo,
ml.title as milestone
from
prs pr,
gha_milestones ml
where
pr.milestone_id = ml.id
and pr.event_id = ml.event_id
)
select
sub.sig_milestone,
sub.cnt
from (
select concat('prsigml,', s.sig, '-', m.milestone, '-', s.repo) as sig_milestone,
count(s.issue_id) as cnt
from
prs_milestones m,
prs_sigs s
where
m.issue_id = s.issue_id
group by
s.sig,
m.milestone,
s.repo
union select concat('prsigml,', 'All-', m.milestone, '-', m.repo) as sig_milestone,
count(m.issue_id) as cnt
from
prs_milestones m
group by
m.milestone,
m.repo
union select concat('prsigml,', s.sig, '-All-', s.repo) as sig_milestone,
count(s.issue_id) as cnt
from
prs_sigs s
group by
s.sig,
s.repo
union select concat('prsigml,All-All-', pr.repo) as sig_milestone,
count(pr.issue_id) as cnt
from
prs pr
group by
pr.repo
union select concat('prsigml,', s.sig, '-', m.milestone, '-All') as sig_milestone,
count(s.issue_id) as cnt
from
prs_milestones m,
prs_sigs s
where
m.issue_id = s.issue_id
group by
s.sig,
m.milestone
union select concat('prsigml,', 'All-', m.milestone, '-All') as sig_milestone,
count(m.issue_id) as cnt
from
prs_milestones m
group by
m.milestone
union select concat('prsigml,', s.sig, '-All-All') as sig_milestone,
count(s.issue_id) as cnt
from
prs_sigs s
group by
s.sig
union select 'prsigml,All-All-All' as sig_milestone,
count(pr.issue_id) as cnt
from
prs pr
) sub
order by
sub.cnt desc,
sub.sig_milestone asc
;