Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize /org/admin/users/admin_index
app/controllers/users_controller.rb - Both in the super_user case as well as the non-super_user case, Bullet warnings are addressed by modifying the .includes() args app/views/paginable/users/_index.html.erb - This commit removes `presenter = IdentifierPresenter.new(identifiable: user)` and instead accesses `identifier_scheme.name` via the `user` variable. user.identifiers and user.identifiers[i].identifier_scheme are now being eager loaded, whereas IdentifierPresenter was loading IdentifierScheme.for_users for each user. - Analyzing the code below, we can see how there is no difference between `presenter` and `user` when acccessing `.identifiers` and `.identifiers[i].identifier_scheme` ``` # app/views/paginable/users/_index.html.erb <% presenter = IdentifierPresenter.new(identifiable: user) %> <% presenter.identifiers.each do |identifier| %> <p><%= identifier.identifier_scheme.name %></p> # app/presenters/identifier_presenter.rb class IdentifierPresenter attr_reader :schemes, :identifiable def initialize(identifiable:) @Identifiable = identifiable @schemes = load_schemes end def identifiers @identifiable.identifiers end ```
- Loading branch information