-
Notifications
You must be signed in to change notification settings - Fork 9
/
sql.txt
396 lines (312 loc) · 9.91 KB
/
sql.txt
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# This is a collection of the most sql-statments for checkwiki.
#######################################
# new project into database
#####################
1. Dump herunterladen
dumpload
######################
2. Project einfügen
mysql -u sk u_sk_yarrow
select max(id) from cw_project where id != 99;
insert into cw_project (id, project, lang, wikipage, translation_page, last_dump) values ( 80, 'specieswiki', 'species', '', '', '');
######################
3. Dump scannen
perl checkwiki.pl -p specieswiki -m dump
######################
4. Testen ob Fehler in Datenbank
mysql -u sk u_sk_yarrow
select count(*) from cw_error where project ='svwikisource';
######################
# jetzt automatisch
# 5. anlegen der Ausgabedatei svwikisource_error_list.txt (
######################
6. live scan
perl checkwiki.pl -p svwikisource -m live
########################################
create table cw_project
(id bigint,
project varchar(100),
lang varchar(100),
last_dump varchar(100),
wikipage varchar(400),
translation_page varchar(400)
);
drop table cw_dumpscan ;
create table cw_dumpscan
(project varchar(100),
error_id int(12),
title varchar(4000),
error int (8),
notice varchar(4000),
ok int(1),
found datetime);
###########################################################################################
-- Tabele cw_error
create table cw_error(
project varchar(100),
error_id int(12),
title varchar(4000),
error int(8),
notice varchar(4000),
ok int(1),
found datetime
);
create table cw_error_desc(
project varchar(100),
id int(8),
prio int(4),
name varchar(255),
text varchar(4000) ,
name_trans varchar(255),
text_trans varchar(4000)
);
###########################################################################################
-- Table for overview, update by Cronjob with merge
create table cw_overview
(id int(8),
project varchar(100),
lang varchar(100),
errors bigint,
done bigint,
last_dump varchar(4000),
last_update varchar(4000),
project_page varchar(4000),
translation_page varchar(4000)
);
select id,project, lang, errors, done, last_dump, last_update from cw_overview;
-- insert all projects
truncate table cw_overview ;
insert into cw_overview (id, project, lang, last_dump, project_page, translation_page)
(select id, project, lang, last_dump, wikipage, translation_page from cw_project);
-- update done
-- http://dev.mysql.com/doc/refman/5.1/de/update.html
update cw_overview, (
select a.project, IFNULL(b.done,0) done from cw_project a
left outer join(
select count(*) done, project from cw_error where ok = 1 group by project
) b
on a.project = b.project) basis
set cw_overview.done = basis.done
where cw_overview.project = basis.project;
-- update error
update cw_overview, (
select a.project, IFNULL(b.errors,0) errors from cw_project a
left outer join(
select count(*) errors, project from cw_error group by project
) b
on a.project = b.project) basis
set cw_overview.errors = basis.errors
where cw_overview.project = basis.project;
-- update last_dump
update cw_overview, (
select a.project, b.found found from cw_project a
left outer join(
select max(found) found, project from cw_error group by project
) b
on a.project = b.project
) basis
set cw_overview.last_update = basis.found
where cw_overview.project = basis.project;
###########################################################################################
# Tabelle cw_overview_errors
drop table cw_overview_errors;
create table cw_overview_errors
(project varchar(100),
id int(8),
errors bigint,
done bigint,
name varchar(4000),
name_trans varchar(4000),
prio int(8)
);
select project, id, errors, done, name, name_trans, prio from cw_overview_errors;
select project, id, errors, done from cw_overview_errors where project = 'dewiki';
select project, id, errors, done from cw_overview_errors where errors > 0 or done > 0;
select project, 0, sum(errors), sum(done) from cw_overview_errors where project = 'pdcwiki'
union all
select project, prio, sum(errors), sum(done) from cw_overview_errors where project = 'pdcwiki' group by prio order by prio;
select IFNULL(sum(errors),0) ,prio , IFNULL(sum(done),0) from cw_overview_errors where project = 'jawiki' group by prio having prio > 0 order by prio;
-- insert all errors
truncate table cw_overview_errors ;
insert into cw_overview_errors (project, id, name, name_trans, prio, errors, done)
(select project, id, name, name_trans, prio, null, null from cw_error_desc);
-- update error
update cw_overview_errors, (
select a.project, IFNULL(b.errors,0) errors, b.id from cw_project a
left outer join(
select count(*) errors, project, error id
from cw_error
group by project, error
) b
on a.project = b.project) basis
set cw_overview_errors.errors = basis.errors
where cw_overview_errors.project = basis.project
and cw_overview_errors.id = basis.id;
--update done
update cw_overview_errors, (
select a.project, IFNULL(b.done,0)done, b.id from cw_project a
left outer join(
select count(*) done, project, error id
from cw_error
where ok = 1
group by project, error
) b
on a.project = b.project) basis
set cw_overview_errors.done = basis.done
where cw_overview_errors.project = basis.project
and cw_overview_errors.id = basis.id;
--insert errors without detection
insert into cw_overview_errors (project, id, name, name_trans, prio, errors, done)
(select a.project, a.id, a.name, a.name_trans, a.prio, null, null
from cw_error_desc a
left outer join cw_overview_errors b
on (a.id = b.id and a.project=b.project)
where b.project is null
and b.id is null)
;
#############################################################
Statistic for longtime
drop table cw_statistic_all;
create table cw_statistic_all
(project varchar(100),
daytime datetime,
errors bigint);
insert into cw_statistic_all (select project, now(), ifnull(errors,0) + ifnull(done, 0) errors from cw_overview order by project);
--Statistiv for 100 days every error
drop table cw_statistic;
create table cw_statistic
(project varchar(100),
id int(8),
nr int(8),
daytime datetime,
errors bigint);
update cw_statistic set nr=nr+1;
insert into cw_statistic (select project, id, 1 nr, now(), ifnull(errors,0) + ifnull(done, 0) errors from cw_overview_errors order by project, id);
delete from cw_statistic where nr > 100;
#############################################################
Starter
-- table
drop table cw_starter;
create table cw_starter
(project varchar(100),
errors_done bigint,
errors_new bigint,
errors_dump bigint,
errors_change bigint,
errors_old bigint,
last_run_change varchar(100)
);
#############################################################
new
drop table cw_new;
create table cw_new(
project varchar(100),
title varchar(4000),
daytime datetime,
scan_live boolean default false )
;
change
drop table cw_change;
create table cw_change(
project varchar(100),
title varchar(4000),
daytime datetime,
scan_live boolean default false )
;
#############################################################
Templatetiger
drop table tt ;
create table tt
(
project varchar(100),
id int,
title varchar(4000) ,
template int,
name varchar(4000),
number int,
parameter varchar(4000),
value text
)
;
##############################################################
-- Löschen eines Projectes
delete from cw_project where project = 'pdcwiki';
insert into cw_dumpscan values ( 'pdcwiki', 'test3', 123, false);
-- Anzahl gefunder Fehler aller Projecte
select project, count(*)
from cw_dumpscan
where scan_live = false
group by project
order by project;
-- Abfrage nach Anzahl der Fehler für ein Project
select project, error_id, count(*)
from cw_dumpscan
where project = 'dewiki'
group by error_id;
-- Liste aller Error_ID mit ungescannten Artikeln
select error_id, count(*) from
(select *
from cw_dumpscan
where project = 'pdcwiki'
and scan_live = false
) a
group by a.error_id
;
-- Liste mit Artikeln, die noch nicht gescannt wurden
select *
from cw_dumpscan
where project = 'pdcwiki'
and scan_live = false ;
-- jeweils die ersten 5 Artikel ( Beispiel mit Union)
select * from
(select *
from cw_dumpscan
where project = 'pdcwiki'
and scan_live = false
and error_id = 30
limit 5) a
union all
select * from
(select *
from cw_dumpscan
where project = 'pdcwiki'
and scan_live = false
and error_id = 40
limit 5) b
;
- Wie viele dump Artikel noch nicht live gescannt?
select project,count(*) from cw_dumpscan where scan_live = 0 group by project;
-- die ältesten Artikel in der DB
select found from cw_error where project = 'cswiki' and DATEDIFF(now(),found) > 31 order by DATEDIFF(now(),found) desc limit 25;
-- älter als 100 Tage --> old
select project, count(*) from cw_error where DATEDIFF(now(),found) > 100 group by project;
-- Statistik eines Projectes
-- alles
select * from cw_statistic_all where project = 'dewiki';
select * from cw_statistic_all where project = 'dewiki' and DATEDIFF(now(),daytime) = 7 limit 1;
-- Statistik letzte Tage
select a.project , c.errors last, b.errors one, a.errors, a.errors-b.errors diff1, a.errors-c.errors diff7 from (
select project, ifnull(errors,0) errors from cw_statistic_all where project = 'jawiki' and DATEDIFF(now(),daytime) = 0 limit 1
)a join
(
select project, ifnull(errors,0) errors from cw_statistic_all where project = 'jawiki' and DATEDIFF(now(),daytime) = 1 limit 1
)b
on (a.project = b.project)
join
(select project, ifnull(errors,0) errors from cw_statistic_all where project = 'jawiki' and DATEDIFF(now(),daytime) = 7 limit 1
)c
on (a.project = c.project);
;
-- Statistik letzte Tage
select a.project , c.errors last, b.errors one, a.errors, a.errors-b.errors diff1, a.errors-c.errors diff7 from (
select project, ifnull(errors,0) errors from cw_statistic_all where DATEDIFF(now(),daytime) = 0
)a join
(
select project, ifnull(errors,0) errors from cw_statistic_all where DATEDIFF(now(),daytime) = 1
)b
on (a.project = b.project)
join
(select project, ifnull(errors,0) errors from cw_statistic_all where DATEDIFF(now(),daytime) = 7
)c
on (a.project = c.project);
;