Addressed comments
This commit is contained in:
parent
89b3989d19
commit
e9cfb6c2bd
3 changed files with 48 additions and 22 deletions
|
|
@ -16,9 +16,6 @@ with
|
||||||
int_kpis__dimension_daily_accommodation as (
|
int_kpis__dimension_daily_accommodation as (
|
||||||
select * from {{ ref("int_kpis__dimension_daily_accommodation") }}
|
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 (
|
listings as (
|
||||||
select *
|
select *
|
||||||
from {{ ref("int_kpis__agg_daily_listings") }}
|
from {{ ref("int_kpis__agg_daily_listings") }}
|
||||||
|
|
@ -86,20 +83,6 @@ select
|
||||||
-- DEAL STATIC ATTRIBUTES --
|
-- DEAL STATIC ATTRIBUTES --
|
||||||
ikdd.id_deal,
|
ikdd.id_deal,
|
||||||
ikdd.client_type,
|
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.main_deal_name,
|
||||||
ikdd.has_active_pms,
|
ikdd.has_active_pms,
|
||||||
ikdd.active_pms_list,
|
ikdd.active_pms_list,
|
||||||
|
|
@ -107,6 +90,21 @@ select
|
||||||
dda.active_accommodations_per_deal_segmentation, 'UNSET'
|
dda.active_accommodations_per_deal_segmentation, 'UNSET'
|
||||||
) as active_accommodations_per_deal_segmentation,
|
) as active_accommodations_per_deal_segmentation,
|
||||||
ikdd.main_billing_country_iso_3_per_deal,
|
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 --
|
-- DEAL LIFECYCLE --
|
||||||
daily_deal_lifecycle.deal_lifecycle_state,
|
daily_deal_lifecycle.deal_lifecycle_state,
|
||||||
|
|
@ -183,7 +181,8 @@ select
|
||||||
as host_resolution_amount_paid_per_created_booking,
|
as host_resolution_amount_paid_per_created_booking,
|
||||||
{{
|
{{
|
||||||
return_capped_value(
|
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,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
@ -250,7 +249,17 @@ select
|
||||||
) as revenue_retained_in_gbp,
|
) as revenue_retained_in_gbp,
|
||||||
{{
|
{{
|
||||||
return_capped_value(
|
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,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
@ -268,7 +277,17 @@ select
|
||||||
) as revenue_retained_post_resolutions_in_gbp,
|
) as revenue_retained_post_resolutions_in_gbp,
|
||||||
{{
|
{{
|
||||||
return_capped_value(
|
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,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
@ -327,5 +346,3 @@ left join
|
||||||
host_resolutions
|
host_resolutions
|
||||||
on d.date = host_resolutions.end_date
|
on d.date = host_resolutions.end_date
|
||||||
and d.dimension_value = host_resolutions.dimension_value
|
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
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
{{ config(materialized="table", unique_key="id_deal") }}
|
{{ config(materialized="table", unique_key="id_deal") }}
|
||||||
with
|
with
|
||||||
|
int_core__new_dash_deal_since_date as (
|
||||||
|
select * from {{ ref("int_core__new_dash_deal_since_date") }}
|
||||||
|
),
|
||||||
hubspot_deals as (
|
hubspot_deals as (
|
||||||
select
|
select
|
||||||
id_deal,
|
id_deal,
|
||||||
|
|
@ -70,7 +73,9 @@ select
|
||||||
cd.main_billing_country_iso_3_per_deal,
|
cd.main_billing_country_iso_3_per_deal,
|
||||||
cd.effective_deal_start_date_utc,
|
cd.effective_deal_start_date_utc,
|
||||||
cd.effective_deal_start_month,
|
cd.effective_deal_start_month,
|
||||||
|
icnddsd.min_user_in_new_dash_since_date_utc,
|
||||||
cd.hubspot_deal_cancellation_date_utc,
|
cd.hubspot_deal_cancellation_date_utc,
|
||||||
cd.hubspot_deal_cancellation_month,
|
cd.hubspot_deal_cancellation_month,
|
||||||
cd.hubspot_listing_segmentation
|
cd.hubspot_listing_segmentation
|
||||||
from combined_deals cd
|
from combined_deals cd
|
||||||
|
left join int_core__new_dash_deal_since_date icnddsd on cd.id_deal = icnddsd.id_deal
|
||||||
|
|
|
||||||
|
|
@ -496,6 +496,10 @@ models:
|
||||||
to the month.
|
to the month.
|
||||||
data_tests:
|
data_tests:
|
||||||
- not_null
|
- 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
|
- name: hubspot_deal_cancellation_date_utc
|
||||||
data_type: date
|
data_type: date
|
||||||
description: |
|
description: |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue