Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error by one" in the definition of the radius of revert detection? #22

Closed
he7d3r opened this issue Jan 25, 2015 · 2 comments
Closed

"Error by one" in the definition of the radius of revert detection? #22

he7d3r opened this issue Jan 25, 2015 · 2 comments

Comments

@he7d3r
Copy link
Contributor

he7d3r commented Jan 25, 2015

The API provides the following excerpt of the history of a page:

                    {
                        "revid": 40689105,
                        "parentid": 40686393,
                        "sha1": "2143678744b3ff595b998daa11f97e366212e18e"
                    },
                    {
                        "revid": 40686393,
                        "parentid": 40679748,
                        "sha1": "84c489b7d568795b3da6696968f1483893b6519b"
                    },
                    {
                        "revid": 40679748,
                        "parentid": 40632743,
                        "sha1": "2143678744b3ff595b998daa11f97e366212e18e"
                    }

However,

from mw.api import Session
from mw.lib import reverts
session = Session("https://pt.wikipedia.org/w/api.php")
reverts.api.check_rev(session, {'revid':40679748,'pageid':40677}, radius=1)

returns nothing and

reverts.api.check_rev(session, {'revid':40679748,'pageid':40677}, radius=2)

returns

Revert(reverting={'revid': 40686393, 'page': {'title': 'João Figueiredo', 'pageid': 40677, 'ns': 0}, 'sha1': '84c489b7d568795b3da6696968f1483893b6519b', 'parentid': 40679748, 'timestamp': '2014-11-23T17:40:23Z'}, reverteds=[{'revid': 40679748, 'page': {'title': 'João Figueiredo', 'pageid': 40677, 'ns': 0}, 'sha1': '2143678744b3ff595b998daa11f97e366212e18e', 'parentid': 40632743, 'timestamp': '2014-11-22T22:24:20Z'}, {'revid': 40679748, 'page': {'title': 'João Figueiredo', 'pageid': 40677, 'ns': 0}, 'sha1': '2143678744b3ff595b998daa11f97e366212e18e', 'parentid': 40632743, 'timestamp': '2014-11-22T22:24:20Z'}], reverted_to={'revid': 40632743, 'page': {'title': 'João Figueiredo', 'pageid': 40677, 'ns': 0}, 'sha1': '84c489b7d568795b3da6696968f1483893b6519b', 'parentid': 40396585, 'timestamp': '2014-11-17T03:24:51Z'})

Therefore, I believe there is an "error by one" somewhere in the definition of the radius ("the maximum number of revisions that can be reverted"), because this is the simplest revert case where a single revision is reverted right after it is saved (A --> B --> A).

@he7d3r
Copy link
Contributor Author

he7d3r commented Feb 3, 2015

Compare with

>>> from mw.lib import reverts
>>> detector = reverts.Detector(radius=1)
>>> detector.process("aaa", {'rev_id': 1})
>>> detector.process("bbb", {'rev_id': 2})
>>> detector.process("aaa", {'rev_id': 3})
Revert(reverting={'rev_id': 3}, reverteds=[{'rev_id': 2}], reverted_to={'rev_id': 1})

which works fine (the radius here is defined as "the maximum revision distance that a revert can span")

@halfak
Copy link
Member

halfak commented Feb 3, 2015

Fixed in. a293667

And released as v0.4.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants