Skip to content

Commit

Permalink
feat(benefits): add new enrollment_method cols
Browse files Browse the repository at this point in the history
default to 'digital' for historical events
  • Loading branch information
thekaveman committed Oct 25, 2024
1 parent 3e26875 commit 4f305e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions warehouse/models/mart/benefits/_mart_benefits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ models:
description: UUID
- name: processed_time
description: UTC ISO-8601 timestamp
- name: event_properties_enrollment_method
description: The `enrollment_method` value from the `event_properties` column
- name: event_properties_auth_provider
description: The `claims_provider` value from the `event_properties` column
deprecated:
Expand Down Expand Up @@ -103,6 +105,8 @@ models:
date: "2024-09-19"
- name: event_properties_enrollment_flows
description: A semi-colon delimited list of `enrollment_flows` values from the `event_properties` column
- name: user_properties_enrollment_method
description: The `enrollment_method` value from the `user_properties` column
- name: user_properties_eligibility_verifier
description: The `eligibility_verifier` value from the `user_properties` column
- name: user_properties_initial_referrer
Expand Down
16 changes: 16 additions & 0 deletions warehouse/models/mart/benefits/fct_benefits_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ WITH fct_benefits_events AS (
{{ json_extract_column('event_properties', 'status') }},
{{ json_extract_column('event_properties', 'transit_agency') }},

-- New column `enrollment_method`, historical values should be set to "digital"
-- https://github.com/cal-itp/benefits/pull/2402
COALESCE(
{{ json_extract_column('event_properties', 'enrollment_method', no_alias = true) }},
"digital"
) AS event_properties_enrollment_method,

-- Historical data existed in `auth_provider` but new data is in `claims_provider`
-- https://github.com/cal-itp/benefits/pull/2401
COALESCE(
Expand Down Expand Up @@ -94,6 +101,13 @@ WITH fct_benefits_events AS (
{{ json_extract_column('user_properties', 'referring_domain') }},
{{ json_extract_column('user_properties', 'user_agent') }},

-- New column `enrollment_method`, historical values should be set to "digital"
-- https://github.com/cal-itp/benefits/pull/2402
COALESCE(
{{ json_extract_column('user_properties', 'enrollment_method', no_alias = true) }},
"digital"
) AS user_properties_enrollment_method,

-- Historical data existed in `eligibility_types` but new data is in `enrollment_flows`
-- https://github.com/cal-itp/benefits/pull/2379
COALESCE(
Expand Down Expand Up @@ -132,6 +146,7 @@ fct_old_enrollments AS (
start_version,
uuid,
processed_time,
"digital" as event_properties_enrollment_method,
CASE
WHEN client_event_time < '2022-08-12T07:00:00Z'
THEN "ca-dmv"
Expand Down Expand Up @@ -160,6 +175,7 @@ fct_old_enrollments AS (
"Monterey-Salinas Transit" as event_properties_transit_agency,
"senior" as event_properties_enrollment_flows,
event_properties_enrollment_flows as event_properties_eligibility_types,
"digital" as user_properties_enrollment_method,
CASE
WHEN client_event_time < '2022-08-12T07:00:00Z'
THEN "ca-dmv"
Expand Down

0 comments on commit 4f305e0

Please sign in to comment.