Skip to content

Commit

Permalink
Merge pull request #4529 from DFE-Digital/fix-amend-participant-cohort
Browse files Browse the repository at this point in the history
do not include the latest record in the list of historical records
  • Loading branch information
ltello authored Feb 12, 2024
2 parents 577f781 + ae68d1b commit 6e86806
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/services/induction/amend_participant_cohort.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ def initialize(*)
end

def all_records_in_target?
historical_records.all? do |induction_record|
in_target?(induction_record)
end
induction_records.all? { |induction_record| in_target?(induction_record) }
end

def current_induction_record_changed?
Expand Down Expand Up @@ -148,9 +146,7 @@ def historical_records_changed?
end

def historical_records
return [] unless participant_profile

@historical_records ||= participant_profile.induction_records.order(created_at: :desc)
@historical_records ||= induction_records - [induction_record]
end

def historical_induction_programme_for(historical_record)
Expand Down Expand Up @@ -210,6 +206,10 @@ def induction_record
.latest
end

def induction_records
@induction_records ||= participant_profile&.induction_records.to_a
end

def in_target?(induction_record)
in_target_cohort?(induction_record) && in_target_schedule?(induction_record)
end
Expand Down

0 comments on commit 6e86806

Please sign in to comment.