refactor: experts emails pluck
This commit is contained in:
parent
5cd780251b
commit
1502635327
1 changed files with 10 additions and 3 deletions
|
@ -30,11 +30,18 @@ class Expert < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.autocomplete_mails(procedure)
|
def self.autocomplete_mails(procedure)
|
||||||
|
experts = Expert
|
||||||
|
.joins(:experts_procedures, :user)
|
||||||
|
.where(experts_procedures: { procedure: procedure })
|
||||||
|
|
||||||
if procedure.experts_require_administrateur_invitation?
|
if procedure.experts_require_administrateur_invitation?
|
||||||
procedure.experts_procedures.where(revoked_at: nil).map(&:expert).map(&:email).sort
|
experts = experts
|
||||||
else
|
.where(experts_procedures: { revoked_at: nil })
|
||||||
procedure.experts.map(&:email).sort
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
experts
|
||||||
|
.pluck('users.email')
|
||||||
|
.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge(old_expert)
|
def merge(old_expert)
|
||||||
|
|
Loading…
Reference in a new issue