Removes configuration status and adds config id for further joins

This commit is contained in:
uri 2025-03-18 09:20:31 +01:00
parent 91e7fe09b1
commit 74a76fe8fc
2 changed files with 25 additions and 56 deletions

View file

@ -1,7 +1,4 @@
with
stg_core__guest_product_configuration_status as (
select * from {{ ref("stg_core__guest_product_configuration_status") }}
),
stg_core__guest_product_configuration_price_plan as (
select * from {{ ref("stg_core__guest_product_configuration_price_plan") }}
),
@ -10,17 +7,6 @@ with
select * from {{ ref("stg_core__guest_product_configuration") }}
),
int_core__guest_products as (select * from {{ ref("int_core__guest_products") }}),
ranked_configuration_status as (
select
id_guest_product_configuration,
is_enabled,
is_enabled_for_guest_journey,
starts_at_utc,
row_number() over (
partition by id_guest_product_configuration order by starts_at_utc desc
) as status_rank
from stg_core__guest_product_configuration_status
),
price_plan_with_end_date as (
select
id_guest_product_configuration_price_plan,
@ -41,33 +27,30 @@ with
from stg_core__guest_product_configuration_price_plan
)
select
rpp.id_guest_product_configuration_price_plan,
ppwed.id_guest_product_configuration_price_plan,
ppwed.id_guest_product_configuration,
icgp.guest_product_name,
icgp.guest_product_latest_display_name,
scgpc.configuration_level as configuration_level,
scgpc.id_user_host,
rks.is_enabled as is_currently_enabled,
rks.is_enabled_for_guest_journey as is_currently_enabled_for_guest_journey,
scc.iso4217_code as currency_code,
rpp.product_price_in_local_currency,
rpp.protection_limit_in_local_currency,
rpp.starts_at_utc,
rpp.start_date_utc,
coalesce(rpp.ends_at_utc, {{ var("end_of_time") }}::timestamp) as ends_at_utc,
coalesce(date(rpp.ends_at_utc), {{ var("end_of_time") }}) as end_date_utc,
case when rpp.ends_at_utc is null then true else false end as is_latest_price_plan,
rpp.created_at_utc,
rpp.created_date_utc,
rpp.updated_at_utc,
rpp.updated_date_utc
from price_plan_with_end_date rpp
left join stg_core__currency scc on rpp.id_currency = scc.id_currency
ppwed.product_price_in_local_currency,
ppwed.protection_limit_in_local_currency,
ppwed.starts_at_utc,
ppwed.start_date_utc,
coalesce(ppwed.ends_at_utc, {{ var("end_of_time") }}::timestamp) as ends_at_utc,
coalesce(date(ppwed.ends_at_utc), {{ var("end_of_time") }}) as end_date_utc,
case
when ppwed.ends_at_utc is null then true else false
end as is_latest_price_plan,
ppwed.created_at_utc,
ppwed.created_date_utc,
ppwed.updated_at_utc,
ppwed.updated_date_utc
from price_plan_with_end_date ppwed
left join stg_core__currency scc on ppwed.id_currency = scc.id_currency
left join
stg_core__guest_product_configuration scgpc
on rpp.id_guest_product_configuration = scgpc.id_guest_product_configuration
left join
ranked_configuration_status rks
on scgpc.id_guest_product_configuration = rks.id_guest_product_configuration
and rks.status_rank = 1 -- Get only latest status
on ppwed.id_guest_product_configuration = scgpc.id_guest_product_configuration
left join
int_core__guest_products icgp on scgpc.id_guest_product = icgp.id_guest_product

View file

@ -5936,6 +5936,13 @@ models:
- not_null
- unique
- name: id_guest_product_configuration
data_type: bigint
description: |
Identifier of the guest product configuration.
data_tests:
- not_null
- name: guest_product_name
data_type: character varying
description: |
@ -5983,27 +5990,6 @@ models:
default configuration. If it's set, it means this
configuration is a custom configuration.
- name: is_currently_enabled
data_type: boolean
description: |
Indicates if the product is currently enabled or not.
- If true, then the product is visible everywhere.
- If false, then the product is disabled. Therefore,
the product is NOT visible anywhere.
It cannot be null.
data_tests:
- not_null
- name: is_currently_enabled_for_guest_journey
data_type: boolean
description: |
Indicates if the product, for a given user, is currently
enabled for the guest journey.
- If true, then the product is visible in the guest journey.
It cannot be null.
data_tests:
- not_null
- name: currency_code
data_type: text
description: