feat(attestation): dossier for preview priorize termine dossier: all data are available

This commit is contained in:
Colin Darie 2024-02-15 16:43:31 +01:00
parent accc5af7d2
commit c5174f7d43
No known key found for this signature in database
GPG key ID: 8C76CADD40253590

View file

@ -995,8 +995,9 @@ class Procedure < ApplicationRecord
def dossier_for_preview(user)
# Try to use a preview or a dossier filled by current user
dossiers.where(for_procedure_preview: true).or(dossiers.not_brouillon)
.order(Arel.sql("CASE WHEN for_procedure_preview = True THEN 1 ELSE 0 END DESC,
CASE WHEN user_id = #{user.id} THEN 1 ELSE 0 END DESC")) \
.order(Arel.sql("CASE WHEN user_id = #{user.id} THEN 1 ELSE 0 END DESC,
CASE WHEN state = 'accepte' THEN 1 ELSE 0 END DESC,
CASE WHEN for_procedure_preview = True THEN 1 ELSE 0 END DESC")) \
.first
end