Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAPT 1797/qualification report tweak #3531

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions app/models/reports/failed_qualification_claims.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ def initialize
@claims = Claim
.approved
.where(academic_year: AcademicYear.current)
.joins(:tasks).merge(Task.where(name: "qualifications", passed: false))
.includes(:eligibility, decisions: :created_by)
.joins(:tasks).merge(
Task.qualifications.where(passed: false).or(
Task.qualifications.claim_verifier_match_none
)
)
.includes(:eligibility, :notes, decisions: :created_by)
end

def to_csv
Expand Down Expand Up @@ -54,10 +58,10 @@ def to_a
qualification,
itt_academic_year,
eligible_itt_subject,
itt_subjects,
itt_start_date,
qts_award_date,
qualification_name
parse_note("ITT subjects"),
parse_note("ITT start date"),
parse_note("QTS award date"),
parse_note("Qualification name")
]
end

Expand All @@ -84,34 +88,18 @@ def qualification
claim.eligibility.try(:qualification)
end

def itt_subjects
dqt_teacher_record&.itt_subjects&.join(", ")
end

def itt_start_date
date = dqt_teacher_record&.itt_start_date

return unless date

I18n.l(date, format: :day_month_year)
end
# dqt information isn't stored on any claims on production.
# We don't want to make an API call for each claim in this report, so
# instead we parse the note to get the information for the report.
def parse_note(label)
return unless dqt_note

def qts_award_date
date = dqt_teacher_record&.qts_award_date

return unless date

I18n.l(date, format: :day_month_year)
match = dqt_note.body.match(/#{label}: (.*)/)
match ? match[1].strip : nil
end

def qualification_name
dqt_teacher_record&.qualification_name
end

def dqt_teacher_record
@dqt_teacher_record ||= if claim.has_dqt_record?
Dqt::Teacher.new(claim.dqt_teacher_status)
end
def dqt_note
@dqt_note ||= claim.notes.find_by(label: "qualifications")
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Task < ApplicationRecord
payroll_gender
].freeze

NAMES.each { |name| scope name.to_sym, -> { where(name: name) } }

belongs_to :claim
belongs_to :created_by, class_name: "DfeSignIn::User", optional: true

Expand All @@ -44,7 +46,6 @@ class Task < ApplicationRecord
scope :automated, -> { where(manual: false) }
scope :passed_automatically, -> { automated.where(passed: true) }

scope :census_subjects_taught, -> { where(name: "census_subjects_taught") }
scope :no_data_census_subjects_taught, -> { census_subjects_taught.where(passed: nil, claim_verifier_match: nil) }

def to_param
Expand Down
4 changes: 4 additions & 0 deletions spec/factories/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@
trait :automated do
manual { false }
end

trait :claim_verifier_context do
to_create { it.save!(context: :claim_verifier) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice approach 👍

end
end
end
Loading