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

Fix most-read.json?_edition=EUR&dcr=true endpoint #9553

Closed
ioannakok opened this issue Nov 20, 2023 · 3 comments · Fixed by guardian/frontend#26830
Closed

Fix most-read.json?_edition=EUR&dcr=true endpoint #9553

ioannakok opened this issue Nov 20, 2023 · 3 comments · Fixed by guardian/frontend#26830
Assignees
Labels
Bug Rota Any issues that have come in as part of rota. Useful for the person on rota to track their work.
Milestone

Comments

@ioannakok
Copy link
Contributor

ioannakok commented Nov 20, 2023

It is currently broken. It can be hit in the following edge case: A reader

  1. Is in the Europe edition
  2. Visits an article without a section

const endpoint = `/most-read${
hasSection ? `/${sectionId}` : ''
}.json?_edition=${edition}`;

We haven't found an article yet that does not have a section so this is not likely to affect many readers.

@ioannakok ioannakok changed the title Fix most-read.json?_edition=EUR&dcr=true Fix most-read.json?_edition=EUR&dcr=true endpoint Nov 20, 2023
@ioannakok ioannakok added Rota Any issues that have come in as part of rota. Useful for the person on rota to track their work. Bug labels Nov 20, 2023
@ioannakok ioannakok added this to the Health milestone Nov 20, 2023
@arelra
Copy link
Member

arelra commented Jan 3, 2024

Original post from Mariot:

https://chat.google.com/room/AAAAG9rU0m0/q8w3fX4P1Ao/

@ioannakok
Copy link
Contributor Author

ioannakok commented Jan 3, 2024

The issue

https://api.nextgen.guardianapps.co.uk/most-read.json?_edition=EUR&dcr=true endpoint gives a 404 although it seems possible from the DCR code that it can be hit.

Why is this happening?

  1. DCR makes a request to https://api.nextgen.guardianapps.co.uk/most-read/[sectionId].json?_edition=EUR&dcr=true
  2. When the sectionId is missing from the path the request hits /most-read.json endpoint in onward app.
  3. The controller passes the edition to fetch content from the MostPopularAgent.
  4. The MostPopularAgent refreshes its cache with most viewed data from CAPI.
  5. MostPopularAgent calls CAPI to fetch the content making this query (UK edition example):

https://content.guardianapis.com?show-most-viewed=true&show-elements=all&show-atoms=media&edition=UK&show-rights=syndicatable&show-references=pa-football-competition,pa-football-team,witness-assignment,esa-cricket-match&show-section=true&show-packages=true&show-fields=byline,headline,trail-text,liveBloggingNow,thumbnail,hasStoryPackage,wordcount,shortUrl,commentable,commentCloseDate,starRating,productionOffice&show-tags=all

which redirects to:
https://content.guardianapis.com/uk?show-most-viewed=true&show-elements=all&show-atoms=media&show-rights=syndicatable&show-section=true&show-packages=true&show-fields=byline,headline,trail-text,liveBloggingNow,thumbnail,hasStoryPackage,wordcount,shortUrl,commentable,commentCloseDate,starRating,productionOffice&show-tags=all&show-references=pa-football-competition,pa-football-team,witness-assignment,esa-cricket-match

The CAPI query frontend is making for Europe content is:

https://content.guardianapis.com?show-most-viewed=true&show-elements=all&show-atoms=media&edition=EUR&show-rights=syndicatable&show-references=pa-football-competition,pa-football-team,witness-assignment,esa-cricket-match&show-section=true&show-packages=true&show-fields=byline,headline,trail-text,liveBloggingNow,thumbnail,hasStoryPackage,wordcount,shortUrl,commentable,commentCloseDate,starRating,productionOffice&show-tags=all

Because the Europe id is EUR.

This query does not redirect and returns an empty array, hence the cache is empty for key EUR
image

Query parameter should be edition=EUROPE instead of edition=EUR:

https://content.guardianapis.com?show-most-viewed=true&show-elements=all&show-atoms=media&edition=EUROPE&show-rights=syndicatable&show-references=pa-football-competition,pa-football-team,witness-assignment,esa-cricket-match&show-section=true&show-packages=true&show-fields=byline,headline,trail-text,liveBloggingNow,thumbnail,hasStoryPackage,wordcount,shortUrl,commentable,commentCloseDate,starRating,productionOffice&show-tags=all

Fixing the query for the Europe edition content populates the agent with content and fixes this endpoint. See for a draft solution:

What happens currently with the Most Viewed container for articles in the Europe edition?

It seems to be working fine because all articles have a sectionId. I haven't been able to find one without it. When sectionId is present the content is fetched directly from CAPI and onward app does not return the empty content coming from the MostPopularAgent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Rota Any issues that have come in as part of rota. Useful for the person on rota to track their work.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants