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(get_permitted_projects): get rid of distinct #4320

Merged
merged 3 commits into from
Jul 10, 2024

Conversation

gagantrivedi
Copy link
Member

@gagantrivedi gagantrivedi commented Jul 10, 2024

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

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • 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

Refactor get_permitted_projects_for_user to use 4 small queries(each taking less than 1ms) instead of one giant query using distinct

Feature permission: Let view do the permission check for list action

How did you test this code?

Adds/updates unit tests

Copy link

vercel bot commented Jul 10, 2024

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 9:10am
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 9:10am
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 9:10am

@github-actions github-actions bot added api Issue related to the REST API fix labels Jul 10, 2024
Copy link
Contributor

github-actions bot commented Jul 10, 2024

Uffizzi Preview deployment-54029 was deleted.

@gagantrivedi gagantrivedi force-pushed the fix/4242/optimize-query branch from a8040e5 to 4d03569 Compare July 10, 2024 06:39
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
@gagantrivedi gagantrivedi force-pushed the fix/4242/optimize-query branch from 4d03569 to 4e35608 Compare July 10, 2024 06:47
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
Use multiple small queries instead of distinct for
better performance
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
@gagantrivedi gagantrivedi force-pushed the fix/4242/optimize-query branch from db84759 to ebe2dfb Compare July 10, 2024 07:47
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.61%. Comparing base (288a47e) to head (50d141e).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4320   +/-   ##
=======================================
  Coverage   96.60%   96.61%           
=======================================
  Files        1196     1196           
  Lines       39113    39123   +10     
=======================================
+ Hits        37787    37797   +10     
  Misses       1326     1326           

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

@gagantrivedi gagantrivedi marked this pull request as ready for review July 10, 2024 07:57
@gagantrivedi gagantrivedi requested a review from a team as a code owner July 10, 2024 07:57
@gagantrivedi gagantrivedi requested review from zachaysan and removed request for a team July 10, 2024 07:57
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
Copy link
Contributor

github-actions bot commented Jul 10, 2024

flagsmith-e2e image build finished ✨

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-4320 Finished ✅ Skipped

Copy link
Contributor

github-actions bot commented Jul 10, 2024

flagsmith image build and security scan finished ✨

Image Build Status Security report
ghcr.io/flagsmith/flagsmith:pr-4320 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Jul 10, 2024

flagsmith-private-cloud image build and security scan finished ✨

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4320 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Jul 10, 2024

flagsmith-frontend image build and security scan finished ✨

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-frontend:pr-4320 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Jul 10, 2024

flagsmith-api image build and security scan finished ✨

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api:pr-4320 Finished ✅ Results

@github-actions github-actions bot removed the fix label Jul 10, 2024
@github-actions github-actions bot added the fix label Jul 10, 2024
@gagantrivedi gagantrivedi force-pushed the fix/4242/optimize-query branch from 4ada29b to 3b26f65 Compare July 10, 2024 08:15
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
@gagantrivedi gagantrivedi force-pushed the fix/4242/optimize-query branch from 3b26f65 to 44f4755 Compare July 10, 2024 08:34
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
object_ids.update(
list(for_model.objects.filter(group_filter).values_list("id", flat=True))
)
if settings.IS_RBAC_INSTALLED:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if settings.IS_RBAC_INSTALLED:
if settings.IS_RBAC_INSTALLED: # pragma: no cover

This will exclude all the code from the if branch.

@gagantrivedi gagantrivedi force-pushed the fix/4242/optimize-query branch from 44f4755 to ed8727e Compare July 10, 2024 08:54
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
@gagantrivedi gagantrivedi force-pushed the fix/4242/optimize-query branch from ed8727e to 50d141e Compare July 10, 2024 09:10
@github-actions github-actions bot added fix and removed fix labels Jul 10, 2024
@@ -3102,7 +3121,7 @@ def test_feature_list_last_modified_values(
Feature.objects.create(name=f"feature_{i}", project=project)

# When
with django_assert_num_queries(19): # TODO: reduce this number of queries!
with django_assert_num_queries(18): # TODO: reduce this number of queries!
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! First time I've actually seen this number go down in a while! 😄

@gagantrivedi gagantrivedi added this pull request to the merge queue Jul 10, 2024
Merged via the queue into main with commit e7252cb Jul 10, 2024
32 checks passed
@gagantrivedi gagantrivedi deleted the fix/4242/optimize-query branch July 10, 2024 09:19
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 fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants