From ee21f75ed6bc134a9139cc6f226d2b489e40f076 Mon Sep 17 00:00:00 2001 From: Chidi Ekuma Date: Fri, 26 Apr 2024 11:06:37 +0100 Subject: [PATCH 1/2] Refactor secondary_subjects scope in Bookings::Subject model to include only non-hidden secondary subjects --- app/models/bookings/subject.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/bookings/subject.rb b/app/models/bookings/subject.rb index 9d474945e7..f021384c76 100644 --- a/app/models/bookings/subject.rb +++ b/app/models/bookings/subject.rb @@ -33,7 +33,7 @@ class Bookings::Subject < ApplicationRecord dependent: :restrict_with_exception default_scope -> { where.not(hidden: true) } - scope :secondary_subjects, -> { where(secondary_subject: true) } + scope :secondary_subjects, -> { where(secondary_subject: true).where.not(hidden: true) } scope :ordered_by_name, -> { order(name: 'asc') } end From 516a37fc050c07dd10fd41610ff280c3f4e57280 Mon Sep 17 00:00:00 2001 From: Chidi Ekuma Date: Fri, 26 Apr 2024 11:08:55 +0100 Subject: [PATCH 2/2] Remove safe navigation from `bookings_subject` in `placement_date_option.rb` --- app/models/candidates/placement_date_option.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/candidates/placement_date_option.rb b/app/models/candidates/placement_date_option.rb index 98d7114a12..30e9e17f53 100644 --- a/app/models/candidates/placement_date_option.rb +++ b/app/models/candidates/placement_date_option.rb @@ -5,7 +5,7 @@ def self.for_secondary_date(placement_date) placement_date.placement_date_subjects.map do |placement_date_subject| new( placement_date_subject.date_and_subject_id, - placement_date_subject.bookings_subject&.name, + placement_date_subject.bookings_subject.name, placement_date.duration, placement_date.date, placement_date.virtual,