diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 73d70eda6..504cf671a 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -76,7 +76,7 @@ module Instructeurs @has_termine_notifications = notifications[:termines].present? @not_archived_notifications_dossier_ids = notifications[:en_cours] + notifications[:termines] - filtered_sorted_ids = procedure_presentation.filtered_sorted_ids(dossiers, @dossiers_count, statut) + filtered_sorted_ids = procedure_presentation.filtered_sorted_ids(dossiers, statut, count: @dossiers_count) page = params[:page].presence || 1 diff --git a/app/models/export.rb b/app/models/export.rb index 78e595546..a62872c5b 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -168,7 +168,7 @@ class Export < ApplicationRecord dossiers.visible_by_administration.where('dossiers.depose_at > ?', since) elsif procedure_presentation.present? filtered_sorted_ids = procedure_presentation - .filtered_sorted_ids(dossiers, dossiers.size, statut) + .filtered_sorted_ids(dossiers, statut) dossiers.where(id: filtered_sorted_ids) else diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 4382a02b5..c2edecc70 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -182,9 +182,9 @@ class ProcedurePresentation < ApplicationRecord end.reduce(:&) end - def filtered_sorted_ids(dossiers, count, statut) + def filtered_sorted_ids(dossiers, statut, count: nil) dossiers_by_statut = dossiers.by_statut(instructeur, statut) - dossiers_sorted_ids = self.sorted_ids(dossiers_by_statut, count) + dossiers_sorted_ids = self.sorted_ids(dossiers_by_statut, count || dossiers_by_statut.size) if filters[statut].present? filtered_ids(dossiers_by_statut, statut).intersection(dossiers_sorted_ids)