我正在做一个游戏化网络应用程序来帮助维基媒体的社区健康。
我想找出哪些编辑在上周编辑了与“Jake”相同的页面最多或最后一次编辑 100 次或类似的内容。
我知道我的查询,但我不知道我需要什么表,因为 Wikimedia DB 布局一团糟。
所以,我想获得类似的东西
用户名 | 出现次数 | 页面 |
---|---|---|
米奇 | 13 | 奥巴马,... |
所以查询将类似于(我正在接受建议):
- 获取用户“Jake”在上周编辑的页面。
- 获取上周该页面的贡献者。
- 对于这些贡献者中的每一个,获取他们在上周编辑的页面,看看它们是否与“Jake”编辑的页面匹配并计算它们。
我尝试在Pywikibot中做一些更简单的事情,但它非常非常慢(Jake 的最后 500 次贡献需要 20 秒)。
我只获取编辑过的页面并获取该页面的贡献者并仅计算它们,这非常慢。
我的 pywikibot 代码是:
site = Site(langcode, 'wikipedia')
user = User(site, username)
contributed_pages = set()
for page, oldid, ts, comment in user.contributions(total=100, namespaces=[0]):
contributed_pages.add(page)
return get_contributor_ocurrences(contributed_pages,site, username)
和功能
def get_contributor_ocurrences(contributed_pages, site,username):
contributors = []
for page in contributed_pages:
for editor in page.contributors():
if APISite.isBot(self= site,username=editor) or editor==username:
continue
contributors.append(editor)
return Counter(contributors)
PS:我可以访问DB 副本,我想这比 Wikimedia API 或 Pywikibot 快得多