Skip to content

Commit

Permalink
feat(routing): bulk route only dossiers not termines
Browse files Browse the repository at this point in the history
  • Loading branch information
E-L-T committed Mar 3, 2025
1 parent 9036e0e commit a0dc47e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def create_simple_routing
defaut.destroy!
end

procedure.update!(routing_alert: true) if procedure.dossiers.soumis.any?
procedure.update!(routing_alert: true) if procedure.dossiers.state_en_construction_ou_instruction.any?

flash[:routing_mode] = 'simple'

Expand All @@ -111,7 +111,7 @@ def configurate_custom_routing

procedure.toggle_routing

procedure.update!(routing_alert: true) if procedure.dossiers.soumis.any?
procedure.update!(routing_alert: true) if procedure.dossiers.state_en_construction_ou_instruction.any?

flash[:routing_mode] = 'custom'

Expand Down Expand Up @@ -398,7 +398,7 @@ def export_groupe_instructeurs
end

def bulk_route
dossiers = procedure.dossiers
dossiers = procedure.dossiers.state_not_termine

Check warning on line 401 in app/controllers/administrateurs/groupe_instructeurs_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/administrateurs/groupe_instructeurs_controller.rb#L401

Added line #L401 was not covered by tests

dossiers.update_all(forced_groupe_instructeur: false)

Check warning on line 403 in app/controllers/administrateurs/groupe_instructeurs_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/administrateurs/groupe_instructeurs_controller.rb#L403

Added line #L403 was not covered by tests

Expand Down
1 change: 0 additions & 1 deletion app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def classer_sans_suite(motivation: nil, instructeur: nil, processed_at: Time.zon
scope :state_accepte, -> { where(state: states.fetch(:accepte)) }
scope :state_refuse, -> { where(state: states.fetch(:refuse)) }
scope :state_sans_suite, -> { where(state: states.fetch(:sans_suite)) }
scope :soumis, -> { where(state: SOUMIS) }

scope :archived, -> { where(archived: true) }
scope :not_archived, -> { where(archived: false) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%span
= dsfr_icon("fr-icon-warning-fill fr-mr-1v")
- if @procedure.groupe_instructeurs.any?(&:invalid_rule?)
= t('.routing_alert_with_invalid_rules_html', count: @procedure.dossiers.soumis.count)
= t('.routing_alert_with_invalid_rules_html', count: @procedure.dossiers.state_en_construction_ou_instruction.count)
- else
= t('.routing_alert_html', count: @procedure.dossiers.soumis.count)
= t('.routing_alert_html', count: @procedure.dossiers.state_en_construction_ou_instruction.count)
= button_to t('.bulk_route'), bulk_route_admin_procedure_groupe_instructeurs_path(@procedure), class: 'fr-btn no-wrap', disabled: @procedure.groupe_instructeurs.any?(&:invalid_rule?), data: { disable_with: "Routage en cours…", confirm: t('.bulk_routing_confirm') }
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ en:
one: "%{count} group exist"
other: "%{count} groups exist"
routing_alert_sticky_header:
routing_alert_html: "<strong>%{count} dossiers</strong> have already been deposited on this procedure and have <strong>not been routed according to the configured routing</strong>. You must launch the routing to distribute these files to the different groups."
routing_alert_with_invalid_rules_html: "<strong>%{count} dossiers</strong> have already been deposited on this procedure and have <strong>not yet been routed</strong>. Once you have configured your routing rules, you will need to launch the routing to distribute these files to the different groups."
routing_alert_html: "<strong>%{count} files</strong> have been deposited and are waiting to be processed on this procedure. These files have <strong>not been routed according to the configured routing</strong>. You must launch the routing to distribute them to the different groups."
routing_alert_with_invalid_rules_html: "<strong>%{count} files</strong> have been deposited and are waiting to be processed on this procedure. These files have <strong>not yet been routed</strong>. Once you have configured your routing rules, you will need to launch the routing to distribute them to the different groups."
bulk_route: Launch routing
bulk_routing_confirm: "Are you sure you want to launch the routing for the deposited files?"
bulk_routing_confirm: "Are you sure you want to launch the routing for the deposited files waiting to be processed ?"
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fr:
simple_routing:
procedures: Démarches
routing_alert_sticky_header:
routing_alert_html: "<strong>%{count} dossiers</strong> ont déjà été déposés sur cette démarche et n’ont <strong>pas été routés selon le routage configuré</strong>. Vous devez lancer le routage pour répartir ces dossiers dans les différents groupes."
routing_alert_with_invalid_rules_html: "<strong>%{count} dossiers</strong> ont déjà été déposés sur cette démarche et n’ont <strong>pas encore été routés</strong>. Une fois que vous aurez configuré vos règles de routage, vous devrez lancer le routage pour répartir ces dossiers dans les différents groupes."
routing_alert_html: "Il y a <strong>%{count} dossiers</strong> déposés et en attente de traitement sur cette démarche. Ces dossiers n’ont <strong>pas été routés selon le routage configuré</strong>. Vous devez lancer le routage pour les répartir dans les différents groupes."
routing_alert_with_invalid_rules_html: "Il y a <strong>%{count} dossiers</strong> déposés et en attente de traitement sur cette démarche. Ces dossiers n’ont <strong>pas encore été routés</strong>. Une fois que vous aurez configuré vos règles de routage, vous devrez lancer le routage pour les répartir dans les différents groupes."
bulk_route: Lancer le routage
bulk_routing_confirm: "Êtes-vous sûr de vouloir lancer le routage pour les dossiers déposés ?"
bulk_routing_confirm: "Êtes-vous sûr de vouloir lancer le routage pour les dossiers déposés et en attente de traitement ?"
Original file line number Diff line number Diff line change
Expand Up @@ -1103,17 +1103,21 @@ def remove_instructeur(instructeur)
let!(:drop_down_tdc) { procedure.draft_revision.types_de_champ.first }
let!(:dossier1) { create(:dossier, :with_populated_champs, procedure: procedure, state: :en_construction) }
let!(:dossier2) { create(:dossier, :with_populated_champs, procedure: procedure, state: :en_construction) }
let!(:dossier3) { create(:dossier, :with_populated_champs, procedure: procedure, state: :accepte) }

before do
dossier1.champs.first.update(value: 'Paris')
dossier2.champs.first.update(value: 'Lyon')
dossier3.champs.first.update(value: 'Marseille')
post :create_simple_routing, params: { procedure_id: procedure.id, create_simple_routing: { stable_id: drop_down_tdc.stable_id } }
post :bulk_route, params: { procedure_id: procedure.id }
end

it do
it 'routes only dossiers en construction or en instruction' do
expect(dossier1.reload.groupe_instructeur.label).to eq 'Paris'
expect(dossier2.reload.groupe_instructeur.label).to eq 'Lyon'
expect(dossier3.reload.groupe_instructeur.label).to eq 'Lyon'
# Lyon is default group
expect(procedure.reload.routing_alert).to be_falsey
end
end
Expand Down

0 comments on commit a0dc47e

Please sign in to comment.