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

Reduce number of queries to preferences db table #1082

Merged
merged 5 commits into from
Dec 11, 2024

Conversation

elfjes
Copy link
Collaborator

@elfjes elfjes commented Dec 11, 2024

Prior to #1072 and this PR, a single request to incidents/ lead to 21 (!) queries to the argus_auth_preferences table 😄. This PR reduces this number by 7 (#1072 takes care of another 12) so that in the end we have only have 2 queries left

  • one for looking up the page_size preference
  • one for looking up all preferences in the context processor

We could try and limit that further, but I don't think that that's worth the effort. One thing I'm thinking of, is a middleware that grabs all preferences and adds them to the Request, so that views, utils, context processors and others can just read them from there.

Other views also benefit from these PRs, but I don't have numbers for them

@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 6 lines in your changes missing coverage. Please review.

Project coverage is 81.18%. Comparing base (bc31fca) to head (f8ea8cb).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/argus/auth/utils.py 50.00% 3 Missing ⚠️
src/argus/htmx/dateformat/views.py 50.00% 1 Missing ⚠️
src/argus/htmx/themes/views.py 50.00% 1 Missing ⚠️
src/argus/htmx/user/views.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1082      +/-   ##
==========================================
- Coverage   81.19%   81.18%   -0.02%     
==========================================
  Files         140      140              
  Lines        5074     5076       +2     
==========================================
+ Hits         4120     4121       +1     
- Misses        954      955       +1     

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

@hmpf hmpf assigned hmpf and elfjes and unassigned hmpf Dec 11, 2024
@hmpf hmpf requested review from hmpf and lunkwill42 December 11, 2024 08:01
src/argus/auth/models.py Outdated Show resolved Hide resolved
src/argus/auth/utils.py Outdated Show resolved Hide resolved
src/argus/auth/utils.py Outdated Show resolved Hide resolved
src/argus/htmx/themes/views.py Outdated Show resolved Hide resolved
@elfjes elfjes requested a review from hmpf December 11, 2024 09:04
@hmpf hmpf added the frontend Affects frontend label Dec 11, 2024
@hmpf hmpf merged commit 622cfad into Uninett:master Dec 11, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Affects frontend performance
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants