Created new kpi daily model for new dash users

This commit is contained in:
Joaquin 2025-03-24 13:00:24 +01:00
parent c0a1e90fae
commit 1ebd1c5ccb
5 changed files with 213 additions and 173 deletions

View file

@ -0,0 +1,92 @@
{{
config(
materialized="table",
unique_key=[
"id_user_host",
"id_user_product_bundle",
"service_name",
"date",
"service_business_type",
],
)
}}
select
-- Unique Key --
d.date_day as date,
bs.id_user_host,
bs.id_user_product_bundle,
bs.product_service_display_name as service_name,
coalesce(ps.service_business_type, 'UNSET') as service_business_type,
-- Dimensions --
coalesce(uh.id_deal, 'UNSET') as id_deal,
case when ps.is_default_service then 'NO' else 'YES' end as is_upgraded_service,
coalesce(uh.new_dash_version, 'UNSET') as new_dash_version,
coalesce(
uh.main_billing_country_iso_3_per_deal, 'UNSET'
) as main_billing_country_iso_3_per_deal,
coalesce(
icmas.active_accommodations_per_deal_segmentation, 'UNSET'
) as active_accommodations_per_deal_segmentation
from {{ ref("int_dates") }} as d
inner join
{{ ref("int_core__user_host") }} as uh
on uh.is_user_in_new_dash = true
and uh.is_missing_id_deal = false
and uh.is_test_account = false
and d.date_day between uh.user_in_new_dash_since_date_utc and current_date - 1
inner join
{{ ref("int_core__user_product_bundle_contains_services") }} as bs
on uh.id_user_host = bs.id_user_host
left join
{{ ref("stg_core__product_service") }} as ps
on ps.product_service_display_name = bs.product_service_display_name
left join
{{ ref("int_hubspot__deal") }} as hd
on uh.id_deal = hd.id_deal
and coalesce(hd.cancellation_date_utc, {{ var("end_of_time") }}) >= d.date_day
left join
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
on uh.id_deal = icmas.id_deal
and d.date_day = icmas.date
-- Union of all product services with all protection plan services.
-- This is because there are basically two types of services: product services
-- and protection plan services and they are stored in different tables.
union all
select
-- Unique Key --
d.date_day as date,
pb.id_user_host,
pb.id_user_product_bundle,
coalesce(pb.protection_display_name, {{ var("default_service") }}) as service_name,
'PROTECTION' as service_business_type,
-- Dimensions --
coalesce(uh.id_deal, 'UNSET') as id_deal,
case when pp.is_default_service then 'NO' else 'YES' end as is_upgraded_service,
coalesce(uh.new_dash_version, 'UNSET') as new_dash_version,
coalesce(
uh.main_billing_country_iso_3_per_deal, 'UNSET'
) as main_billing_country_iso_3_per_deal,
coalesce(
icmas.active_accommodations_per_deal_segmentation, 'UNSET'
) as active_accommodations_per_deal_segmentation
from {{ ref("int_dates") }} as d
inner join
{{ ref("int_core__user_host") }} as uh
on uh.is_user_in_new_dash = true
and uh.is_missing_id_deal = false
and uh.is_test_account = false
and d.date_day between uh.user_in_new_dash_since_date_utc and current_date - 1
inner join
{{ ref("int_core__user_product_bundle") }} as pb
on uh.id_user_host = pb.id_user_host
left join
{{ ref("stg_core__protection_plan") }} as pp
on pp.protection_display_name = pb.protection_display_name
left join
{{ ref("int_hubspot__deal") }} as hd
on uh.id_deal = hd.id_deal
and coalesce(hd.cancellation_date_utc, {{ var("end_of_time") }}) >= d.date_day
left join
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
on uh.id_deal = icmas.id_deal
and d.date_day = icmas.date

View file

@ -7383,3 +7383,121 @@ models:
The unique daily chargeable accommodations, or listings, in a given time range
and per specified dimension. This metric is not additive, and its value
can vary depending on the time period considered.
- name: int_kpis__metric_daily_new_dash_users_offered_services
description: |
This model computes the Daily Offered Services by Users at the deepest granularity.
It only retrieves services that come from users that are in New Dash, as well
as it only considers services created after the user has moved to New Dash.
The unique key corresponds to the deepest granularity of the model,
in this case:
- date,
- id_user_host,
- id_user_product_bundle,
- service_name,
- service_business_type
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- date
- id_user_host
- id_user_product_bundle
- service_name
- service_business_type
columns:
- name: date
data_type: date
description: Date of when user has a bundle with service active.
data_tests:
- not_null
- name: id_user_host
data_type: bigint
description: Unique identifier of the User Host.
data_tests:
- not_null
- name: id_user_product_bundle
data_type: bigint
description: Unique identifier of the User Product Bundle.
data_tests:
- not_null
- name: service_name
data_type: string
description: Name of the created service.
data_tests:
- not_null
- name: id_deal
data_type: string
description: Unique identifier of an account.
data_tests:
- not_null
- name: is_upgraded_service
data_type: string
description: |
Whether the service is an upgraded version of the
default. In other words, if it's not Basic Screening.
data_tests:
- not_null
- accepted_values:
values:
- "YES"
- "NO"
- name: service_business_type
data_type: string
description: |
Identifies the service type (Screening, Deposit Management, Protection
or Guest Agreement) according to New Pricing documentation.
Cannot be null.
data_tests:
- not_null
- accepted_values:
values:
- "SCREENING"
- "PROTECTION"
- "DEPOSIT_MANAGEMENT"
- "GUEST_AGREEMENT"
- "UNKNOWN"
- "UNSET"
- name: new_dash_version
data_type: string
description: |
The version of the New Dash. It corresponds to the
release or migration phase from user point of view.
data_tests:
- not_null
- name: active_accommodations_per_deal_segmentation
data_type: string
description: |
Segment value based on the number of listings booked in 12 months
for a given deal and date.
data_tests:
- not_null
- accepted_values:
values:
- "0"
- "01-05"
- "06-20"
- "21-60"
- "61+"
- "UNSET"
- name: main_billing_country_iso_3_per_deal
data_type: string
description: |
Main billing country of the host aggregated at Deal level.
data_tests:
- not_null
- name: created_services
data_type: bigint
description: |
Count of daily services created in a given date and per specified dimension.