Skip to content

Optimize event processing to avoid N+1 queries - #364

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
n1-query-9cfvsu
Closed

Optimize event processing to avoid N+1 queries#364
cursor[bot] wants to merge 1 commit into
mainfrom
n1-query-9cfvsu

Conversation

@cursor

@cursor cursor Bot commented Nov 21, 2025

Copy link
Copy Markdown

Adds per-request caching for user potato statistics to eliminate redundant SUM queries.

The potatoSentToday and potatoLeftToday methods were executing identical database queries multiple times within a single request. This change introduces a lightweight cache on the User entity, ensuring these methods only query the daily potato count once per request and potatoLeftToday derives its value from the cached potatoSentToday result.


Open in Cursor Open in Web

Co-authored-by: jenn.muengtaweepongsa <jenn.muengtaweepongsa@sentry.io>
@cursor

cursor Bot commented Nov 21, 2025

Copy link
Copy Markdown
Author

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@codecov

codecov Bot commented Nov 21, 2025

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Nov 21, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.04%. Comparing base (b6005c8) to head (0f95e26).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #364      +/-   ##
============================================
- Coverage     26.20%   26.04%   -0.16%     
- Complexity      323      324       +1     
============================================
  Files            77       77              
  Lines          3247     3240       -7     
============================================
- Hits            851      844       -7     
  Misses         2396     2396              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cleptric cleptric closed this Feb 13, 2026
@cleptric
cleptric deleted the n1-query-9cfvsu branch February 13, 2026 15:54
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.

2 participants