From 204771ef2b31ee071c7048d0cec776a27381c3ca Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Thu, 11 Jul 2024 23:39:40 +0200 Subject: [PATCH] Make unbreakable bonds belong to the same affinity group in seeds --- db/seeds.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 2c8427b..e79ad9b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -60,13 +60,17 @@ end guest.save! end +Guest.affinity_group_counts.each do |group| + couples = (group.taggings_count / 4).floor -Guest.all.sample(100).each_slice(2) do |a, b| - bond_name = "#{a.full_name} & #{b.full_name}" + guests_involved = Guest.tagged_with(group.name).limit(couples * 2) + guests_involved.each_slice(2) do |a, b| + bond_name = "#{a.full_name} & #{b.full_name}" - a.unbreakable_bond_list.add(bond_name) - b.unbreakable_bond_list.add(bond_name) + a.unbreakable_bond_list.add(bond_name) + b.unbreakable_bond_list.add(bond_name) - a.save! - b.save! -end \ No newline at end of file + a.save! + b.save! + end +end