refactor: experts emails pluck

This commit is contained in:
simon lehericey 2024-04-16 13:33:37 +02:00
parent 5cd780251b
commit 1502635327
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5

View file

@ -30,11 +30,18 @@ class Expert < ApplicationRecord
end
def self.autocomplete_mails(procedure)
experts = Expert
.joins(:experts_procedures, :user)
.where(experts_procedures: { procedure: procedure })
if procedure.experts_require_administrateur_invitation?
procedure.experts_procedures.where(revoked_at: nil).map(&:expert).map(&:email).sort
else
procedure.experts.map(&:email).sort
experts = experts
.where(experts_procedures: { revoked_at: nil })
end
experts
.pluck('users.email')
.sort
end
def merge(old_expert)