-
Notifications
You must be signed in to change notification settings - Fork 0
/
autopatrolled_candidates.sql
88 lines (87 loc) · 2.13 KB
/
autopatrolled_candidates.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
SELECT
`user_id`,
CONVERT(`user_name` USING 'utf8') AS 'name',
CONVERT(`block_reasons` USING 'utf8') AS 'reason',
`user_editcount` AS 'editcount',
DATE_FORMAT(`user_registration`, '%Y-%m-%d') AS 'regdate'
FROM
(
SELECT
REPLACE(`user_name`, ' ', '_') AS 'uname',
`user_id`,
`user_name`,
`user_editcount`,
`user_registration`
FROM
`user`
WHERE
`user`.`user_editcount` > 1000
AND `user`.`user_id` NOT IN(
SELECT
`ug_user`
FROM
`user_groups`
)
AND (
DATEDIFF(NOW(), `user`.`user_registration`) > 30
OR `user`.`user_registration` IS NULL
)
AND `user`.`user_id` NOT IN(
SELECT
`ipb_user`
FROM
`ipblocks`
)
AND `user`.`user_id` IN(
SELECT
`actor_user`
FROM
`recentchanges_userindex`
JOIN actor_recentchanges ON rc_actor = actor_id
)
) AS q1
LEFT JOIN (
SELECT
GROUP_CONCAT(`comment_text` SEPARATOR ' // ') AS 'block_reasons',
`log_title`
FROM
`logging_logindex`
JOIN `comment_logging` ON `log_comment_id` = `comment_id`
WHERE
`log_type` = 'block'
AND `log_title` IN (
SELECT
REPLACE (`user_name`, ' ', '_') AS 'uname'
FROM
`user`
WHERE
`user`.`user_editcount` > 1000
AND `user`.`user_id` NOT IN(
SELECT
`ug_user`
FROM
`user_groups`
)
AND (
DATEDIFF(NOW(), `user`.`user_registration`) > 30
OR `user`.`user_registration` IS NULL
)
AND `user`.`user_id` NOT IN(
SELECT
`ipb_user`
FROM
`ipblocks`
)
AND `user`.`user_id` IN(
SELECT
`actor_user`
FROM
`recentchanges_userindex`
JOIN actor_recentchanges ON rc_actor = actor_id
)
)
GROUP BY
`log_title`
) AS `user_selection` ON `user_selection`.`log_title` = `q1`.`uname`
ORDER BY
`user_editcount` DESC;