diff --git a/models/intermediate/kpis/int_kpis__product_new_dash_agg_metrics.sql b/models/intermediate/kpis/int_kpis__product_new_dash_agg_metrics.sql index dc87da1..9fd5702 100644 --- a/models/intermediate/kpis/int_kpis__product_new_dash_agg_metrics.sql +++ b/models/intermediate/kpis/int_kpis__product_new_dash_agg_metrics.sql @@ -16,12 +16,39 @@ with ), int_kpis__agg_monthly_new_dash_chargeable_services as ( select * from {{ ref("int_kpis__agg_monthly_new_dash_chargeable_services") }} + ), + int_kpis__agg_daily_new_dash_deals_offered_services as ( + select * from {{ ref("int_kpis__agg_daily_new_dash_deals_offered_services") }} + ), + int_kpis__agg_weekly_new_dash_deals_offered_services as ( + select * from {{ ref("int_kpis__agg_weekly_new_dash_deals_offered_services") }} + ), + int_kpis__agg_monthly_new_dash_deals_offered_services as ( + select * from {{ ref("int_kpis__agg_monthly_new_dash_deals_offered_services") }} + ), + int_kpis__agg_daily_new_dash_accommodation_offered_services as ( + select * + from {{ ref("int_kpis__agg_daily_new_dash_accommodation_offered_services") }} + ), + int_kpis__agg_weekly_new_dash_accommodation_offered_services as ( + select * + from {{ ref("int_kpis__agg_weekly_new_dash_accommodation_offered_services") }} + ), + int_kpis__agg_monthly_new_dash_accommodation_offered_services as ( + select * + from {{ ref("int_kpis__agg_monthly_new_dash_accommodation_offered_services") }} ) select coalesce(created.date, chargeable.date) as date, 'daily' as time_granularity, coalesce(created.dimension, chargeable.dimension) as dimension, coalesce(created.dimension_value, chargeable.dimension_value) as dimension_value, + coalesce( + deals.deal_with_offered_service_count, 0 + ) as deal_with_offered_service_count, + coalesce( + accommodation.accommodation_with_offered_service_count, 0 + ) as accommodation_with_offered_service_count, coalesce(created.created_services, 0) as created_services, coalesce( created.booking_with_created_services_count, 0 @@ -38,12 +65,28 @@ full outer join on created.date = chargeable.date and created.dimension = chargeable.dimension and created.dimension_value = chargeable.dimension_value +full outer join + int_kpis__agg_daily_new_dash_deals_offered_services deals + on created.date = deals.date + and created.dimension = deals.dimension + and created.dimension_value = deals.dimension_value +full outer join + int_kpis__agg_daily_new_dash_accommodation_offered_services accommodation + on created.date = accommodation.date + and created.dimension = accommodation.dimension + and created.dimension_value = accommodation.dimension_value union all select coalesce(created.end_date, chargeable.end_date) as date, 'weekly' as time_granularity, coalesce(created.dimension, chargeable.dimension) as dimension, coalesce(created.dimension_value, chargeable.dimension_value) as dimension_value, + coalesce( + deals.deal_with_offered_service_count, 0 + ) as deal_with_offered_service_count, + coalesce( + accommodation.accommodation_with_offered_service_count, 0 + ) as accommodation_with_offered_service_count, coalesce(created.created_services, 0) as created_services, coalesce( created.booking_with_created_services_count, 0 @@ -60,12 +103,28 @@ full outer join on created.end_date = chargeable.end_date and created.dimension = chargeable.dimension and created.dimension_value = chargeable.dimension_value +full outer join + int_kpis__agg_weekly_new_dash_deals_offered_services deals + on created.end_date = deals.end_date + and created.dimension = deals.dimension + and created.dimension_value = deals.dimension_value +full outer join + int_kpis__agg_weekly_new_dash_accommodation_offered_services accommodation + on created.end_date = accommodation.end_date + and created.dimension = accommodation.dimension + and created.dimension_value = accommodation.dimension_value union all select coalesce(created.end_date, chargeable.end_date) as date, 'monthly' as time_granularity, coalesce(created.dimension, chargeable.dimension) as dimension, coalesce(created.dimension_value, chargeable.dimension_value) as dimension_value, + coalesce( + deals.deal_with_offered_service_count, 0 + ) as deal_with_offered_service_count, + coalesce( + accommodation.accommodation_with_offered_service_count, 0 + ) as accommodation_with_offered_service_count, coalesce(created.created_services, 0) as created_services, coalesce( created.booking_with_created_services_count, 0 @@ -82,3 +141,13 @@ full outer join on created.end_date = chargeable.end_date and created.dimension = chargeable.dimension and created.dimension_value = chargeable.dimension_value +full outer join + int_kpis__agg_monthly_new_dash_deals_offered_services deals + on created.end_date = deals.end_date + and created.dimension = deals.dimension + and created.dimension_value = deals.dimension_value +full outer join + int_kpis__agg_monthly_new_dash_accommodation_offered_services accommodation + on created.end_date = accommodation.end_date + and created.dimension = accommodation.dimension + and created.dimension_value = accommodation.dimension_value diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index 190472a..641d1dc 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -6711,6 +6711,16 @@ models: data_tests: - not_null + - name: deal_with_offered_service_count + data_type: bigint + description: | + The count of deals with services offered by a given date, dimension and value. + + - name: accommodation_with_offered_service_count + data_type: bigint + description: | + The count of accommodations with services offered by a given date, dimension and value. + - name: created_services data_type: bigint description: | diff --git a/models/reporting/kpis/kpis__product_new_dash_agg_metrics.sql b/models/reporting/kpis/kpis__product_new_dash_agg_metrics.sql index 22d67e2..384abd4 100644 --- a/models/reporting/kpis/kpis__product_new_dash_agg_metrics.sql +++ b/models/reporting/kpis/kpis__product_new_dash_agg_metrics.sql @@ -8,6 +8,9 @@ select {{ capitalise_and_remove_underscores("dimension") }} as dimension, dimension_value as dimension_value, created_services as created_services, + deal_with_offered_service_count as deal_with_offered_service_count, + accommodation_with_offered_service_count + as accommodation_with_offered_service_count, booking_with_created_services_count as booking_with_created_services_count, total_chargeable_services as total_chargeable_services, total_chargeable_amount_in_gbp as total_chargeable_amount_in_gbp, diff --git a/models/reporting/kpis/schema.yml b/models/reporting/kpis/schema.yml index 3682d8e..3f26e78 100644 --- a/models/reporting/kpis/schema.yml +++ b/models/reporting/kpis/schema.yml @@ -315,6 +315,16 @@ models: data_type: bigint description: | The created services for a given time granularity, date or dates range, + + - name: deal_with_offered_service_count + data_type: bigint + description: | + The count of deals with services offered by a given date, dimension and value. + + - name: accommodation_with_offered_service_count + data_type: bigint + description: | + The count of accommodations with services offered by a given date, dimension and value. dimension and value. - name: booking_with_created_services_count