From 82829db3d2bfa8c5930c8685e0ecc22c0f90ae3d Mon Sep 17 00:00:00 2001 From: Joaquin Date: Thu, 3 Apr 2025 16:00:43 +0200 Subject: [PATCH] Update to listing count in new dash overview --- .../core/int_core__new_dash_user_overview.sql | 37 ++++++++++++------- models/intermediate/core/schema.yml | 19 +++++----- ..._agg_monthly_new_dash_created_bookings.sql | 4 +- ...__agg_weekly_new_dash_created_bookings.sql | 4 +- .../core/core__new_dash_user_overview.sql | 15 ++++---- models/reporting/core/schema.yml | 22 +++++------ 6 files changed, 55 insertions(+), 46 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 8bafed5..db4ac3a 100644 --- a/models/intermediate/core/int_core__new_dash_user_overview.sql +++ b/models/intermediate/core/int_core__new_dash_user_overview.sql @@ -47,26 +47,35 @@ with count( distinct case when - atpb.user_product_bundle_name - not in ({{ var("default_service") }}) + atpb.effective_start_date_utc <= current_date + and coalesce( + atpb.effective_end_date_utc, {{ var("end_of_time") }} + ) + >= current_date then atpb.id_accommodation else null end - ) as total_listings_with_product_bundle_with_paid_service, + ) as total_active_listings_with_active_product_bundle, count( distinct case when - atpb.user_product_bundle_name + atpb.effective_start_date_utc <= current_date + and coalesce( + atpb.effective_end_date_utc, {{ var("end_of_time") }} + ) + >= current_date + and atpb.user_product_bundle_name not in ({{ var("default_service") }}) - and atpb.has_no_end_date = true then atpb.id_accommodation else null end - ) as total_listings_with_active_product_bundle_with_paid_service + ) as total_active_listings_with_active_product_bundle_with_paid_service from int_core__user_product_bundle upb left join int_core__accommodation_to_product_bundle atpb on upb.id_user_product_bundle = atpb.id_user_product_bundle + inner join int_core__accommodation a on upb.id_user_host = a.id_user_host + where a.is_active = true group by 1 ), btpb_aggregation as ( @@ -107,8 +116,8 @@ with upb.total_active_user_product_bundles, a.total_listings, a.total_active_listings, - atpb.total_listings_with_product_bundle_with_paid_service, - atpb.total_listings_with_active_product_bundle_with_paid_service, + atpb.total_active_listings_with_active_product_bundle, + atpb.total_active_listings_with_active_product_bundle_with_paid_service, btpb.total_bookings_with_product_bundle, btpb.total_bookings_with_product_bundle_with_paid_service from upb_aggregation upb @@ -139,17 +148,17 @@ select total_active_user_product_bundles, total_listings, total_active_listings, - total_listings_with_product_bundle_with_paid_service, - total_listings_with_active_product_bundle_with_paid_service, + total_active_listings_with_active_product_bundle, + total_active_listings_with_active_product_bundle_with_paid_service, case when total_active_listings > 0 then 1 else 0 end as has_active_listings, case - when total_listings_with_product_bundle_with_paid_service > 0 then 1 else 0 - end as has_listings_with_paid_service_applied, + when total_active_listings_with_active_product_bundle > 0 then 1 else 0 + end as has_active_listings_with_active_product_bundle_applied, case - when total_listings_with_active_product_bundle_with_paid_service > 0 + when total_active_listings_with_active_product_bundle_with_paid_service > 0 then 1 else 0 - end as has_listings_with_active_paid_service_applied, + end as has_active_listings_with_active_paid_service_applied, total_bookings_with_product_bundle, total_bookings_with_product_bundle_with_paid_service, case diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 9cf2364..9965231 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -2639,16 +2639,15 @@ models: activation - not to be confused with activity-based segmentation). - - name: total_listings_with_product_bundle_with_paid_service + - name: total_active_listings_with_active_product_bundle data_type: integer description: | - Count of listings that have, or have had, a paid service - product bundle activated. + Count of active listings that currently have an active product bundle. - - name: total_listings_with_active_product_bundle_with_paid_service + - name: total_active_listings_with_active_product_bundle_with_paid_service data_type: integer description: | - Count of listings that currently have an active paid service + Count of active listings that currently have an active paid service product bundle. - name: has_active_listings @@ -2656,15 +2655,17 @@ models: description: | Integer-based flag version of total_active_listings. - - name: has_listings_with_paid_service_applied + - name: has_active_listings_with_active_product_bundle_applied data_type: integer description: | - Integer-based flag version of total_listings_with_product_bundle_with_paid_service. + Integer-based flag version of + total_active_listings_with_active_product_bundle. - - name: has_listings_with_active_paid_service_applied + - name: has_active_listings_with_active_paid_service_applied data_type: integer description: | - Integer-based flag version of total_listings_with_active_product_bundle_with_paid_service. + Integer-based flag version of + total_active_listings_with_active_product_bundle_with_paid_service. - name: total_bookings_with_product_bundle data_type: integer diff --git a/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_created_bookings.sql b/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_created_bookings.sql index 185c844..8825648 100644 --- a/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_created_bookings.sql +++ b/models/intermediate/kpis/int_kpis__agg_monthly_new_dash_created_bookings.sql @@ -7,7 +7,7 @@ select -- Unique Key -- d.first_day_month as start_date, - d.date as end_date, + d.last_day_month as end_date, {{ dimension.dimension }} as dimension, {{ dimension.dimension_value }} as dimension_value, -- Metrics -- @@ -16,7 +16,7 @@ left join {{ ref("int_kpis__metric_daily_new_dash_created_bookings") }} as dcb on dcb.date = d.date - where d.is_end_of_month = true and dcb.id_booking is not null + where dcb.id_booking is not null group by 1, 2, 3, 4 {% if not loop.last %} union all diff --git a/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_created_bookings.sql b/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_created_bookings.sql index 5bf664a..8825648 100644 --- a/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_created_bookings.sql +++ b/models/intermediate/kpis/int_kpis__agg_weekly_new_dash_created_bookings.sql @@ -7,7 +7,7 @@ select -- Unique Key -- d.first_day_month as start_date, - d.date as end_date, + d.last_day_month as end_date, {{ dimension.dimension }} as dimension, {{ dimension.dimension_value }} as dimension_value, -- Metrics -- @@ -16,7 +16,7 @@ left join {{ ref("int_kpis__metric_daily_new_dash_created_bookings") }} as dcb on dcb.date = d.date - where d.is_end_of_week = true and dcb.id_booking is not null + where dcb.id_booking is not null group by 1, 2, 3, 4 {% if not loop.last %} union all diff --git a/models/reporting/core/core__new_dash_user_overview.sql b/models/reporting/core/core__new_dash_user_overview.sql index 3e94244..bf19fd1 100644 --- a/models/reporting/core/core__new_dash_user_overview.sql +++ b/models/reporting/core/core__new_dash_user_overview.sql @@ -20,14 +20,15 @@ select total_active_user_product_bundles as total_active_user_product_bundles, total_listings as total_listings, total_active_listings as total_active_listings, - total_listings_with_product_bundle_with_paid_service - as total_listings_with_product_bundle_with_paid_service, - total_listings_with_active_product_bundle_with_paid_service - as total_listings_with_active_product_bundle_with_paid_service, + total_active_listings_with_active_product_bundle + as total_active_listings_with_active_product_bundle, + total_active_listings_with_active_product_bundle_with_paid_service + as total_active_listings_with_active_product_bundle_with_paid_service, has_active_listings as has_active_listings, - has_listings_with_paid_service_applied as has_listings_with_paid_service_applied, - has_listings_with_active_paid_service_applied - as has_listings_with_active_paid_service_applied, + has_active_listings_with_active_product_bundle_applied + as has_active_listings_with_active_product_bundle_applied, + has_active_listings_with_active_paid_service_applied + as has_active_listings_with_active_paid_service_applied, total_bookings_with_product_bundle as total_bookings_with_product_bundle, total_bookings_with_product_bundle_with_paid_service as total_bookings_with_product_bundle_with_paid_service, diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index 52a6aca..22adf6f 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1235,19 +1235,15 @@ models: description: | Count of listings that the user owns. It contains only those that can accept bookings (hard - activation - not to be confused with activity-based - segmentation). - - - name: total_listings_with_product_bundle_with_paid_service + activation - not to be confused with activity-based- name: total_active_listings_with_active_product_bundle data_type: integer description: | - Count of listings that have, or have had, a paid service - product bundle activated. + Count of active listings that currently have an active product bundle. - - name: total_listings_with_active_product_bundle_with_paid_service + - name: total_active_listings_with_active_product_bundle_with_paid_service data_type: integer description: | - Count of listings that currently have an active paid service + Count of active listings that currently have an active paid service product bundle. - name: has_active_listings @@ -1255,15 +1251,17 @@ models: description: | Integer-based flag version of total_active_listings. - - name: has_listings_with_paid_service_applied + - name: has_active_listings_with_active_product_bundle_applied data_type: integer description: | - Integer-based flag version of total_listings_with_product_bundle_with_paid_service. + Integer-based flag version of + total_active_listings_with_active_product_bundle. - - name: has_listings_with_active_paid_service_applied + - name: has_active_listings_with_active_paid_service_applied data_type: integer description: | - Integer-based flag version of total_listings_with_active_product_bundle_with_paid_service. + Integer-based flag version of + total_active_listings_with_active_product_bundle_with_paid_service. - name: total_bookings_with_product_bundle data_type: integer