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: Rely on Flagsmith Engine for segment evaluation, avoid N+1 queries #3038

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

khvn26
Copy link
Member

@khvn26 khvn26 commented Nov 27, 2023

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

  1. Add the prefetch_related to SDKIdentitiesDeprecated. This solves the traits N+1 query.
  2. Move the mapper invocations out of the related segment iteration loop. This solves the environments N+1 query.

How did you test this code?

@khvn26 khvn26 requested a review from matthewelwell November 27, 2023 12:07
Copy link

vercel bot commented Nov 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2023 10:27am
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2023 10:27am
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2023 10:27am

@github-actions github-actions bot added the api Issue related to the REST API label Nov 27, 2023
@khvn26 khvn26 changed the title fix: Avoid N+1 queries fix: Rely on engine for segments again, avoid N+1 queries Nov 27, 2023
@khvn26 khvn26 force-pushed the fix/n-plus-one-identities-deprecated branch from 9199e9b to 8c0b0b9 Compare November 27, 2023 12:54
@khvn26 khvn26 changed the title fix: Rely on engine for segments again, avoid N+1 queries fix: Rely on Flagsmith Engine for segment evaluation, avoid N+1 queries Nov 27, 2023
Copy link
Contributor

github-actions bot commented Nov 27, 2023

Uffizzi Preview deployment-41511 was deleted.

@codecov-commenter
Copy link

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (e5058ae) 95.73% compared to head (8c0b0b9) 95.88%.
Report is 1 commits behind head on main.

Files Patch % Lines
api/environments/identities/managers.py 62.50% 3 Missing ⚠️
api/environments/identities/views.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3038      +/-   ##
==========================================
+ Coverage   95.73%   95.88%   +0.14%     
==========================================
  Files        1046     1045       -1     
  Lines       30859    30677     -182     
==========================================
- Hits        29544    29414     -130     
+ Misses       1315     1263      -52     

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

@matthewelwell
Copy link
Contributor

@khvn26 it seems like this PR shares a commit with #3039 ?

@khvn26
Copy link
Member Author

khvn26 commented Nov 28, 2023

@matthewelwell This is correct. I'll prefer to merge #3039 first and then this one.

@khvn26
Copy link
Member Author

khvn26 commented Nov 28, 2023

Actually let's just merge this one, there's no value in doing them separately.

@khvn26 khvn26 force-pushed the fix/n-plus-one-identities-deprecated branch from 8c0b0b9 to 5cd1316 Compare November 28, 2023 10:09
@khvn26 khvn26 added this pull request to the merge queue Nov 28, 2023
Merged via the queue into main with commit 616c6be Nov 28, 2023
@khvn26 khvn26 deleted the fix/n-plus-one-identities-deprecated branch November 28, 2023 10:23
Copy link

sentry-io bot commented Nov 28, 2023

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ error: global flags not at the start of the expression at position 1 /api/v1/identities/ View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants