Don't check org quota visibility if user reads globally #2876
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adopts the approach taken in #2650 and #2638 to eliminate the need for DB queries in the org quotas presenter when the user is a global reader.
This noticeably speeds up GET /v3/organization_quotas for global readers, which currently drags when constructing the relationships block of each response object. On foundations with thousands of orgs constructing the relationships block currently take a very long time (I measured an average of 117 seconds on one foundation with 65,000 orgs, and that's with
per_page=50
(versus 0.035 seconds for the equivalent v2 endpoint)). Currently, a separate DB query is made for each org that org quotas have a relationship with in order to determine whether it is visible to the user - even when we know the user is a global reader.This change skips these expensive queries for users with an admin, admin read-only or global auditor role, and in a test environment with 20,000 orgs, each assigned its own org quota,
/v3/organization_quotas?per_page=50
now takes 0.533 seconds.I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests