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 update of GA4 pageview data for questions #6420

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

escattone
Copy link
Contributor

@escattone escattone commented Dec 19, 2024

mozilla/sumo#1913

Notes

  • The Reload Question Traffic Stats weekly cron has been broken for over 5 months. This PR fixes it.
  • There are two problems with the currently released code:
    • The kitsune.sumo.googleanalytics.pageviews_by_question() function returns multiple rows for each question ID -- one for each locale that a question was viewed in during the past 365 days -- and that means that more than 700K rows can be returned in prod. In this PR, it returns a dict with one entry for each question ID where the value of that entry is the total pageviews of the question across all locales, which means over 300K entries in prod.
    • The QuestionVisits.reload_from_analytics() method was causing an OOM error because it was building the instance_by_question_id dict for all questions at once. In this PR, that's now done in batches of 30K.
  • A very minor variation of the code in this PR has already been successfully tested within the prod environment.

@escattone escattone requested a review from akatsoulas December 19, 2024 21:19
Copy link
Contributor

@smithellis smithellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice! It has a few hard to read spots (your clever use of enumerate, for instance, felt a bit inception-like -- but I couldn't think of a better/easier to read way of doing that).

I didn't run this locally (don't think it would work unless I mocked GA or something), but it looks good to me, and the tests work. Approved!

@akatsoulas akatsoulas merged commit 131fba6 into main Jan 8, 2025
2 checks passed
@akatsoulas akatsoulas deleted the fix-update-of-question-pageview-data branch January 8, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants