Merged PR 5427: data alert fix

# Description

Change in model `int_core__accommodation_to_product_bundle` to remove effective dates and use original start and end date.
Updated downstream models as well

# Checklist

- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

data alert fix

Related work items: #30948
This commit is contained in:
Joaquin Ossa 2025-06-10 12:57:05 +00:00
commit 8b415fc726
4 changed files with 25 additions and 47 deletions

View file

@ -12,23 +12,10 @@ select
atpb.id_user_product_bundle,
upb.id_user_host,
upb.product_bundle_display_name as user_product_bundle_name,
atpb.starts_at_utc as original_starts_at_utc,
atpb.ends_at_utc as original_ends_at_utc,
/*
The following is to ensure that we cap the reporting to the
dates in which these product bundles could have been active.
For analysis and reporting purposes, it is encouraged to use
the effective fields (start_date and end_date) rather than the
backend ones (named as original_starts_at and original_ends_at).
*/
greatest(
date(atpb.starts_at_utc), upb.effective_start_date_utc
) as effective_start_date_utc,
case
when atpb.has_no_end_date
then null
else greatest(date(atpb.ends_at_utc), upb.effective_end_date_utc)
end as effective_end_date_utc,
atpb.starts_at_utc,
atpb.ends_at_utc,
date(atpb.starts_at_utc) as start_date_utc,
date(atpb.ends_at_utc) as end_date_utc,
atpb.has_no_end_date,
upb.product_bundle_services,
upb.is_custom_bundle,

View file

@ -68,11 +68,11 @@ with
count(
distinct case
when
atpb.effective_start_date_utc <= current_date
and coalesce(
atpb.effective_end_date_utc, {{ var("end_of_time") }}
atpb.start_date_utc <= current_date
and (
atpb.end_date_utc >= current_date
or atpb.has_no_end_date = true
)
>= current_date
then atpb.id_accommodation
else null
end
@ -80,11 +80,11 @@ with
count(
distinct case
when
atpb.effective_start_date_utc <= current_date
and coalesce(
atpb.effective_end_date_utc, {{ var("end_of_time") }}
atpb.start_date_utc <= current_date
and (
atpb.end_date_utc >= current_date
or atpb.has_no_end_date = true
)
>= current_date
and atpb.user_product_bundle_name
not in ({{ var("default_service") }})
then atpb.id_accommodation

View file

@ -2183,42 +2183,33 @@ models:
description: |
The name of the Product Bundle.
- name: original_starts_at_utc
- name: starts_at_utc
data_type: timestamp
description: |
Timestamp of when this Product Bundle is assigned into an Accommodation was
active for the first time, according to the Backend.
Keep in mind that this timestamp can be before the migration of the user, thus
effective_start_date_utc might be better for reporting and analysis purposes.
data_tests:
- not_null
- name: original_ends_at_utc
- name: ends_at_utc
data_type: timestamp
description: |
Timestamp of when this Product Bundle is assigned into an Accommodation was
active for the last time, according to the Backend. If null it means that
it's currently active.
Keep in mind that this timestamp can be before the migration of the user, thus
effective_end_date_utc might be better for reporting and analysis purposes.
- name: effective_start_date_utc
- name: start_date_utc
data_type: date
description: |
Effective date of when this Product Bundle is assigned into an Accommodation was
active for the first time.
It takes into account the fact that a User needs to be migrated in order for
the Product Bundle to be active in the Accommodation. In case of doubt, use this date.
The date when this Product Bundle was first assigned to the Accommodation.
data_tests:
- not_null
- name: effective_end_date_utc
- name: end_date_utc
data_type: date
description: |
Effective date of when this Product Bundle is assigned into an Accommodation was
active for the last time. If null it means that it's currently active.
It takes into account the fact that a User needs to be migrated in order for
the Product Bundle to be active in the Accommodation. In case of doubt, use this date.
The date when this Product Bundle was last active for the Accommodation.
If null, it means the Product Bundle is currently active.
- name: has_no_end_date
data_type: boolean