Skip to content

feat(feedback): cache the feedback summary #93461

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

Merged
merged 12 commits into from
Jun 18, 2025

Conversation

vishnupsatish
Copy link
Member

Hopefully this one doesn't ping the whole company

@vishnupsatish vishnupsatish requested a review from a team as a code owner June 12, 2025 17:47
@vishnupsatish vishnupsatish requested a review from a team June 12, 2025 17:47
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 12, 2025
Copy link

codecov bot commented Jun 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #93461      +/-   ##
==========================================
+ Coverage   88.03%   88.09%   +0.05%     
==========================================
  Files       10335    10324      -11     
  Lines      596828   595765    -1063     
  Branches    23196    22992     -204     
==========================================
- Hits       525432   524852     -580     
+ Misses      70937    70481     -456     
+ Partials      459      432      -27     

@vishnupsatish
Copy link
Member Author

Changed cache key to: projects selected and year, month, day of start and end dates. Also made the cache time out after 1 hour. This is done so that if the same filters are selected, the cache stays the same for at least an hour and wouldn't immediately change if new feedbacks are submitted. Also, the time of the start and end dates are not used since if they were, the cache would become useless.


# Cache key should be the filters that were selected by the user, and the cache should time out after 1 hour
# For date range, only use year, month, and day since including the time would make the cache useless
summary_cache_key = f"feedback_summary:{organization.id}:{start.strftime('%Y-%m-%d')}:{end.strftime('%Y-%m-%d')}:{hashed_project_ids}"
Copy link
Member

Choose a reason for hiding this comment

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

It wouldn't be useless to include the time. Including the time up to the hour still gives you an hour long cache except it has the granularity to discern ranges between the potential two day window outlined above.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if granularity up to the hour is needed, as I'm just thinking if the feedbacks that may be submitted within one day are enough to justify changing the feedback every hour. Maybe they are

Copy link
Member

Choose a reason for hiding this comment

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

it really depends on the org size - for sentry javascript i don't think we even get enough feedbacks to justify recalculating a summary every hour

Copy link
Member Author

@vishnupsatish vishnupsatish Jun 13, 2025

Choose a reason for hiding this comment

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

Yeah, that's true. But also, if a user chooses the stat period to be the last hour, they'd probably expect a different summary than if they chose the last 24 hours, but not including the hour may mean that those two stat periods result in the same summary, potentially confusing UX there.

Copy link
Member Author

@vishnupsatish vishnupsatish Jun 16, 2025

Choose a reason for hiding this comment

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

hmm, read this again and I'm not too sure what you mean by "discern ranges between the potential two day window outlined above", since the cache times out after an hour anyways. Or is that better done by adding the hour in the cache key and timing out in 2 hours (or more)? (cc: @cmanallen)

Edit: never mind, got confused here, I think it does make sense to add hour to the cache key

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, django's default seems to be five minutes but I don't know if we've overridden that anywhere. I'll set it to one day just to be on the safer side

Copy link
Member

Choose a reason for hiding this comment

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

Why raise it to one day? Timeout should match the granularity right?

Copy link
Member Author

@vishnupsatish vishnupsatish Jun 16, 2025

Choose a reason for hiding this comment

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

Curious but why does timeout have to match granularity? For custom date ranges, an hour timeout seems too short. And if the stats period includes the current time, by including hour don't we regenerate every hour anyways?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I was thinking about this wrong, 1 day seems good to me. To summarize my understanding

  • users looking at hour-level views will likely use relative time ranges, through statsPeriod and "last X hours" view. These naturally update every hour with the cache key.
  • users looking at fixed time ranges will likely do it at day+ granularity using the calendar selector we have in the UI. These will update every day with the cache timeout.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that understanding matches what I had in mind. Including hour in the cache key also allows the distinction between different hour-level time ranges to be made (within the same day).

@vishnupsatish vishnupsatish merged commit 9ce2093 into master Jun 18, 2025
64 checks passed
@vishnupsatish vishnupsatish deleted the vishnupsatish/uf-summary-cache branch June 18, 2025 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants