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 pageviews_by_document to properly handle article locale #6283

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

escattone
Copy link
Contributor

@escattone escattone commented Oct 9, 2024

mozilla/sumo#1896

The root of the problem was my earlier change to use the actual locale of the KB article displayed to the user (AKA the article_locale) instead of the locale in the URL of the KB article requested (see

article_locale = article_locale if article_locale in VALID_LOCALES else url_locale
). This caused the pageviews_by_document function to return multiple rows for the same (article_locale, slug) pair, which the WikiDocumentVisits.reload_period_from_analytics method wasn't expecting. It only used the last row encountered, so the visits count for many of the WikiDocumentVisits entries was way off.

This PR resolves that by fixing it within the pageviews_by_document function itself, which now returns a dictionary rather than a generator.

@akatsoulas akatsoulas merged commit 1d12c81 into mozilla:main Oct 11, 2024
2 checks passed
@escattone escattone deleted the fix-ga-pageviews-by-document branch October 11, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants