From 50a5c90728f7dda18be80391d22570828173686a Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 3 Nov 2024 09:15:48 +0100 Subject: [PATCH] Only include potential guests in the simulation --- app/jobs/table_simulator_job.rb | 2 +- app/models/guest.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/jobs/table_simulator_job.rb b/app/jobs/table_simulator_job.rb index 574c4a5..f0e99f0 100644 --- a/app/jobs/table_simulator_job.rb +++ b/app/jobs/table_simulator_job.rb @@ -7,7 +7,7 @@ class TableSimulatorJob < ApplicationJob engine.add_perturbation(Tables::Swap) initial_solution = Tables::Distribution.new(min_per_table: 8, max_per_table: 10) - initial_solution.random_distribution(Guest.all.shuffle) + initial_solution.random_distribution(Guest.potential.shuffle) engine.initial_solution = initial_solution diff --git a/app/models/guest.rb b/app/models/guest.rb index 39d27b3..87680bf 100644 --- a/app/models/guest.rb +++ b/app/models/guest.rb @@ -8,9 +8,11 @@ class Guest < ApplicationRecord invited: 10, confirmed: 20, declined: 30, - tentative: 40, + tentative: 40 } + scope :potential, -> { where.not(status: %i[declined considered]) } + def full_name "#{first_name} #{last_name}" end