This commit is contained in:
Joaquin Ossa 2025-02-10 14:57:46 +01:00
parent e39e17fd21
commit ed696488bf

View file

@ -9,7 +9,6 @@ with
int_core__accommodation_to_product_bundle as (
select * from {{ ref("int_core__accommodation_to_product_bundle") }}
),
int_core__new_dash_users as (select * from {{ ref("int_core__new_dash_users") }}),
int_core__accommodation as (select * from {{ ref("int_core__accommodation") }}),
int_core__booking_to_product_bundle as (
select * from {{ ref("int_core__booking_to_product_bundle") }}
@ -17,32 +16,38 @@ with
int_core__bookings as (select * from {{ ref("int_core__bookings") }}),
bundle_services as (
select
id_user_product_bundle,
id_user_host,
product_service_display_name as service_display_name
from int_core__user_product_bundle_contains_services
-- 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
id_user_product_bundle,
id_user_host,
coalesce(
protection_display_name, {{ var("default_service") }}
) as service_display_name
from int_core__user_product_bundle
),
users as (
select distinct
bs.service_display_name, count(distinct bs.id_user_host) as number_users
from bundle_services bs
bs.id_user_product_bundle,
bs.id_user_host,
bs.product_service_display_name as service_display_name
from int_core__user_product_bundle_contains_services bs
inner join
int_core__user_host uh
on bs.id_user_host = uh.id_user_host
and uh.is_user_in_new_dash = true
and uh.is_missing_id_deal = false
and uh.is_test_account = false
-- 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
pb.id_user_product_bundle,
pb.id_user_host,
coalesce(
pb.protection_display_name, {{ var("default_service") }}
) as service_display_name
from int_core__user_product_bundle pb
inner join
int_core__user_host uh
on pb.id_user_host = uh.id_user_host
and uh.is_user_in_new_dash = true
and uh.is_missing_id_deal = false
and uh.is_test_account = false
),
users as (
select distinct
bs.service_display_name, count(distinct bs.id_user_host) as number_users
from bundle_services bs
group by 1
),
accommodations as (
@ -65,12 +70,6 @@ with
apb.original_ends_at_utc, {{ var("end_of_time") }}
)
left join int_core__accommodation a on apb.id_accommodation = a.id_accommodation
inner join
int_core__user_host uh
on bs.id_user_host = uh.id_user_host
and uh.is_user_in_new_dash = true
and uh.is_missing_id_deal = false
and uh.is_test_account = false
group by 1
),
bookings as (
@ -106,12 +105,6 @@ with
int_core__bookings b
on b.id_booking = bpb.id_booking
and b.is_duplicate_booking is false
inner join
int_core__user_host uh
on bs.id_user_host = uh.id_user_host
and uh.is_user_in_new_dash = true
and uh.is_missing_id_deal = false
and uh.is_test_account = false
group by 1
)
select