-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueries.sql
More file actions
152 lines (145 loc) · 2.57 KB
/
queries.sql
File metadata and controls
152 lines (145 loc) · 2.57 KB
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
.mode markdown
-- Common queries to generate stats like in example.md
-- Total commits in release train
select
COUNT(*) as total_commits
from
commits
where
major_version = <MAJOR_VERSION>;
-- Total releases
select
COUNT(*) as total_releases
from
releases
where
major_version = <MAJOR_VERSION>;
-- Total minor releases
select
COUNT(*) as minor_releases
from
releases
where
major_version = <MAJOR_VERSION>
and is_minor = 1;
-- Commits by type (all)
select
type,
COUNT(*) as count
from
commits
where
major_version = <MAJOR_VERSION>
and type is not null
group by
type
order by
count desc;
-- Commits by type (excluding dependency updates)
select
type,
COUNT(*) as count
from
commits
where
major_version = <MAJOR_VERSION>
and type is not null
and is_dependency_update = 0
group by
type
order by
count desc;
-- Top 10 scopes
select
scope,
COUNT(*) as count
from
commits
where
major_version = <MAJOR_VERSION>
and scope is not null
and is_dependency_update = 0
group by
scope
order by
count desc
limit
10;
-- Dates with most releases
select
release_date as date,
COUNT(*) as num_releases
from
releases
where
major_version = <MAJOR_VERSION>
group by
release_date
order by
num_releases desc
limit
3;
-- Find longest stream of consecutive commit days
with RECURSIVE commit_dates as (
select
distinct commit_date
from
commits
where
major_version = <MAJOR_VERSION>
order by
commit_date
),
date_gaps as (
select
commit_date,
LAG(commit_date) OVER (
order by
commit_date
) as prev_date,
julianday(commit_date) - julianday(
LAG(commit_date) OVER (
order by
commit_date
)
) as day_diff
from
commit_dates
),
streak_groups as (
select
commit_date,
SUM(
case
when day_diff > 1
or day_diff is null then 1
else 0
end
) OVER (
order by
commit_date
) as streak_id
from
date_gaps
),
streaks as (
select
streak_id,
MIN(commit_date) as start_date,
MAX(commit_date) as end_date,
julianday(MAX(commit_date)) - julianday(MIN(commit_date)) + 1 as days
from
streak_groups
group by
streak_id
)
select
days,
start_date,
end_date
from
streaks
order by
days desc
limit
1;