Page MenuHomePhabricator

Documentation of -recentchanges is misleading
Closed, ResolvedPublic

Description

The documentation states:

-recentchanges      Work on the pages with the most recent changes. If
	            given as -recentchanges:x, will work on the x most recently
	            changed pages. [...]

However, this is not truth.

return RecentChangesPageGenerator(
  namespaces=self.namespaces, total=total, start=rcstart, end=rcend,
  site=self.site, reverse=True, tag=rctag,
  _filter_unique=self._filter_unique)
@param reverse: if True, start with oldest changes (default: newest)

The reverse=True argument will make the generator start from the oldest changes.
The solution could be to change the value to False in case of this kind of input but this make the behavior inconsistent with the other kinds of input.

Event Timeline

Xqt triaged this task as Medium priority.Jul 10 2018, 10:22 AM
Xqt added a subscriber: Dalba.
Xqt added a subscriber: darthbhyrava.

No glue why this rdirection change was introduced with T129193; I propose to revert it as suggested.

I am interesting in taking this up. Should I go ahead and make reverse = False ?

I am interesting in taking this up. Should I go ahead and make reverse = False ?

Let's do it! :)

Change 445338 had a related patch set uploaded (by AdityaJ; owner: AdityaJ):
[pywikibot/core@master] Fix Bug: T199199 Change-Id: I823683

https://gerrit.wikimedia.org/r/445338

Change 445338 had a related patch set uploaded (by AdityaJ; owner: AdityaJ):
[pywikibot/core@master] Change from reverse=True to reverse=False

https://gerrit.wikimedia.org/r/445338

Change 445338 merged by jenkins-bot:
[pywikibot/core@master] Changed "reverse" argument of RecentChangesPageGenerator function to False

https://gerrit.wikimedia.org/r/445338

zhuyifei1999 assigned this task to AdityaJ.
Dalba reopened this task as Open.EditedJul 12 2018, 11:30 AM

tests.pagegenerators_tests.TestFactoryGenerator.test_recentchanges_timespan started to fail after this change was merged.

https://travis-ci.org/wikimedia/pywikibot/jobs/403022851#L3648

_______________ TestFactoryGenerator.test_recentchanges_timespan _______________
self = <tests.pagegenerators_tests.TestFactoryGenerator testMethod=test_recentchanges_timespan>
    def test_recentchanges_timespan(self):
        """Test recentchanges generator with offset and duration params."""
        gf = pagegenerators.GeneratorFactory(site=self.site)
>       gf.handleArg('-recentchanges:120,70')
tests/pagegenerators_tests.py:999: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pywikibot/pagegenerators.py:1160: in handleArg
    handler_result = handler(value)
pywikibot/pagegenerators.py:818: in _handle_recentchanges
    _filter_unique=self._filter_unique)
pywikibot/tools/__init__.py:1450: in wrapper
    return obj(*__args, **__kw)
pywikibot/pagegenerators.py:1389: in RecentChangesPageGenerator
    user=user, excludeuser=excludeuser, tag=tag)
pywikibot/tools/__init__.py:1450: in wrapper
    return obj(*__args, **__kw)
pywikibot/site.py:4710: in recentchanges
    self.assert_valid_iter_params('recentchanges', start, end, reverse)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = APISite("en", "musicbrainz"), msg_prefix = 'recentchanges'
start = Timestamp(2018, 7, 12, 8, 23, 7), end = Timestamp(2018, 7, 12, 9, 33, 7)
reverse = False
    def assert_valid_iter_params(self, msg_prefix, start, end, reverse):
        """Validate iterating API parameters."""
        if reverse:
            if end < start:
                raise Error(msg_prefix +
                            ': end must be later than start with reverse=True')
        elif start < end:
            raise Error(msg_prefix +
>                       ': start must be later than end with reverse=False')
E           pywikibot.exceptions.Error: recentchanges: start must be later than end with reverse=False
pywikibot/site.py:2279: Error

Change 445388 had a related patch set uploaded (by Zhuyifei1999; owner: Zhuyifei1999):
[pywikibot/core@master] Revert "Changed "reverse" argument of RecentChangesPageGenerator function to False"

https://gerrit.wikimedia.org/r/445388

@Dalba I think jenkins hates me, and I gtg in a few minutes. Could you get the revert merged and cherry pick the original patch to master so we can build upon the original patch?

Change 445388 merged by jenkins-bot:
[pywikibot/core@master] Revert "Changed "reverse" argument of RecentChangesPageGenerator function to False"

https://gerrit.wikimedia.org/r/445388

Change 445392 had a related patch set uploaded (by Zhuyifei1999; owner: AdityaJ):
[pywikibot/core@master] Changed "reverse" argument of RecentChangesPageGenerator function to False

https://gerrit.wikimedia.org/r/445392

Change 445956 had a related patch set uploaded (by AdityaJ; owner: AdityaJ):
[pywikibot/core@master] In return statement of RecentChangesPageGenerator if rcstart > rcend then reverse = True and when rcstart < rcend then reverse = False

https://gerrit.wikimedia.org/r/445956

Change 445994 had a related patch set uploaded (by AdityaJ; owner: AdityaJ):
[pywikibot/core@master] In function def RecentChangesPageGenerator swap the values of start and end if reverse = True

https://gerrit.wikimedia.org/r/445994

Change 445994 abandoned by Xqt:
In function def RecentChangesPageGenerator swap the values of start and end if reverse = True

Reason:
https://gerrit.wikimedia.org/r/#/c/pywikibot/core/ /445956/

https://gerrit.wikimedia.org/r/445994

Xqt reassigned this task from AdityaJ to Dalba.

Change 445392 merged by jenkins-bot:
[pywikibot/core@master] pagegenerators._handle_recentchanges: Do not request for reversed results

https://gerrit.wikimedia.org/r/445392

Change 445956 abandoned by Xqt:
In return statement of RecentChangesPageGenerator if rcstart > rcend then reverse = True and when rcstart < rcend then reverse = False

Reason:
https://gerrit.wikimedia.org/r/#/c/pywikibot/core/ /445392/

https://gerrit.wikimedia.org/r/445956