Addressed comments

This commit is contained in:
Joaquin 2025-03-14 14:20:57 +01:00
parent 89b3989d19
commit e9cfb6c2bd
3 changed files with 48 additions and 22 deletions

View file

@ -16,9 +16,6 @@ with
int_kpis__dimension_daily_accommodation as (
select * from {{ ref("int_kpis__dimension_daily_accommodation") }}
),
int_core__new_dash_deal_since_date as (
select * from {{ ref("int_core__new_dash_deal_since_date") }}
),
listings as (
select *
from {{ ref("int_kpis__agg_daily_listings") }}
@ -86,20 +83,6 @@ select
-- DEAL STATIC ATTRIBUTES --
ikdd.id_deal,
ikdd.client_type,
case
when ikdd.client_type = 'API'
then 'API'
when ikdd.client_type = 'PLATFORM'
then
case
when
icnddsd.id_deal is not null
and d.date >= icnddsd.min_user_in_new_dash_since_date_utc
then 'New Dash'
else 'Old Dash'
end
else 'UNSET'
end as business_scope,
ikdd.main_deal_name,
ikdd.has_active_pms,
ikdd.active_pms_list,
@ -107,6 +90,21 @@ select
dda.active_accommodations_per_deal_segmentation, 'UNSET'
) as active_accommodations_per_deal_segmentation,
ikdd.main_billing_country_iso_3_per_deal,
-- DEAL BUSINESS SCOPE
case
when ikdd.client_type = 'API'
then 'API'
when ikdd.client_type = 'PLATFORM'
then
case
when
ikdd.id_deal is not null
and d.date >= ikdd.min_user_in_new_dash_since_date_utc
then 'New Dash'
else 'Old Dash'
end
else 'UNSET'
end as business_scope,
-- DEAL LIFECYCLE --
daily_deal_lifecycle.deal_lifecycle_state,
@ -183,7 +181,8 @@ select
as host_resolution_amount_paid_per_created_booking,
{{
return_capped_value(
"cast(host_resolutions.xero_host_resolution_payment_count as decimal) / created_bookings.created_bookings",
"cast(host_resolutions.xero_host_resolution_payment_count as decimal)
/ created_bookings.created_bookings",
-1,
1,
)
@ -250,7 +249,17 @@ select
) as revenue_retained_in_gbp,
{{
return_capped_value(
"nullif( coalesce(guest_payments.total_guest_payments_in_gbp, 0) + coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0), 0) / nullif( coalesce(guest_payments.total_guest_payments_in_gbp, 0) + coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0), 0)",
"nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0),
0) /
nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0),
0)",
-1,
1,
)
@ -268,7 +277,17 @@ select
) as revenue_retained_post_resolutions_in_gbp,
{{
return_capped_value(
"nullif( coalesce(guest_payments.total_guest_payments_in_gbp, 0) + coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0) + coalesce(host_resolutions.xero_host_resolution_amount_paid_in_gbp, 0), 0) / nullif(coalesce(guest_payments.total_guest_payments_in_gbp, 0) + coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0), 0)",
"nullif(
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0)
+ coalesce(host_resolutions.xero_host_resolution_amount_paid_in_gbp, 0),
0) /
nullif(coalesce(guest_payments.total_guest_payments_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0),
0)",
-1,
1,
)
@ -327,5 +346,3 @@ left join
host_resolutions
on d.date = host_resolutions.end_date
and d.dimension_value = host_resolutions.dimension_value
left join
int_core__new_dash_deal_since_date as icnddsd on ikdd.id_deal = icnddsd.id_deal

View file

@ -1,5 +1,8 @@
{{ config(materialized="table", unique_key="id_deal") }}
with
int_core__new_dash_deal_since_date as (
select * from {{ ref("int_core__new_dash_deal_since_date") }}
),
hubspot_deals as (
select
id_deal,
@ -70,7 +73,9 @@ select
cd.main_billing_country_iso_3_per_deal,
cd.effective_deal_start_date_utc,
cd.effective_deal_start_month,
icnddsd.min_user_in_new_dash_since_date_utc,
cd.hubspot_deal_cancellation_date_utc,
cd.hubspot_deal_cancellation_month,
cd.hubspot_listing_segmentation
from combined_deals cd
left join int_core__new_dash_deal_since_date icnddsd on cd.id_deal = icnddsd.id_deal

View file

@ -496,6 +496,10 @@ models:
to the month.
data_tests:
- not_null
- name: min_user_in_new_dash_since_date_utc
data_type: date
description: |
The date when the first user host appeared in New Dash for this deal.
- name: hubspot_deal_cancellation_date_utc
data_type: date
description: |