]> code.communitydata.science - rises_declines_wikia_code.git/blob - mediawiki_dump_tools/Mediawiki-Utilities/examples/lib.reverts.database.py
add copy of the GPL
[rises_declines_wikia_code.git] / mediawiki_dump_tools / Mediawiki-Utilities / examples / lib.reverts.database.py
1 """
2 Prints the reverting rev_id, rev_id and reverted to rev_id of all reverted
3 revisions made by user with ID 9133062.
4 """
5 from mw.database import DB
6 from mw.lib import reverts
7
8 db = DB.from_params(
9     host="s1-analytics-slave.eqiad.wmnet",
10     read_default_file="~/.my.cnf",
11     user="research",
12     db="enwiki"
13 )
14 revisions = db.revisions.query(user_id=9133062)
15
16 for rev_row in revisions:
17     revert = reverts.database.check_row(db, rev_row)
18     if revert is not None:
19         print("{0} reverted {1} to {2}".format(
20             revert.reverting['rev_id'],
21             rev_row['rev_id'],
22             revert.reverted_to['rev_id'])
23         )

Community Data Science Collective || Want to submit a patch?