Skip to content

Commit

Permalink
Make teaching qualification duration optional
Browse files Browse the repository at this point in the history
We want to do some final calculations on this so we need to bring back
the ability to set this to false. This will be reverted once we've done
the analysis.
  • Loading branch information
thomasleese committed Dec 5, 2023
1 parent 3b4d3b2 commit a4fefb3
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions app/lib/work_history_duration.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
# frozen_string_literal: true

class WorkHistoryDuration
def initialize(application_form:, relation:)
def initialize(
application_form:,
relation:,
consider_teaching_qualification: true
)
@application_form = application_form
@relation =
relation.where.not(start_date: nil).where.not(hours_per_week: nil)
@consider_teaching_qualification = consider_teaching_qualification
end

def self.for_application_form(application_form)
def self.for_application_form(
application_form,
consider_teaching_qualification: true
)
WorkHistoryDuration.new(
application_form:,
relation: application_form.work_histories,
consider_teaching_qualification:,
)
end

def self.for_ids(ids, application_form:)
def self.for_ids(
ids,
application_form:,
consider_teaching_qualification: true
)
WorkHistoryDuration.new(
application_form:,
relation: application_form.work_histories.where(id: ids),
consider_teaching_qualification:,
)
end

def self.for_record(record)
for_ids([record.id], application_form: record.application_form)
def self.for_record(record, consider_teaching_qualification: true)
for_ids(
[record.id],
application_form: record.application_form,
consider_teaching_qualification:,
)
end

def count_months
Expand Down Expand Up @@ -59,7 +77,7 @@ def enough_to_skip_induction?
AVERAGE_WEEKS_PER_MONTH = 4.34
HOURS_PER_FULL_TIME_MONTH = 130.0

attr_reader :application_form, :relation
attr_reader :application_form, :relation, :consider_teaching_qualification

def work_histories
@work_histories ||=
Expand All @@ -71,7 +89,10 @@ def work_histories
end

def teaching_qualification
@teaching_qualification ||= application_form.teaching_qualification
@teaching_qualification ||=
if consider_teaching_qualification
application_form.teaching_qualification
end
end

def work_history_full_time_months(work_history)
Expand Down

0 comments on commit a4fefb3

Please sign in to comment.