feat(routing): add routing engine

This commit is contained in:
simon lehericey 2023-03-29 10:47:43 +02:00 committed by Eric Leroy-Terquem
parent b93e3776c4
commit 3cede55d41
3 changed files with 58 additions and 0 deletions

View file

@ -455,6 +455,8 @@ module Users
@dossier.assign_to_groupe_instructeur(groupe_instructeur_from_params)
end
RoutingEngine.compute(@dossier)
if dossier.en_construction?
errors += @dossier.check_mandatory_and_visible_champs
end

View file

@ -0,0 +1,9 @@
module RoutingEngine
def self.compute(dossier)
matching_groupe = dossier.procedure.groupe_instructeurs.active.find do |gi|
gi.routing_rule&.compute(dossier.champs)
end
matching_groupe ||= dossier.procedure.defaut_groupe_instructeur
dossier.update!(groupe_instructeur: matching_groupe)
end
end