Skip to content

Commit

Permalink
Set verified at on the claim
Browse files Browse the repository at this point in the history
We need to be able to access the timestamp a claim was verified in big
query. The provider verification is flagged in the analytics block list
so isn't sent over to big query (it's a json structure and some of it's
fields are pii). To ensure big query has access to the verification
timestamp we have added a new column on the claim `Claim#verified_at`
which will be sent over to big query. A follow up PR will back fill this
column on already verified claims.
  • Loading branch information
rjlynch committed Oct 28, 2024
1 parent 2cf19f9 commit c9d2a6d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,28 @@ def assertions_attributes=(params)
def save
return false unless valid?

claim.eligibility.update!(
verification: {
assertions: assertions.map(&:attributes),
verifier: {
dfe_sign_in_uid: answers.dfe_sign_in_uid,
first_name: answers.dfe_sign_in_first_name,
last_name: answers.dfe_sign_in_last_name,
email: answers.dfe_sign_in_email,
dfe_sign_in_organisation_name: answers.dfe_sign_in_organisation_name,
dfe_sign_in_role_codes: answers.dfe_sign_in_role_codes
},
created_at: DateTime.now
}
)

claim.save!
ApplicationRecord.transaction do
verified_at = DateTime.now

claim.eligibility.update!(
verification: {
assertions: assertions.map(&:attributes),
verifier: {
dfe_sign_in_uid: answers.dfe_sign_in_uid,
first_name: answers.dfe_sign_in_first_name,
last_name: answers.dfe_sign_in_last_name,
email: answers.dfe_sign_in_email,
dfe_sign_in_organisation_name: answers.dfe_sign_in_organisation_name,
dfe_sign_in_role_codes: answers.dfe_sign_in_role_codes
},
created_at: verified_at
}
)

claim.verified_at = verified_at

claim.save!
end

ClaimMailer
.further_education_payment_provider_confirmation_email(claim)
Expand Down
3 changes: 2 additions & 1 deletion app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class Claim < ApplicationRecord
paye_reference: true,
practitioner_email_address: true,
provider_contact_name: true,
started_at: false
started_at: false,
verified_at: false
}.freeze
DECISION_DEADLINE = 12.weeks
DECISION_DEADLINE_WARNING_POINT = 2.weeks
Expand Down
1 change: 1 addition & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ shared:
- onelogin_auth_at
- onelogin_idv_at
- started_at
- verified_at
:decisions:
- id
- result
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddVerifiedAtTimestampToClaims < ActiveRecord::Migration[7.0]
def change
add_column :claims, :verified_at, :datetime
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_10_17_113701) do
ActiveRecord::Schema[7.0].define(version: 2024_10_28_095040) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -112,6 +112,7 @@
t.text "onelogin_idv_last_name"
t.date "onelogin_idv_date_of_birth"
t.datetime "started_at", precision: nil, null: false
t.datetime "verified_at"
t.index ["academic_year"], name: "index_claims_on_academic_year"
t.index ["created_at"], name: "index_claims_on_created_at"
t.index ["eligibility_type", "eligibility_id"], name: "index_claims_on_eligibility_type_and_eligibility_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@
"created_at" => "2024-01-01T12:00:00.000+00:00"
}
)

expect(claim.verified_at).to eq(DateTime.new(2024, 1, 1, 12, 0, 0))
end

it "creates a provider verification task" do
Expand Down

0 comments on commit c9d2a6d

Please sign in to comment.