Updated the query logic for scope :with_template_and_user_counts. It is now significantly faster (see table at bottom of description).
app/views/paginable/orgs/_index.html.erb
Updated the code to correspond with the changes made in app/models/org.rb.
The code updated in this file is for determining whether or not a listed Org should have the delete option enabled. These PR changes should result in the same exact Orgs having the delete option enabled as before.
Refactoring:
To reflect these changes, scope: Org.with_template_and_user_counts has been renamed to scope: 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 equivalent left_outer_joins(:templates)
The following table compares the development branch to aaron/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).
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).