feat(export): can sort by revision first, instead of mixing revisions

This commit is contained in:
Colin Darie 2023-12-22 16:32:21 +01:00
parent d69dc6e2c9
commit 58c00b2d4e
No known key found for this signature in database
GPG key ID: 8C76CADD40253590

View file

@ -104,8 +104,13 @@ class Procedure < ApplicationRecord
TypeDeChamp
.joins(:revision_types_de_champ)
.where(revision_types_de_champ: { id: recents_prtdc })
.order(:private, :position, 'revision_types_de_champ.revision_id': :desc)
.where(revision_types_de_champ: { id: recents_prtdc }).then do |relation|
if feature_enabled?(:export_order_by_revision) # Fonds Verts, en attente d'exports personnalisables
relation.order(:private, 'revision_types_de_champ.revision_id': :desc, position: :asc)
else
relation.order(:private, :position, 'revision_types_de_champ.revision_id': :desc)
end
end
end
end