New Dash Listings with services
This commit is contained in:
parent
87517f6a92
commit
3f08229256
1 changed files with 16 additions and 6 deletions
|
|
@ -10,10 +10,21 @@
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
|
with
|
||||||
|
-- Selects the most recent product bundle per accommodation per day
|
||||||
|
latest_daily_bundle as (
|
||||||
|
select distinct on (id_accommodation, effective_start_date_utc) *
|
||||||
|
from {{ ref("int_core__accommodation_to_product_bundle") }}
|
||||||
|
order by
|
||||||
|
id_accommodation, -- Ensures we are filtering per accommodation
|
||||||
|
effective_start_date_utc desc, -- Prefers the latest effective start date
|
||||||
|
original_starts_at_utc desc, -- In case of ties, prefers the most recent original start
|
||||||
|
coalesce(original_ends_at_utc, {{ var("end_of_time") }}) desc
|
||||||
|
)
|
||||||
select
|
select
|
||||||
-- Unique Key --
|
-- Unique Key --
|
||||||
dd.date,
|
dd.date,
|
||||||
apb.id_accommodation,
|
ldb.id_accommodation,
|
||||||
bs.id_user_product_bundle,
|
bs.id_user_product_bundle,
|
||||||
bs.service_name,
|
bs.service_name,
|
||||||
bs.service_business_type,
|
bs.service_business_type,
|
||||||
|
|
@ -35,11 +46,10 @@ inner join
|
||||||
{{ ref("int_core__user_product_bundle_contains_services") }} as bs
|
{{ ref("int_core__user_product_bundle_contains_services") }} as bs
|
||||||
on uh.id_user_host = bs.id_user_host
|
on uh.id_user_host = bs.id_user_host
|
||||||
inner join
|
inner join
|
||||||
{{ ref("int_core__accommodation_to_product_bundle") }} as apb
|
latest_daily_bundle as ldb
|
||||||
on bs.id_user_product_bundle = apb.id_user_product_bundle
|
on bs.id_user_product_bundle = ldb.id_user_product_bundle
|
||||||
and date between apb.effective_start_date_utc and coalesce(
|
and date >= ldb.effective_start_date_utc
|
||||||
apb.effective_end_date_utc, {{ var("end_of_time") }}
|
and date < coalesce(ldb.effective_end_date_utc, {{ var("end_of_time") }})
|
||||||
)
|
|
||||||
left join
|
left join
|
||||||
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
|
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
|
||||||
on uh.id_deal = icmas.id_deal
|
on uh.id_deal = icmas.id_deal
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue