diff --git a/macros/business_kpis_configuration.sql b/macros/business_kpis_configuration.sql index cfce33d..dd5fea2 100644 --- a/macros/business_kpis_configuration.sql +++ b/macros/business_kpis_configuration.sql @@ -134,7 +134,7 @@ Provides a general assignement for the Dimensions available for each KPI {% set additional_dimensions = [] %} {# Adds Deal dimension to all models except DEAL metrics #} - {% if entity_name != "DEALS" %} + {% if entity_name not in ["DEALS", "NEW_DASH_DEALS_OFFERED_SERVICES"] %} {% set additional_dimensions = additional_dimensions + [dim_deal()] %} {% endif %} @@ -188,6 +188,24 @@ Provides a general assignement for the Dimensions available for each KPI ] %} {% endif %} + {% if entity_name == "NEW_DASH_DEALS_OFFERED_SERVICES" %} + {% set additional_dimensions = additional_dimensions + [ + dim_has_upgraded_service(), + dim_new_dash_version(), + dim_pricing_service(), + dim_pricing_business_type(), + ] %} + {% endif %} + + {% if entity_name == "NEW_DASH_ACCOMMODATION_OFFERED_SERVICES" %} + {% set additional_dimensions = additional_dimensions + [ + dim_has_upgraded_service(), + dim_new_dash_version(), + dim_pricing_service(), + dim_pricing_business_type(), + ] %} + {% endif %} + {# Combine base dimensions with additional dimensions for the specific model #} {% set dimensions = base_dimensions + additional_dimensions %} {{ return(dimensions) }} diff --git a/models/intermediate/kpis/int_kpis__agg_daily_new_dash_accommodation_offered_services.sql b/models/intermediate/kpis/int_kpis__agg_daily_new_dash_accommodation_offered_services.sql new file mode 100644 index 0000000..080395d --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_daily_new_dash_accommodation_offered_services.sql @@ -0,0 +1,26 @@ +{% set dimensions = get_kpi_dimensions_per_model( + "NEW_DASH_ACCOMMODATION_OFFERED_SERVICES" +) %} + +{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} + + +{% for dimension in dimensions %} + select + -- Unique Key -- + d.date, + {{ dimension.dimension }} as dimension, + {{ dimension.dimension_value }} as dimension_value, + -- Metrics -- + count(distinct aos.id_accommodation) as accommodation_with_offered_service_count + from {{ ref("int_kpis__dimension_dates") }} d + left join + {{ ref("int_kpis__metric_daily_new_dash_accommodation_offered_services") }} + as aos + on d.date = aos.date + where aos.id_accommodation is not null + group by 1, 2, 3 + {% if not loop.last %} + union all + {% endif %} +{% endfor %} diff --git a/models/intermediate/kpis/int_kpis__agg_daily_new_dash_deals_offered_services.sql b/models/intermediate/kpis/int_kpis__agg_daily_new_dash_deals_offered_services.sql new file mode 100644 index 0000000..4e351ca --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_daily_new_dash_deals_offered_services.sql @@ -0,0 +1,23 @@ +{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_DEALS_OFFERED_SERVICES") %} + +{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} + + +{% for dimension in dimensions %} + select + -- Unique Key -- + d.date, + {{ dimension.dimension }} as dimension, + {{ dimension.dimension_value }} as dimension_value, + -- Metrics -- + count(distinct dos.id_deal) as deal_with_offered_service_count + from {{ ref("int_kpis__dimension_dates") }} d + left join + {{ ref("int_kpis__metric_daily_new_dash_deals_offered_services") }} as dos + on d.date = dos.date + where dos.id_deal is not null + group by 1, 2, 3 + {% if not loop.last %} + union all + {% endif %} +{% endfor %} diff --git a/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_accommodation_offered_services.sql b/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_accommodation_offered_services.sql new file mode 100644 index 0000000..7d82a9c --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_accommodation_offered_services.sql @@ -0,0 +1,26 @@ +{% set dimensions = get_kpi_dimensions_per_model( + "NEW_DASH_ACCOMMODATION_OFFERED_SERVICES" +) %} + +{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} + + +{% for dimension in dimensions %} + select + -- Unique Key -- + d.date, + {{ dimension.dimension }} as dimension, + {{ dimension.dimension_value }} as dimension_value, + -- Metrics -- + count(distinct aos.id_accommodation) as accommodation_with_offered_service_count + from {{ ref("int_kpis__dimension_dates") }} d + left join + {{ ref("int_kpis__metric_daily_new_dash_accommodation_offered_services") }} + as aos + on aos.date = d.date + where d.is_end_of_month = true and aos.id_accommodation is not null + group by 1, 2, 3 + {% if not loop.last %} + union all + {% endif %} +{% endfor %} diff --git a/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_deals_offered_services.sql b/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_deals_offered_services.sql new file mode 100644 index 0000000..31700ef --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_deals_offered_services.sql @@ -0,0 +1,23 @@ +{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_DEALS_OFFERED_SERVICES") %} + +{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} + + +{% for dimension in dimensions %} + select + -- Unique Key -- + d.date, + {{ dimension.dimension }} as dimension, + {{ dimension.dimension_value }} as dimension_value, + -- Metrics -- + count(distinct dos.id_deal) as deal_with_offered_service_count + from {{ ref("int_kpis__dimension_dates") }} d + left join + {{ ref("int_kpis__metric_daily_new_dash_deals_offered_services") }} as dos + on dos.date = d.date + where d.is_end_of_month = true and dos.id_deal is not null + group by 1, 2, 3 + {% if not loop.last %} + union all + {% endif %} +{% endfor %} diff --git a/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_accommodation_offered_services.sql b/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_accommodation_offered_services.sql new file mode 100644 index 0000000..a353a74 --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_accommodation_offered_services.sql @@ -0,0 +1,26 @@ +{% set dimensions = get_kpi_dimensions_per_model( + "NEW_DASH_ACCOMMODATION_OFFERED_SERVICES" +) %} + +{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} + + +{% for dimension in dimensions %} + select + -- Unique Key -- + d.date, + {{ dimension.dimension }} as dimension, + {{ dimension.dimension_value }} as dimension_value, + -- Metrics -- + count(distinct aos.id_accommodation) as accommodation_with_offered_service_count + from {{ ref("int_kpis__dimension_dates") }} d + left join + {{ ref("int_kpis__metric_daily_new_dash_accommodation_offered_services") }} + as aos + on aos.date = d.date + where d.is_end_of_week = true and aos.id_accommodation is not null + group by 1, 2, 3 + {% if not loop.last %} + union all + {% endif %} +{% endfor %} diff --git a/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_deals_offered_services.sql b/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_deals_offered_services.sql new file mode 100644 index 0000000..a7b4175 --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_deals_offered_services.sql @@ -0,0 +1,23 @@ +{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_DEALS_OFFERED_SERVICES") %} + +{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} + + +{% for dimension in dimensions %} + select + -- Unique Key -- + d.date, + {{ dimension.dimension }} as dimension, + {{ dimension.dimension_value }} as dimension_value, + -- Metrics -- + count(distinct dos.id_deal) as deal_with_offered_service_count + from {{ ref("int_kpis__dimension_dates") }} d + left join + {{ ref("int_kpis__metric_daily_new_dash_deals_offered_services") }} as dos + on dos.date = d.date + where d.is_end_of_week = true and dos.id_deal is not null + group by 1, 2, 3 + {% if not loop.last %} + union all + {% endif %} +{% endfor %} diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index b0aee31..190472a 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -7587,4 +7587,317 @@ models: description: | Main billing country of the host aggregated at Deal level. data_tests: - - not_null \ No newline at end of file + - not_null + + - name: int_kpis__agg_daily_new_dash_deals_offered_services + description: | + This model computes the dimension aggregation for Daily Deals Offered Services. + It only retrieves services that come from users that are in New Dash, as well + as it only considers services created after the user has moved to New Dash. + The primary key of this model is date, dimension and dimension_value. + + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - date + - dimension + - dimension_value + + columns: + - name: date + data_type: date + description: | + The daily date acting as time range for the metrics in this record. + data_tests: + - not_null + + - name: dimension + data_type: string + description: The dimension or granularity of the metrics. + data_tests: + - assert_dimension_completeness: + metric_column_names: + - deal_with_offered_service_count + where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version')" + - accepted_values: + values: + - global + - by_number_of_listings + - by_billing_country + - by_new_dash_version + - by_has_upgraded_service + - by_service + - by_service_business_type + + - name: dimension_value + data_type: string + description: The value or segment available for the selected dimension. + data_tests: + - not_null + + - name: deal_with_offered_service_count + data_type: bigint + description: | + The daily count of deals with services offered for a given date, dimension and value. + + - name: int_kpis__agg_weekly_new_dash_deals_offered_services + description: | + This model computes the dimension aggregation for Number of Deals with + Offered Services by the end of each week. + It only retrieves services that come from users that are in New Dash, as well + as it only considers services created after the user has moved to New Dash. + The primary key of this model is date, dimension and dimension_value. + + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - date + - dimension + - dimension_value + + columns: + - name: date + data_type: date + description: | + The end date of the week. + data_tests: + - not_null + + - name: dimension + data_type: string + description: The dimension or granularity of the metrics. + data_tests: + - assert_dimension_completeness: + metric_column_names: + - deal_with_offered_service_count + where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version')" + - accepted_values: + values: + - global + - by_number_of_listings + - by_billing_country + - by_new_dash_version + - by_has_upgraded_service + - by_service + - by_service_business_type + + - name: dimension_value + data_type: string + description: The value or segment available for the selected dimension. + data_tests: + - not_null + + - name: deal_with_offered_service_count + data_type: bigint + description: | + The count of deals with services offered by the end of a given week, dimension and value. + + - name: int_kpis__agg_monthly_new_dash_deals_offered_services + description: | + This model computes the dimension aggregation for Number of Deals with + Offered Services by the end of each month. + It only retrieves services that come from users that are in New Dash, as well + as it only considers services created after the user has moved to New Dash. + The primary key of this model is date, dimension and dimension_value. + + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - date + - dimension + - dimension_value + + columns: + - name: date + data_type: date + description: | + The end date of the month. + data_tests: + - not_null + + - name: dimension + data_type: string + description: The dimension or granularity of the metrics. + data_tests: + - assert_dimension_completeness: + metric_column_names: + - deal_with_offered_service_count + where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version')" + - accepted_values: + values: + - global + - by_number_of_listings + - by_billing_country + - by_new_dash_version + - by_has_upgraded_service + - by_service + - by_service_business_type + + - name: dimension_value + data_type: string + description: The value or segment available for the selected dimension. + data_tests: + - not_null + + - name: deal_with_offered_service_count + data_type: bigint + description: | + The count of deals with services offered by the end of a given month, dimension and value. + + - name: int_kpis__agg_daily_new_dash_accommodation_offered_services + description: | + This model computes the dimension aggregation for Daily Accommodation Offered Services. + It only retrieves services that come from users that are in New Dash, as well + as it only considers services created after the user has moved to New Dash. + The primary key of this model is date, dimension and dimension_value. + + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - date + - dimension + - dimension_value + + columns: + - name: date + data_type: date + description: | + The daily date acting as time range for the metrics in this record. + data_tests: + - not_null + + - name: dimension + data_type: string + description: The dimension or granularity of the metrics. + data_tests: + - assert_dimension_completeness: + metric_column_names: + - accommodation_with_offered_service_count + where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version', 'by_deal')" + - accepted_values: + values: + - global + - by_number_of_listings + - by_billing_country + - by_new_dash_version + - by_deal + - by_has_upgraded_service + - by_service + - by_service_business_type + + - name: dimension_value + data_type: string + description: The value or segment available for the selected dimension. + data_tests: + - not_null + + - name: accommodation_with_offered_service_count + data_type: bigint + description: | + The daily count of accommodations with services offered for a given date, dimension and value. + + - name: int_kpis__agg_weekly_new_dash_accommodation_offered_services + description: | + This model computes the dimension aggregation for Number of Accommodation with + Offered Services by the end of each week. + It only retrieves services that come from users that are in New Dash, as well + as it only considers services created after the user has moved to New Dash. + The primary key of this model is date, dimension and dimension_value. + + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - date + - dimension + - dimension_value + + columns: + - name: date + data_type: date + description: | + The end date of the week. + data_tests: + - not_null + + - name: dimension + data_type: string + description: The dimension or granularity of the metrics. + data_tests: + - assert_dimension_completeness: + metric_column_names: + - accommodation_with_offered_service_count + where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version', 'by_deal')" + - accepted_values: + values: + - global + - by_number_of_listings + - by_billing_country + - by_new_dash_version + - by_deal + - by_has_upgraded_service + - by_service + - by_service_business_type + + - name: dimension_value + data_type: string + description: The value or segment available for the selected dimension. + data_tests: + - not_null + + - name: accommodation_with_offered_service_count + data_type: bigint + description: | + The count of accommodations with services offered by the end of a given week, dimension and value. + + - name: int_kpis__agg_monthly_new_dash_accommodation_offered_services + description: | + This model computes the dimension aggregation for Number of Accommodation with + Offered Services by the end of each month. + It only retrieves services that come from users that are in New Dash, as well + as it only considers services created after the user has moved to New Dash. + The primary key of this model is date, dimension and dimension_value. + + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - date + - dimension + - dimension_value + + columns: + - name: date + data_type: date + description: | + The end date of the month. + data_tests: + - not_null + + - name: dimension + data_type: string + description: The dimension or granularity of the metrics. + data_tests: + - assert_dimension_completeness: + metric_column_names: + - accommodation_with_offered_service_count + where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version', 'by_deal')" + - accepted_values: + values: + - global + - by_number_of_listings + - by_billing_country + - by_new_dash_version + - by_deal + - by_has_upgraded_service + - by_service + - by_service_business_type + + - name: dimension_value + data_type: string + description: The value or segment available for the selected dimension. + data_tests: + - not_null + + - name: accommodation_with_offered_service_count + data_type: bigint + description: | + The count of accommodations with services offered by the end of a given month, dimension and value. \ No newline at end of file