Skip to content

Commit fd69596

Browse files
authoredJul 9, 2020
Merge pull request #26 from wizeline/bugfix/remove_hardcoded_database_name
Bugfix/remove hardcoded database name
2 parents 7d8c48c + 10f9886 commit fd69596

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed
 

‎db/common_queries.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ DELETE FROM metric WHERE branch='master' AND type=4;
8989
-- commit
9090
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
9191
SELECT repository_id, 'master', 4, COUNT(*), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
92-
FROM gitwize.commit_data
92+
FROM commit_data
9393
GROUP BY repository_id, year, month, day, hour
9494
;
9595
@@ -98,7 +98,7 @@ DELETE FROM metric WHERE branch='master' AND type=3;
9898
-- line added
9999
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
100100
SELECT repository_id, 'master', 3, SUM(addition_loc), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
101-
FROM gitwize.commit_data
101+
FROM commit_data
102102
GROUP BY repository_id, year, month, day, hour
103103
;
104104
@@ -107,7 +107,7 @@ DELETE FROM metric WHERE branch='master' AND type=2;
107107
-- line removed
108108
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
109109
SELECT repository_id, 'master', 2, SUM(deletion_loc), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
110-
FROM gitwize.commit_data
110+
FROM commit_data
111111
GROUP BY repository_id, year, month, day, hour
112112
;
113113
@@ -117,7 +117,7 @@ DELETE FROM metric WHERE branch='master' AND type=5;
117117
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
118118
SELECT repository_id, 'master' as branch, 5 as type, created_year as year,
119119
created_month as month, created_day as day, created_hour as hour, COUNT(*) as value
120-
FROM gitwize.pull_request
120+
FROM pull_request
121121
GROUP BY repository_id, created_year, created_month, created_day, created_hour
122122
;
123123
@@ -127,7 +127,7 @@ DELETE FROM metric WHERE branch='master' AND type=6;
127127
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
128128
SELECT repository_id, 'master' as branch, 6 as type, closed_year as year,
129129
closed_month as month, closed_day as day, closed_hour as hour, COUNT(*) as value
130-
FROM gitwize.pull_request
130+
FROM pull_request
131131
WHERE state = 'merged'
132132
GROUP BY repository_id, closed_year, closed_month, closed_day, closed_hour
133133
;
@@ -138,7 +138,7 @@ DELETE FROM metric WHERE branch='master' AND type=7;
138138
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
139139
SELECT repository_id, 'master' as branch, 7 as type, closed_year as year,
140140
closed_month as month, closed_day as day, closed_hour as hour, COUNT(*) as value
141-
FROM gitwize.pull_request
141+
FROM pull_request
142142
WHERE state = 'rejected'
143143
GROUP BY repository_id, closed_year, closed_month, closed_day, closed_hour
144144
;
@@ -154,7 +154,7 @@ DELETE FROM metric WHERE branch='master' AND type=4 AND repository_id=$repoID;
154154
-- commit
155155
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
156156
SELECT repository_id, 'master', 4, COUNT(*), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
157-
FROM gitwize.commit_data
157+
FROM commit_data
158158
WHERE repository_id=$repoID
159159
GROUP BY repository_id, year, month, day, hour
160160
;
@@ -164,7 +164,7 @@ DELETE FROM metric WHERE branch='master' AND type=3 AND repository_id=$repoID;
164164
-- line added
165165
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
166166
SELECT repository_id, 'master', 3, SUM(addition_loc), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
167-
FROM gitwize.commit_data
167+
FROM commit_data
168168
WHERE repository_id=$repoID
169169
GROUP BY repository_id, year, month, day, hour
170170
;
@@ -174,7 +174,7 @@ DELETE FROM metric WHERE branch='master' AND type=2 AND repository_id=$repoID;
174174
-- line removed
175175
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
176176
SELECT repository_id, 'master', 2, SUM(deletion_loc), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
177-
FROM gitwize.commit_data
177+
FROM commit_data
178178
WHERE repository_id=$repoID
179179
GROUP BY repository_id, year, month, day, hour
180180
;
@@ -185,7 +185,7 @@ DELETE FROM metric WHERE branch='master' AND type=5 AND repository_id=$repoID;
185185
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
186186
SELECT repository_id, 'master' as branch, 5 as type, created_year as year,
187187
created_month as month, created_day as day, created_hour as hour, COUNT(*) as value
188-
FROM gitwize.pull_request
188+
FROM pull_request
189189
WHERE repository_id=$repoID
190190
GROUP BY repository_id, created_year, created_month, created_day, created_hour
191191
;
@@ -196,7 +196,7 @@ DELETE FROM metric WHERE branch='master' AND type=6 AND repository_id=$repoID;
196196
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
197197
SELECT repository_id, 'master' as branch, 6 as type, closed_year as year,
198198
closed_month as month, closed_day as day, closed_hour as hour, COUNT(*) as value
199-
FROM gitwize.pull_request
199+
FROM pull_request
200200
WHERE state = 'merged' AND repository_id=$repoID
201201
GROUP BY repository_id, closed_year, closed_month, closed_day, closed_hour
202202
;
@@ -207,7 +207,7 @@ DELETE FROM metric WHERE branch='master' AND type=7 AND repository_id=$repoID;
207207
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
208208
SELECT repository_id, 'master' as branch, 7 as type, closed_year as year,
209209
closed_month as month, closed_day as day, closed_hour as hour, COUNT(*) as value
210-
FROM gitwize.pull_request
210+
FROM pull_request
211211
WHERE state = 'rejected' AND repository_id=$repoID
212212
GROUP BY repository_id, closed_year, closed_month, closed_day, closed_hour
213213
;

‎db/db_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ DELETE FROM metric WHERE branch='master' AND type=4;
4343
-- commit
4444
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
4545
SELECT repository_id, 'master', 4, COUNT(*), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
46-
FROM gitwize.commit_data
46+
FROM commit_data
4747
GROUP BY repository_id, year, month, day, hour
4848
;
4949
@@ -52,7 +52,7 @@ DELETE FROM metric WHERE branch='master' AND type=3;
5252
-- line added
5353
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
5454
SELECT repository_id, 'master', 3, SUM(addition_loc), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
55-
FROM gitwize.commit_data
55+
FROM commit_data
5656
GROUP BY repository_id, year, month, day, hour
5757
;
5858
@@ -61,7 +61,7 @@ DELETE FROM metric WHERE branch='master' AND type=2;
6161
-- line removed
6262
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
6363
SELECT repository_id, 'master', 2, SUM(deletion_loc), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
64-
FROM gitwize.commit_data
64+
FROM commit_data
6565
GROUP BY repository_id, year, month, day, hour
6666
;
6767
@@ -71,7 +71,7 @@ DELETE FROM metric WHERE branch='master' AND type=5;
7171
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
7272
SELECT repository_id, 'master' as branch, 5 as type, created_year as year,
7373
created_month as month, created_day as day, created_hour as hour, COUNT(*) as value
74-
FROM gitwize.pull_request
74+
FROM pull_request
7575
GROUP BY repository_id, created_year, created_month, created_day, created_hour
7676
;
7777
@@ -81,7 +81,7 @@ DELETE FROM metric WHERE branch='master' AND type=6;
8181
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
8282
SELECT repository_id, 'master' as branch, 6 as type, closed_year as year,
8383
closed_month as month, closed_day as day, closed_hour as hour, COUNT(*) as value
84-
FROM gitwize.pull_request
84+
FROM pull_request
8585
WHERE state = 'merged'
8686
GROUP BY repository_id, closed_year, closed_month, closed_day, closed_hour
8787
;
@@ -92,7 +92,7 @@ DELETE FROM metric WHERE branch='master' AND type=7;
9292
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
9393
SELECT repository_id, 'master' as branch, 7 as type, closed_year as year,
9494
closed_month as month, closed_day as day, closed_hour as hour, COUNT(*) as value
95-
FROM gitwize.pull_request
95+
FROM pull_request
9696
WHERE state = 'rejected'
9797
GROUP BY repository_id, closed_year, closed_month, closed_day, closed_hour
9898
;
@@ -111,7 +111,7 @@ DELETE FROM metric WHERE branch='master' AND type=4 AND repository_id=$repoID;
111111
-- commit
112112
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
113113
SELECT repository_id, 'master', 4, COUNT(*), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
114-
FROM gitwize.commit_data
114+
FROM commit_data
115115
WHERE repository_id=$repoID
116116
GROUP BY repository_id, year, month, day, hour
117117
;
@@ -121,7 +121,7 @@ DELETE FROM metric WHERE branch='master' AND type=3 AND repository_id=$repoID;
121121
-- line added
122122
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
123123
SELECT repository_id, 'master', 3, SUM(addition_loc), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
124-
FROM gitwize.commit_data
124+
FROM commit_data
125125
WHERE repository_id=$repoID
126126
GROUP BY repository_id, year, month, day, hour
127127
;
@@ -131,7 +131,7 @@ DELETE FROM metric WHERE branch='master' AND type=2 AND repository_id=$repoID;
131131
-- line removed
132132
INSERT INTO metric (repository_id, branch, type, value, year, month, day, hour)
133133
SELECT repository_id, 'master', 2, SUM(deletion_loc), year, year*100+month, (year*100+month)*100+day, (year*10000+month*100+day)*100+hour
134-
FROM gitwize.commit_data
134+
FROM commit_data
135135
WHERE repository_id=$repoID
136136
GROUP BY repository_id, year, month, day, hour
137137
;
@@ -142,7 +142,7 @@ DELETE FROM metric WHERE branch='master' AND type=5 AND repository_id=$repoID;
142142
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
143143
SELECT repository_id, 'master' as branch, 5 as type, created_year as year,
144144
created_month as month, created_day as day, created_hour as hour, COUNT(*) as value
145-
FROM gitwize.pull_request
145+
FROM pull_request
146146
WHERE repository_id=$repoID
147147
GROUP BY repository_id, created_year, created_month, created_day, created_hour
148148
;
@@ -153,7 +153,7 @@ DELETE FROM metric WHERE branch='master' AND type=6 AND repository_id=$repoID;
153153
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
154154
SELECT repository_id, 'master' as branch, 6 as type, closed_year as year,
155155
closed_month as month, closed_day as day, closed_hour as hour, COUNT(*) as value
156-
FROM gitwize.pull_request
156+
FROM pull_request
157157
WHERE state = 'merged' AND repository_id=$repoID
158158
GROUP BY repository_id, closed_year, closed_month, closed_day, closed_hour
159159
;
@@ -164,7 +164,7 @@ DELETE FROM metric WHERE branch='master' AND type=7 AND repository_id=$repoID;
164164
INSERT INTO metric(repository_id, branch, type, year, month, day, hour, value)
165165
SELECT repository_id, 'master' as branch, 7 as type, closed_year as year,
166166
closed_month as month, closed_day as day, closed_hour as hour, COUNT(*) as value
167-
FROM gitwize.pull_request
167+
FROM pull_request
168168
WHERE state = 'rejected' AND repository_id=$repoID
169169
GROUP BY repository_id, closed_year, closed_month, closed_day, closed_hour
170170
;

0 commit comments

Comments
 (0)