Skip to content

Commit 6955ec2

Browse files
committed
update queries for the rc_user -> rc_actor refactor, see https://www.mediawiki.org/wiki/Manual:Actor_table
1 parent 3c249ee commit 6955ec2

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

weeklypedia/labs/dal.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
"""
18-
TODO: something with protections?
18+
TODO: something with protections? (if we ever do this, remember to use rc_actor/actor, not rc_user, etc.)
1919
here's a query:
2020
select rc_cur_id, rc_title, rc_user_text, rc_params
2121
from recentchanges where
@@ -42,7 +42,7 @@ class RecentChangesSummarizer(object):
4242
SELECT rc_cur_id AS page_id,
4343
rc_title AS title,
4444
COUNT(*) AS edits,
45-
COUNT(DISTINCT rc_user) AS users
45+
COUNT(DISTINCT rc_actor) AS users
4646
FROM recentchanges
4747
WHERE rc_namespace = :namespace
4848
AND rc_type = 0
@@ -56,7 +56,7 @@ class RecentChangesSummarizer(object):
5656
SELECT rc_cur_id AS page_id,
5757
rc_title AS title,
5858
COUNT(*) AS edits,
59-
COUNT(DISTINCT rc_user) AS users
59+
COUNT(DISTINCT rc_actor) AS users
6060
FROM recentchanges
6161
WHERE rc_namespace = :namespace
6262
AND rc_type = 0
@@ -88,26 +88,27 @@ class RecentChangesSummarizer(object):
8888

8989
_activity_query = '''
9090
SELECT COUNT(*) AS edits,
91-
COUNT(DISTINCT rc_user) AS users,
91+
COUNT(DISTINCT rc_actor) AS users,
9292
COUNT(DISTINCT rc_cur_id) AS titles
9393
FROM recentchanges
9494
WHERE rc_namespace = :namespace
9595
AND rc_type = 0
9696
AND rc_timestamp > :start_date;'''
9797

9898
_anon_activity_query = '''
99-
SELECT COUNT(*) AS anon_edits,
100-
COUNT(DISTINCT rc_user_text) AS anon_ip_count,
101-
COUNT(DISTINCT rc_cur_id) AS anon_titles
102-
FROM recentchanges
103-
WHERE rc_namespace = :namespace
104-
AND rc_type = 0
105-
AND rc_timestamp > :start_date
106-
AND rc_user=0;'''
99+
SELECT COUNT(*) AS anon_edits,
100+
COUNT(DISTINCT actor.actor_name) AS anon_ip_count,
101+
COUNT(DISTINCT rc_cur_id) AS anon_titles
102+
FROM recentchanges
103+
LEFT JOIN actor on rc_actor=actor_id
104+
WHERE rc_namespace = :namespace
105+
AND rc_type = 0
106+
AND rc_timestamp > :start_date
107+
AND actor.actor_user IS NULL;'''
107108

108109
_bot_activity_query = '''
109110
SELECT COUNT(*) AS bot_edits,
110-
COUNT(DISTINCT rc_user) AS bot_count,
111+
COUNT(DISTINCT rc_actor) AS bot_count,
111112
COUNT(DISTINCT rc_cur_id) AS bot_titles
112113
FROM recentchanges
113114
WHERE rc_namespace = :namespace

0 commit comments

Comments
 (0)