User:DreamRimmer bot/Task5.py
# @[[:en:User:DreamRimmer]]
import pywikibot, toolforge
from pywikibot.data import api
with toolforge.connect('enwiki_p') as conn:
cur = conn.cursor()
cur.execute("""
SELECT t.page_id,t.page_title,t.actor_name,t.log_timestamp,
TIMESTAMPDIFF(SECOND,t.prev_ts,t.log_timestamp) AS gap_seconds
FROM(
SELECT page.page_id,page.page_title,log_timestamp,actor_name,
LAG(log_timestamp) OVER(PARTITION BY actor_name ORDER BY log_timestamp) AS prev_ts
FROM actor
JOIN logging_userindex ON log_actor=actor_id
JOIN page ON page_title=log_title AND page_namespace=log_namespace
WHERE log_action='reviewed-article'
AND log_type='pagetriage-curation'
AND log_timestamp BETWEEN '20250901' AND '20250928'
AND actor_name='Agent VII'
AND log_namespace=0
AND page_is_redirect=0
) t
LEFT JOIN categorylinks cl ON t.page_id=cl.cl_from AND cl.cl_to='All_disambiguation_pages'
WHERE TIMESTAMPDIFF(SECOND,t.prev_ts,t.log_timestamp)<60
AND t.page_title NOT IN(
SELECT page_title FROM page
JOIN pagetriage_page ON page_id=ptrp_page_id
WHERE ptrp_reviewed=0 AND page_is_redirect=0 AND page_namespace=0
)
AND t.page_title NOT IN(
SELECT DISTINCT p.page_title
FROM logging_userindex l
JOIN actor a ON l.log_actor=a.actor_id
JOIN page p ON l.log_page=p.page_id
WHERE l.log_action='reviewed-article'
AND l.log_type='pagetriage-curation'
AND l.log_timestamp BETWEEN '20250928' AND DATE_FORMAT(CURDATE(), '%Y%m%d')
AND a.actor_name!='Agent VII'
AND p.page_namespace=0
AND p.page_is_redirect=0
)
AND cl.cl_from IS NULL;
""")
results = cur.fetchall()
print(f"{len(results)} pages to unreview")
site = pywikibot.Site("wikipedia:en")
token_request = api.Request(site=site, parameters={'action': 'query', 'meta': 'tokens'})
csrf_token = token_request.submit()['query']['tokens']['csrftoken']
for row in results:
page_id = row[0]
page_title = row[1]
if isinstance(page_title, bytes):
page_title = page_title.decode('utf-8')
params = {'action': 'pagetriageaction', 'pageid': page_id, 'enqueue': True, 'token': csrf_token, 'skipnotif': True}
response = api.Request(site=site, parameters=params).submit()
print(f"Processed {page_title}: {response}")
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.