From ecbabf6cbd2594f4020784312b371af36b5865bf Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Fri, 2 Aug 2024 18:59:36 +0200 Subject: [PATCH] Skip swap between members of the same group --- app/services/tables/swap.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/tables/swap.rb b/app/services/tables/swap.rb index f7d3d26..4bf79bd 100644 --- a/app/services/tables/swap.rb +++ b/app/services/tables/swap.rb @@ -8,6 +8,8 @@ module Tables def each @initial_solution.tables.combination(2) do |table_a, table_b| table_a.swap_candidates.product(table_b.swap_candidates).each do |(person_a, person_b)| + next if person_a.affinity_group_list.first == person_b.affinity_group_list.first + new_solution = @initial_solution.dup new_table_a = table_a.dup