From 3833f3e92d9de47429e1aa739f17bbcda257dc96 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Thu, 27 Mar 2025 17:56:36 +0100 Subject: [PATCH 1/2] Added current deal lifecycle to new dash overview --- .../core/int_core__new_dash_user_overview.sql | 9 +++++++++ models/intermediate/core/schema.yml | 18 ++++++++++++++++++ .../core/core__new_dash_user_overview.sql | 1 + models/reporting/core/schema.yml | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/models/intermediate/core/int_core__new_dash_user_overview.sql b/models/intermediate/core/int_core__new_dash_user_overview.sql index a719f18..60f10e8 100644 --- a/models/intermediate/core/int_core__new_dash_user_overview.sql +++ b/models/intermediate/core/int_core__new_dash_user_overview.sql @@ -10,6 +10,12 @@ with int_core__accommodation_to_product_bundle as ( select * from {{ ref("int_core__accommodation_to_product_bundle") }} ), + int_kpis__lifecycle_daily_deal as ( + select * + from {{ ref("int_kpis__lifecycle_daily_deal") }} + -- Only retrieve deals lifecycle from yesterday + where date = current_date - 1 + ), upb_aggregation as ( select upb.id_user_host, @@ -89,6 +95,7 @@ with uh.has_user_moved_from_old_dash, uh.new_dash_version as user_migration_phase, uh.user_in_new_dash_since_date_utc as user_estimated_migration_date_utc, + kldd.deal_lifecycle_state, uh.has_active_pms, uh.active_pms_list, uh.company_name, @@ -112,6 +119,7 @@ with int_core__user_host uh on upb.id_user_host = uh.id_user_host and uh.is_test_account = false + left join int_kpis__lifecycle_daily_deal kldd on uh.id_deal = kldd.id_deal ) select id_user_host, @@ -119,6 +127,7 @@ select has_user_moved_from_old_dash, user_migration_phase, user_estimated_migration_date_utc, + deal_lifecycle_state, has_active_pms, active_pms_list, company_name, diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 24681c3..94ff919 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -2559,6 +2559,24 @@ models: data_tests: - not_null + - name: deal_lifecycle_state + data_type: character varying + description: | + Contains the lifecycle state of a deal. The accepted values are: + 01-New, 02-Never Booked, 04-Active, 05-Churning, 06-Inactive, + 07-Reactivated, 99-Not in Husbpot. + data_tests: + - not_null + - accepted_values: + values: + - 01-New + - 02-Never Booked + - 04-Active + - 05-Churning + - 06-Inactive + - 07-Reactivated + - 99-Not in HubSpot + - name: has_active_pms data_type: boolean description: | diff --git a/models/reporting/core/core__new_dash_user_overview.sql b/models/reporting/core/core__new_dash_user_overview.sql index 1a011d2..eb10048 100644 --- a/models/reporting/core/core__new_dash_user_overview.sql +++ b/models/reporting/core/core__new_dash_user_overview.sql @@ -8,6 +8,7 @@ select has_user_moved_from_old_dash as has_user_moved_from_old_dash, user_migration_phase as user_migration_phase, user_estimated_migration_date_utc as user_estimated_migration_date_utc, + deal_lifecycle_state as deal_lifecycle_state, has_active_pms as has_active_pms, active_pms_list as active_pms_list, company_name as company_name, diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index 8cda71c..8c9cb97 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1158,6 +1158,24 @@ models: data_tests: - not_null + - name: deal_lifecycle_state + data_type: character varying + description: | + Contains the lifecycle state of a deal. The accepted values are: + 01-New, 02-Never Booked, 04-Active, 05-Churning, 06-Inactive, + 07-Reactivated, 99-Not in Husbpot. + data_tests: + - not_null + - accepted_values: + values: + - 01-New + - 02-Never Booked + - 04-Active + - 05-Churning + - 06-Inactive + - 07-Reactivated + - 99-Not in HubSpot + - name: has_active_pms data_type: boolean description: | From b138e0c626f874796e3211bda288c317a64952b3 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Fri, 28 Mar 2025 09:02:12 +0100 Subject: [PATCH 2/2] Added boolean --- .../intermediate/core/int_core__new_dash_user_overview.sql | 2 +- models/intermediate/kpis/int_kpis__lifecycle_daily_deal.sql | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/models/intermediate/core/int_core__new_dash_user_overview.sql b/models/intermediate/core/int_core__new_dash_user_overview.sql index 60f10e8..cd06eea 100644 --- a/models/intermediate/core/int_core__new_dash_user_overview.sql +++ b/models/intermediate/core/int_core__new_dash_user_overview.sql @@ -14,7 +14,7 @@ with select * from {{ ref("int_kpis__lifecycle_daily_deal") }} -- Only retrieve deals lifecycle from yesterday - where date = current_date - 1 + where is_current_state = true ), upb_aggregation as ( select diff --git a/models/intermediate/kpis/int_kpis__lifecycle_daily_deal.sql b/models/intermediate/kpis/int_kpis__lifecycle_daily_deal.sql index 2f775d8..74c69a7 100644 --- a/models/intermediate/kpis/int_kpis__lifecycle_daily_deal.sql +++ b/models/intermediate/kpis/int_kpis__lifecycle_daily_deal.sql @@ -53,6 +53,7 @@ with deal_historic_booking_dates as ( select d.date, + d.is_yesterday, ikdd.id_deal, ikdd.is_deal_in_hubspot, min(ikdd.client_type) as client_type, @@ -66,11 +67,12 @@ with booked_days_per_deal b on ikdd.id_deal = b.id_deal and d.date >= b.created_date_utc - group by d.date, ikdd.id_deal, ikdd.is_deal_in_hubspot + group by d.date, d.is_yesterday, ikdd.id_deal, ikdd.is_deal_in_hubspot ), deal_historic_features as ( select hhbf.date, + case when hhbf.is_yesterday then true else false end as is_current_state, hhbf.id_deal, hhbf.is_deal_in_hubspot, hhbf.creation_date_utc, @@ -151,6 +153,7 @@ with ) select date, + is_current_state, id_deal, creation_date_utc, first_time_booked_date_utc,