From d1530b40a108f00a432f18f13cb5f7ebdc6ff715 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 15 Oct 2024 13:28:44 +0200 Subject: [PATCH] use the filter_service --- .../instructeurs/procedures_controller.rb | 2 +- app/models/export.rb | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 59797c67a..2d9b4b26f 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -95,7 +95,7 @@ module Instructeurs @has_export_notification = notify_exports? @last_export = last_export_for(statut) - @filtered_sorted_ids = procedure_presentation.filtered_sorted_ids(dossiers, statut, count: dossiers_count) + @filtered_sorted_ids = DossierFilterService.filtered_sorted_ids(dossiers, statut, procedure_presentation.filters_for(statut), procedure_presentation.sorted_column, current_instructeur, count: dossiers_count) page = params[:page].presence || 1 @dossiers_count = @filtered_sorted_ids.size diff --git a/app/models/export.rb b/app/models/export.rb index 0eeff606a..436020a2c 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -140,8 +140,8 @@ class Export < ApplicationRecord if since.present? dossiers.visible_by_administration.where('dossiers.depose_at > ?', since) elsif procedure_presentation.present? - filtered_sorted_ids = procedure_presentation - .filtered_sorted_ids(dossiers, statut) + instructeur = instructeur_from(user_profile) + filtered_sorted_ids = DossierFilterService.filtered_sorted_ids(dossiers, statut, filtered_columns, sorted_column, instructeur) dossiers.where(id: filtered_sorted_ids) else @@ -150,6 +150,15 @@ class Export < ApplicationRecord end end + def instructeur_from(user_profile) + case user_profile + when Administrateur + user_profile.instructeur + when Instructeur + user_profile + end + end + def blob service = ProcedureExportService.new(procedure, dossiers_for_export, user_profile, export_template)