Optimise and Refactor Org.with_template_and_user_counts
#3431
+8
−7
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.
Changes proposed in this PR:
app/models/org.rb
scope :with_template_and_user_counts
. It is now significantly faster (see table at bottom of description).app/views/paginable/orgs/_index.html.erb
app/models/org.rb
.delete
option enabled. These PR changes should result in the same exact Orgs having thedelete
option enabled as before.Refactoring:
To reflect these changes,
scope: Org.with_template_and_user_counts
has been renamed toscope: Org.with_template_count_and_associations_check
throughout the codebase.In
app/models/org.rb
,joins('LEFT OUTER JOIN templates ON orgs.id = templates.org_id')
has been replaced with the equivalentleft_outer_joins(:templates)
The following table compares the
development
branch toaaron/optimize-scope-with_template_and_user_counts
by making requests to the various paths affected by this PR. The benchmarking was performed via ab - Apache HTTP server benchmarking tool alongside a recent (May 2024) db dump from the production environment of DMP Assistant. In both cases, 100 consecutive requests were performed to each path and the recorded result is the mean request time (ms).