debian-mirror-gitlab/app/controllers/concerns/members_presentation.rb

20 lines
647 B
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
module MembersPresentation
extend ActiveSupport::Concern
def present_members(members)
2018-11-18 11:00:15 +05:30
preload_associations(members)
2018-03-17 18:26:18 +05:30
Gitlab::View::Presenter::Factory.new(
members,
current_user: current_user,
presenter_class: MembersPresenter
).fabricate!
end
2018-11-18 11:00:15 +05:30
def preload_associations(members)
ActiveRecord::Associations::Preloader.new.preload(members, :user)
ActiveRecord::Associations::Preloader.new.preload(members, :source)
ActiveRecord::Associations::Preloader.new.preload(members.map(&:user), :status)
ActiveRecord::Associations::Preloader.new.preload(members.map(&:user), :u2f_registrations)
end
2018-03-17 18:26:18 +05:30
end