Updated model
This commit is contained in:
parent
0536cfb0e2
commit
2461286c9c
5 changed files with 79 additions and 1 deletions
|
|
@ -166,7 +166,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,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
-- HubSpot stage for live deals
|
||||||
|
{% set live_stage = "Live" %}
|
||||||
|
{% set churned_state = "05-Churning" %}
|
||||||
|
|
||||||
{{ config(materialized="table", unique_key=["date", "id_deal"]) }}
|
{{ config(materialized="table", unique_key=["date", "id_deal"]) }}
|
||||||
with
|
with
|
||||||
int_monthly_aggregated_metrics_history_by_deal as (
|
int_monthly_aggregated_metrics_history_by_deal as (
|
||||||
|
|
@ -557,7 +561,32 @@ select
|
||||||
d.account_manager,
|
d.account_manager,
|
||||||
d.live_date_utc,
|
d.live_date_utc,
|
||||||
d.cancellation_date_utc,
|
d.cancellation_date_utc,
|
||||||
|
case
|
||||||
|
when mabd.deal_lifecycle_state = '{{churned_state}}'
|
||||||
|
then coalesce(d.cancellation_date_utc, mabd.date) - d.live_date_utc
|
||||||
|
else null
|
||||||
|
end as days_between_live_and_churn,
|
||||||
|
d.last_contacted_date_utc,
|
||||||
|
case
|
||||||
|
when mabd.deal_lifecycle_state = '{{churned_state}}'
|
||||||
|
then
|
||||||
|
case
|
||||||
|
when
|
||||||
|
coalesce(d.cancellation_date_utc, mabd.date)
|
||||||
|
- d.last_contacted_date_utc
|
||||||
|
< 0
|
||||||
|
then null
|
||||||
|
else
|
||||||
|
coalesce(d.cancellation_date_utc, mabd.date)
|
||||||
|
- d.last_contacted_date_utc
|
||||||
|
end
|
||||||
|
else null
|
||||||
|
end as days_between_last_contacted_and_churn,
|
||||||
|
d.amount_times_contacted,
|
||||||
d.cancellation_category,
|
d.cancellation_category,
|
||||||
|
case
|
||||||
|
when d.deal_hubspot_stage = '{{ live_stage }}' then true else false
|
||||||
|
end as is_churning_from_inactivity,
|
||||||
|
|
||||||
-- Windowed metrics
|
-- Windowed metrics
|
||||||
coalesce(mabd.sum_created_bookings, 0) as created_bookings,
|
coalesce(mabd.sum_created_bookings, 0) as created_bookings,
|
||||||
|
|
|
||||||
|
|
@ -1636,6 +1636,44 @@ models:
|
||||||
Hubspot. It can be null if the deal has never
|
Hubspot. It can be null if the deal has never
|
||||||
churned.
|
churned.
|
||||||
|
|
||||||
|
- name: days_between_live_and_churn
|
||||||
|
data_type: integer
|
||||||
|
description: |
|
||||||
|
Number of days between the live date and the
|
||||||
|
churn date.
|
||||||
|
data_tests:
|
||||||
|
- dbt_expectations.expect_column_values_to_be_between:
|
||||||
|
min_value: 0
|
||||||
|
strictly: false
|
||||||
|
|
||||||
|
- name: last_contacted_date_utc
|
||||||
|
data_type: date
|
||||||
|
description: |
|
||||||
|
Date when the deal was last contacted according to
|
||||||
|
Hubspot.
|
||||||
|
|
||||||
|
- name: days_between_last_contacted_and_churn
|
||||||
|
data_type: integer
|
||||||
|
description: |
|
||||||
|
Number of days between the last contacted date
|
||||||
|
and the churn date.
|
||||||
|
data_tests:
|
||||||
|
- dbt_expectations.expect_column_values_to_be_between:
|
||||||
|
min_value: 0
|
||||||
|
strictly: false
|
||||||
|
|
||||||
|
- name: amount_times_contacted
|
||||||
|
data_type: integer
|
||||||
|
description: |
|
||||||
|
Number of times the deal was contacted according
|
||||||
|
to Hubspot.
|
||||||
|
|
||||||
|
- name: is_churning_from_inactivity
|
||||||
|
data_type: boolean
|
||||||
|
description: |
|
||||||
|
Flag to identify if the deal is churning due to
|
||||||
|
inactivity because of lack of bookings in the past 12 months.
|
||||||
|
|
||||||
- name: created_bookings
|
- name: created_bookings
|
||||||
data_type: integer
|
data_type: integer
|
||||||
description: |
|
description: |
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ select
|
||||||
d.cancellation_category,
|
d.cancellation_category,
|
||||||
d.cancellation_details,
|
d.cancellation_details,
|
||||||
d.amount_of_properties,
|
d.amount_of_properties,
|
||||||
|
d.last_contacted_date_utc,
|
||||||
|
d.amount_times_contacted,
|
||||||
d.created_at_utc,
|
d.created_at_utc,
|
||||||
d.created_date_utc,
|
d.created_date_utc,
|
||||||
d.updated_at_utc,
|
d.updated_at_utc,
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,14 @@ models:
|
||||||
Amount of properties the owner told us they manage. This is not necessarily the
|
Amount of properties the owner told us they manage. This is not necessarily the
|
||||||
amount of properties that will be finally booked in our business.
|
amount of properties that will be finally booked in our business.
|
||||||
|
|
||||||
|
- name: last_contacted_date_utc
|
||||||
|
data_type: date
|
||||||
|
description: Date in which the account was last contacted
|
||||||
|
|
||||||
|
- name: amount_times_contacted
|
||||||
|
data_type: integer
|
||||||
|
description: Amount of times the account has been contacted
|
||||||
|
|
||||||
- name: created_at_utc
|
- name: created_at_utc
|
||||||
data_type: timestamp with time zone
|
data_type: timestamp with time zone
|
||||||
description: Timestamp of when the record was created in Hubspot
|
description: Timestamp of when the record was created in Hubspot
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue