Page MenuHomePhabricator

Homepage: "Invalid parameters" for Pageviews from Impact module
Closed, ResolvedPublic

Description

The bug exists in production - e.g. cswiki wmf.8.

  1. https://test.wikipedia.org/wiki/Special:Impact/Zilant17 the mavetuna article will show 11 views
    Screen Shot 2019-06-19 at 11.00.55 AM.png (521×1 px, 65 KB)
  2. Click on the link to view Pageviews page - the error will be displayed and the default range will show only 1 view.
<a class="pageviews" href="https://tools.wmflabs.org/pageviews/?project=test.wikipedia.org&amp;userlang=en&amp;start=2016-03-23&amp;end=2019-06-19&amp;pages=Mavetuna" title="See detailed page views" data-link-id="impact-pageviews">11</a>

So, the link https://tools.wmflabs.org/pageviews/?project=test.wikipedia.org&userlang=en&start=2016-03-23&end=2019-06-19&pages=Mavetuna will result in the error displayed and default data range:

Screen Shot 2019-06-19 at 11.03.44 AM.png (658×1 px, 447 KB)

  1. The same data range applied manually works without any errors:

https://tools.wmflabs.org/pageviews/?project=test.wikipedia.org&platform=all-access&agent=user&start=2019-03-23&end=2019-06-18&pages=Mavetuna

Understanding what's shown on Pageviews page might be challenging for users, especially with the confusing error displayed and the mismatch between the numbers in Impact module and for default data range on Pageviews.

Event Timeline

Change 518281 had a related patch set uploaded (by Sbisson; owner: Sbisson):
[mediawiki/extensions/GrowthExperiments@master] Impact: pageviews URL end should be yesterday

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

Change 518281 merged by jenkins-bot:
[mediawiki/extensions/GrowthExperiments@master] Impact: pageviews URL end should be yesterday

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

Etonkovidova updated the task description. (Show Details)

@SBisson -- I am reopening this task because I am still getting errors when opening the pageviews. @Catrope has some ideas on why this is happening.

See this video: https://drive.google.com/file/d/1SjMKwccywYr04iUuGI4RTUuSbciA_3jn/view. What I'm doing is:

  1. Going to my homepage.
  2. Opening an article I edited and showing the date that I edited it.
  3. Going back to my homepage and clicking to view its pageview details.
  4. I get the error message.
  5. I do this twice, so you can see that the URL changes quickly after I start loading the page, and changes around the dates.

I think this happens because the logic that getPageViewsToolUrl() uses seems to use the wiki's local timezone, whereas the pageviews tool operates using UTC. cswiki's local time is UTC+2 in summer, so for the two hours between 00:00 and 02:00 local time (22:00-00:00 UTC, 15:00-17:00 PDT), they will disagree on what day it is:

catrope@mwdebug1002:~$ date
Mon Jul  1 23:30:33 UTC 2019

catrope@mwdebug1002:~$ mwscript eval.php enwiki
>  echo date( 'Y-m-d', strtotime( '-1 days' ) );
2019-06-30

catrope@mwdebug1002:~$ mwscript eval.php cswiki
>  echo date( 'Y-m-d', strtotime( '-1 days' ) );
2019-07-01

This would be worse on kowiki, which uses UTC+9, so the window where it breaks there would be 00:00-09:00 local time (15:00-00:00 UTC, 08:00-17:00 PDT).

There also appears to be a separate bug in the pageviews tool itself, where (on July 1st) this URL for June 9th - July 1st gets normalized to June 11th - 30th, but the same URL with June 30th as the end date doesn't get normalized. The June 9th -> 11th change doesn't make sense to me (and doesn't happen if the end date isn't too far in the future).

I can also make the pageviews tool ignore end dates that are after the max date (yesterday midnight), and simply use the max date. What's happening now is it is using the defaults when there is an invalid date range, which is the latest 20 days of data.

I want to double-check, do you only want the latest N days of data? If so, use range=latest-20 (where 20 is the number of days) instead of setting start and end.

I can also make the pageviews tool ignore end dates that are after the max date (yesterday midnight), and simply use the max date. What's happening now is it is using the defaults when there is an invalid date range, which is the latest 20 days of data.

Thanks, that would be helpful!

I want to double-check, do you only want the latest N days of data? If so, use range=latest-20 (where 20 is the number of days) instead of setting start and end.

Thanks for the tip, but the start date isn't range-based, it's the first day the user edited the article. The end date is always yesterday. Is end=latest (or something like it) supported?

Sometimes, the start date we send can be invalid too (farther in the past than the tool allows), this happens if the user first edited the page a long time ago. It would also be very handy if that got normalized to the earliest allowed date rather than the default.

I've added earliest as a value for the start parameter, and latest for end.

If the given date range is outside what is allowed, it normalizes to the min/max dates accordingly. However, it still shows a warning. This is because some people will for instance put a date older than 2015-07-01 expecting it to work, and we need to tell them that it doesn't.

To save you the trouble of adding logic to use earliest/latest, I've also added a way to mute the validations. To do this, append mutevalidations=true. The tool will still normalize to valid dates, only it won't show a warning. E.g. https://tools.wmflabs.org/pageviews/?project=cs.wikipedia.org&start=2010-06-09&end=2030-07-02&pages=Joni_Mitchell&mutevalidations=true

Everything is documented at https://tools.wmflabs.org/pageviews/url_structure

Hope this helps!

Change 520928 had a related patch set uploaded (by Sbisson; owner: Sbisson):
[mediawiki/extensions/GrowthExperiments@master] Impact: fix pageviews URLs

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

@MusikAnimal Thanks for enhancing the pageviews tools this way! This is really helpful and simplifies the way we build the URLs.

Change 520928 merged by jenkins-bot:
[mediawiki/extensions/GrowthExperiments@master] Impact: fix pageviews URLs

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