Skip to content

Commit a079c57

Browse files
committed
Bullet fixes for /org_admin/plans (superuser)
app/views/org_admin/plans/index.html.erb: - .length loads the records into memory. Because we are eager-loading other tables (see code changes in app/controllers/org_admin/plans_controller.rb), this was triggering a "AVOID eager loading detected" Bullet warning. Because we are in fact making use of these related tables further in the code, the warnings themselves appear to be false-positives. However, the change to this file manages to suppresses the Bullet warnings, and is still very fast.
1 parent 935433c commit a079c57

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

app/controllers/org_admin/plans_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def index
1717

1818
@super_admin = current_user.can_super_admin?
1919
@clicked_through = params[:click_through].present?
20-
@plans = @super_admin ? Plan.all.page(1) : current_user.org.org_admin_plans.page(1)
20+
@plans = @super_admin ? Plan.all.page(1).includes(:template, roles: { user: :org }) : current_user.org.org_admin_plans.page(1)
2121
end
2222
# rubocop:enable Metrics/AbcSize
2323

app/views/org_admin/plans/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</div>
3535
</div>
3636
<% end %>
37-
<% if @plans.length > 0 %>
37+
<% if @plans.any? %>
3838
<% unless @super_admin %>
3939
<%= link_to sanitize(_('Download plans <em class="sr-only">(new window)</em><span class="new-window-popup-info">%{open_in_new_window_text}</span>') %
4040
{ open_in_new_window_text: _('Opens in new window') },

0 commit comments

Comments
 (0)