spec: improve performances of notification_mailer_preview
The time to find the last dossier could be very long for large procedures.
This commit is contained in:
parent
36f5a98b26
commit
e8b6731af8
1 changed files with 1 additions and 2 deletions
|
@ -26,8 +26,7 @@ class NotificationMailerPreview < ActionMailer::Preview
|
|||
end
|
||||
|
||||
def dossier_with_image
|
||||
procedure = Procedure.where(id: Mails::InitiatedMail.where("body like ?", "%<img%").pluck(:procedure_id).uniq).order("RANDOM()").first
|
||||
procedure.dossiers.last
|
||||
Dossier.joins(procedure: [:initiated_mail]).where("initiated_mails.body like ?", "%<img%").order('RANDOM()').first
|
||||
end
|
||||
|
||||
def dossier_with_motivation
|
||||
|
|
Loading…
Reference in a new issue