Skip to content

Commit

Permalink
dossier_attribute_task : update with latest sql request
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Sep 25, 2024
1 parent 9e5e887 commit 45bc5b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/tasks/maintenance/dossier_attributes_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ class DossierAttributesTask < MaintenanceTasks::Task
no_collection

def process
champs = Champ.private_only.where(dossier:)
order = Arel.sql("COALESCE(revision_types_de_champ_types_de_champ.position, procedure_revision_types_de_champ.position), \
COALESCE(champs.row_id,' '), procedure_revision_types_de_champ.position")
ordered_champs = Champ.private_only.where(dossier:)
.joins(type_de_champ: :revision_types_de_champ)
.includes(:type_de_champ)
.where(procedure_revision_types_de_champ: { revision_id: dossier.revision_id })
.left_joins(parent: { type_de_champ: :revision_types_de_champ })
.includes(type_de_champ: :revision_type_de_champ)
.order(Arel.sql("coalesce(revision_types_de_champ_types_de_champ.position, procedure_revision_types_de_champ.position)," +
" COALESCE(champs.row_id,' '), procedure_revision_types_de_champ.position"))
.where(revision_types_de_champ_types_de_champ: { revision_id: [dossier.revision_id, nil] })
.order(order)
AdministrateurMailer.champ_description(User.find(2), champs).deliver_now
end
end
Expand Down

0 comments on commit 45bc5b7

Please sign in to comment.