Page MenuHomePhabricator

/pageviews-per-category-monthly/ endpoint returns 404 for some valid categories
Open, Needs TriagePublicBUG REPORT

Description

Some categories are on the allow-list for CIM, and we can verify they work for other endpoints, but no data is returned for /pageviews-per-category-monthly/

Example:

  • Media_contributed_by_Abilene_Christian_University_Library
    • Is in allow-list
    • This works: https://wikimedia.org/api/rest_v1/metrics/commons-analytics/category-metrics-snapshot/Media_contributed_by_Abilene_Christian_University_Library/00000101/99991231
    • This is a 404 Not Found: https://wikimedia.org/api/rest_v1/metrics/commons-analytics/pageviews-per-category-monthly/Media_contributed_by_Abilene_Christian_University_Library/deep/all-wikis/00000101/99991231

In this case, perhaps the cause is 0 page views are being recorded (based on the fact that the snapshot shows no media in use). If that is the case, I would consider this a bug, since 0 views is a valid data point, and the user needs to be able to distinguish a result of 0 from an HTTP error (especially since there is other data in the API response worth accessing even with a 0 page view result, such as knowing which month timestamps were measured).

Event Timeline

Hi @Dominicbm, thanks for the report!

Indeed, categories whose leveraging pages have no pageviews return 404 in the pageviews-per-category-monthly endpoint.
And so do media files whose leveraging pages have no pageviews in the pageviews-per-media-file-monthly endpoint.

I understand that this is annoying from the user's point of view.

Our initial design included metrics for all categories and media files, as you suggested.
However, the sheer number of Commons categories and media files with 0 pageviews in leveraging pages made it so
that most of the storage resources consumed by some of the Commons Impact Metrics datasets were due to those 0-pageview elements.
One of the challenges of this project was reducing its monthly snapshot data size, so that the overall data size was sustainable,
for both the source datasets in our data lake and in our serving layers, and the public dumps to be of a manageable size.
So we made the decision to not store data for those mentioned categories and media files, drastically reducing the size of the datasets.
This allowed us to work with less constraints on other parameters, like the depth of the category tree, and the size of the allow-list, which are also multiplying factors.
It also helped us to deliver the data product on time with the allocated resources.

Hi @Dominicbm, thanks for the report!

Indeed, categories whose leveraging pages have no pageviews return 404 in the pageviews-per-category-monthly endpoint.
And so do media files whose leveraging pages have no pageviews in the pageviews-per-media-file-monthly endpoint.

I understand that this is annoying from the user's point of view.

Our initial design included metrics for all categories and media files, as you suggested.
However, the sheer number of Commons categories and media files with 0 pageviews in leveraging pages made it so
that most of the storage resources consumed by some of the Commons Impact Metrics datasets were due to those 0-pageview elements.
One of the challenges of this project was reducing its monthly snapshot data size, so that the overall data size was sustainable,
for both the source datasets in our data lake and in our serving layers, and the public dumps to be of a manageable size.
So we made the decision to not store data for those mentioned categories and media files, drastically reducing the size of the datasets.
This allowed us to work with less constraints on other parameters, like the depth of the category tree, and the size of the allow-list, which are also multiplying factors.
It also helped us to deliver the data product on time with the allocated resources.

I think I understand what you're saying, but isn't is already possible without storing more data to differentiate between the cases where the category isn't in the allow list vs. the case where the pageviews are 0? I just figured it out as a workaround by checking /pageviews-per-category-monthly/. Isn't there a workflow where rather than storing all the "0"s, you check if the category is valid by other means (such as that), and then you know if it's a valid 0 result that should have a 200 HTTP code, or if it's an actual 404?

You get this 404 even if the category does have page views, such as the specific wiki you put in the parameter doesn't have views (or maybe deep search has views and shallow doesn't, but I don't have an example). e.g.: https://wikimedia.org/api/rest_v1/metrics/commons-analytics/pageviews-per-category-monthly/Media_contributed_by_Colorado_State_University_Libraries/deep/ar.wiktionary/00000101/99991231

It's very simple to figure out in cases like this that the category is in fact loaded and just had no views, if I knew to check for that.