2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class MembersPreloader
|
|
|
|
attr_reader :members
|
|
|
|
|
|
|
|
def initialize(members)
|
|
|
|
@members = members
|
|
|
|
end
|
|
|
|
|
|
|
|
def preload_all
|
2023-05-27 22:25:52 +05:30
|
|
|
user_associations = [:status]
|
|
|
|
user_associations << :webauthn_registrations if Feature.enabled?(:webauthn)
|
|
|
|
|
|
|
|
ActiveRecord::Associations::Preloader.new(
|
|
|
|
records: members,
|
|
|
|
associations: [
|
|
|
|
:source,
|
|
|
|
:created_by,
|
|
|
|
{ user: user_associations }
|
|
|
|
]
|
|
|
|
).call
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
MembersPreloader.prepend_mod_with('MembersPreloader')
|