diff --git a/macros/business_kpis_configuration.sql b/macros/business_kpis_configuration.sql index 2c09e3f..f7779dc 100644 --- a/macros/business_kpis_configuration.sql +++ b/macros/business_kpis_configuration.sql @@ -136,17 +136,18 @@ Provides a general assignement for the Dimensions available for each KPI {# Add entity-specific dimensions #} {% if entity_name in [ + "BILLABLE_BOOKINGS", "CHECK_OUT_BOOKINGS", "COMPLETED_GUEST_JOURNEYS", "CREATED_BOOKINGS", "CREATED_GUEST_JOURNEYS", + "DEALS", "GUEST_JOURNEYS_WITH_PAYMENT", "GUEST_PAYMENTS", - "STARTED_GUEST_JOURNEYS", - "INVOICED_REVENUE", "HOST_RESOLUTIONS", + "INVOICED_REVENUE", "LISTINGS", - "DEALS", + "STARTED_GUEST_JOURNEYS", ] %} {% set additional_dimensions = additional_dimensions + [dim_business_scope()] %} {% endif %} diff --git a/models/intermediate/kpis/int_kpis__metric_daily_billable_bookings.sql b/models/intermediate/kpis/int_kpis__metric_daily_billable_bookings.sql index 8d7b8e8..3c8f016 100644 --- a/models/intermediate/kpis/int_kpis__metric_daily_billable_bookings.sql +++ b/models/intermediate/kpis/int_kpis__metric_daily_billable_bookings.sql @@ -1,8 +1,24 @@ -{{ config(materialized="table", unique_key=["date", "id_deal"]) }} +{{ config(materialized="table", unique_key=["date", "id_deal", "business_scope"]) }} select -- Unique Key -- icb.booking_fee_charge_date_utc as date, coalesce(icuh.id_deal, 'UNSET') as id_deal, + -- ORP here: I'm expecting this to change according to the definition of Billable + -- Bookings expected for New Dash. This is just a temporary placeholder in the + -- same fashion as Booking metrics. + case + -- New Dash users with a booking and a deal + when + icbs.id_booking is not null + and icbs.is_user_in_new_dash = true + and icbs.is_missing_id_deal = false + then 'New Dash' + -- Old Dash users if there is no booking or the user is not in the new dash + when icbs.id_booking is null or icbs.is_user_in_new_dash = false + then 'Old Dash' + -- Rest of the cases, includes KYG Lite users + else 'UNSET' + end as business_scope, -- Dimensions -- coalesce( icd.main_billing_country_iso_3_per_deal, 'UNSET' @@ -20,5 +36,7 @@ left join {{ ref("int_kpis__dimension_daily_accommodation") }} as icmas on icuh.id_deal = icmas.id_deal and icb.booking_fee_charge_date_utc = icmas.date -where icb.booking_fee_charge_date_utc is not null -group by 1, 2, 3, 4 +left join + {{ ref("int_core__booking_summary") }} as icbs on icb.id_booking = icbs.id_booking +where icb.is_duplicate_booking = false and icb.booking_fee_charge_date_utc is not null +group by 1, 2, 3, 4, 5 diff --git a/models/intermediate/kpis/int_kpis__metric_monthly_billable_bookings.sql b/models/intermediate/kpis/int_kpis__metric_monthly_billable_bookings.sql index 5c883df..93705f9 100644 --- a/models/intermediate/kpis/int_kpis__metric_monthly_billable_bookings.sql +++ b/models/intermediate/kpis/int_kpis__metric_monthly_billable_bookings.sql @@ -5,6 +5,7 @@ "end_date", "id_deal", "active_accommodations_per_deal_segmentation", + "business_scope", ], ) }} @@ -14,6 +15,7 @@ select d.first_day_month as start_date, d.date as end_date, b.id_deal, + b.business_scope, b.active_accommodations_per_deal_segmentation, -- Dimensions -- b.main_billing_country_iso_3_per_deal, @@ -24,4 +26,4 @@ left join {{ ref("int_kpis__metric_daily_billable_bookings") }} b on date_trunc('month', b.date)::date = d.first_day_month where d.is_end_of_month = true and b.id_deal is not null -group by 1, 2, 3, 4, 5 +group by 1, 2, 3, 4, 5, 6 diff --git a/models/intermediate/kpis/int_kpis__metric_mtd_billable_bookings.sql b/models/intermediate/kpis/int_kpis__metric_mtd_billable_bookings.sql index bd2ab41..f7e0769 100644 --- a/models/intermediate/kpis/int_kpis__metric_mtd_billable_bookings.sql +++ b/models/intermediate/kpis/int_kpis__metric_mtd_billable_bookings.sql @@ -5,6 +5,7 @@ "end_date", "id_deal", "active_accommodations_per_deal_segmentation", + "business_scope", ], ) }} @@ -14,6 +15,7 @@ select d.first_day_month as start_date, d.date as end_date, b.id_deal, + b.business_scope, b.active_accommodations_per_deal_segmentation, -- Dimensions -- b.main_billing_country_iso_3_per_deal, @@ -25,4 +27,4 @@ left join on date_trunc('month', b.date)::date = d.first_day_month and extract(day from b.date) <= d.day where d.is_month_to_date = true and b.id_deal is not null -group by 1, 2, 3, 4, 5 +group by 1, 2, 3, 4, 5, 6 diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index cd1126c..3162502 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -3304,13 +3304,15 @@ models: The unique key corresponds to the deepest granularity of the model, in this case: - date, - - id_deal. + - id_deal, + - business_scope. data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - date - id_deal + - business_scope columns: - name: date @@ -3325,6 +3327,19 @@ models: data_tests: - not_null + - name: business_scope + data_type: string + description: | + Business scope identifying the metric source. + data_tests: + - not_null + - accepted_values: + values: + - "Old Dash" + - "New Dash" + - "API" + - "UNSET" + - name: active_accommodations_per_deal_segmentation data_type: string description: | @@ -3364,6 +3379,7 @@ models: The unique key corresponds to: - end_date, - id_deal, + - business_scope, - active_accommodations_per_deal_segmentation. data_tests: @@ -3371,6 +3387,7 @@ models: combination_of_columns: - end_date - id_deal + - business_scope - active_accommodations_per_deal_segmentation columns: @@ -3394,6 +3411,19 @@ models: data_tests: - not_null + - name: business_scope + data_type: string + description: | + Business scope identifying the metric source. + data_tests: + - not_null + - accepted_values: + values: + - "Old Dash" + - "New Dash" + - "API" + - "UNSET" + - name: active_accommodations_per_deal_segmentation data_type: string description: | @@ -3434,6 +3464,7 @@ models: The unique key corresponds to: - end_date, - id_deal, + - business_scope, - active_accommodations_per_deal_segmentation. data_tests: @@ -3441,6 +3472,7 @@ models: combination_of_columns: - end_date - id_deal + - business_scope - active_accommodations_per_deal_segmentation columns: @@ -3464,6 +3496,19 @@ models: data_tests: - not_null + - name: business_scope + data_type: string + description: | + Business scope identifying the metric source. + data_tests: + - not_null + - accepted_values: + values: + - "Old Dash" + - "New Dash" + - "API" + - "UNSET" + - name: active_accommodations_per_deal_segmentation data_type: string description: | @@ -3535,6 +3580,7 @@ models: - global - by_number_of_listings - by_billing_country + - by_business_scope - by_deal - name: dimension_value @@ -3589,6 +3635,7 @@ models: - global - by_number_of_listings - by_billing_country + - by_business_scope - by_deal - name: dimension_value