diff --git a/macros/business_kpis_configuration.sql b/macros/business_kpis_configuration.sql index 7a55df6..dd5fea2 100644 --- a/macros/business_kpis_configuration.sql +++ b/macros/business_kpis_configuration.sql @@ -197,6 +197,15 @@ Provides a general assignement for the Dimensions available for each KPI ] %} {% 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..5a09e66 --- /dev/null +++ b/models/intermediate/kpis/int_kpis__agg_daily_new_dash_accommodation_offered_services.sql @@ -0,0 +1,25 @@ +{% 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 + inner join + {{ ref("int_kpis__metric_daily_new_dash_accommodation_offered_services") }} + as aos + on d.date = aos.date + 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..8addb32 --- /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 + inner 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 + 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..f032e82 --- /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 + inner 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 + 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 65fbf58..e931cab 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -7690,7 +7690,7 @@ models: - 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. + 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: | @@ -7742,4 +7742,162 @@ models: - 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. \ No newline at end of file + 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: + - deal_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: + - deal_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: + - deal_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