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..135da8d 100644 --- a/models/intermediate/core/int_core__new_dash_user_overview.sql +++ b/models/intermediate/core/int_core__new_dash_user_overview.sql @@ -44,6 +44,7 @@ with atpb_aggregation as ( select upb.id_user_host, + -- To be deleted from here count( distinct case when @@ -62,11 +63,40 @@ with then atpb.id_accommodation else null end - ) as total_listings_with_active_product_bundle_with_paid_service + ) as total_listings_with_active_product_bundle_with_paid_service, + -- To be deleted until here + count( + distinct case + when + 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_active_listings_with_active_product_bundle, + count( + distinct case + when + 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") }}) + then atpb.id_accommodation + else null + end + ) 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 +137,12 @@ with upb.total_active_user_product_bundles, a.total_listings, a.total_active_listings, + atpb.total_active_listings_with_active_product_bundle, + atpb.total_active_listings_with_active_product_bundle_with_paid_service, + -- To be deleted from here atpb.total_listings_with_product_bundle_with_paid_service, atpb.total_listings_with_active_product_bundle_with_paid_service, + -- To be deleted until here btpb.total_bookings_with_product_bundle, btpb.total_bookings_with_product_bundle_with_paid_service from upb_aggregation upb @@ -139,9 +173,20 @@ select total_active_user_product_bundles, total_listings, total_active_listings, + 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_active_listings_with_active_product_bundle > 0 then 1 else 0 + end as has_active_listings_with_active_product_bundle_applied, + case + when total_active_listings_with_active_product_bundle_with_paid_service > 0 + then 1 + else 0 + end as has_active_listings_with_active_paid_service_applied, + -- To be deleted from here total_listings_with_product_bundle_with_paid_service, total_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, @@ -150,6 +195,7 @@ select then 1 else 0 end as has_listings_with_active_paid_service_applied, + -- To be deleted until here 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..5d40b9a 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -2639,6 +2639,35 @@ models: activation - not to be confused with activity-based segmentation). + - name: total_active_listings_with_active_product_bundle + data_type: integer + description: | + Count of active listings that currently have an active product bundle. + + - name: total_active_listings_with_active_product_bundle_with_paid_service + data_type: integer + description: | + Count of active listings that currently have an active paid service + product bundle. + + - name: has_active_listings + data_type: integer + description: | + Integer-based flag version of total_active_listings. + + - name: has_active_listings_with_active_product_bundle_applied + data_type: integer + description: | + Integer-based flag version of + total_active_listings_with_active_product_bundle. + + - name: has_active_listings_with_active_paid_service_applied + data_type: integer + description: | + Integer-based flag version of + total_active_listings_with_active_product_bundle_with_paid_service. + + # To be deleted from here - name: total_listings_with_product_bundle_with_paid_service data_type: integer description: | @@ -2651,11 +2680,6 @@ models: Count of listings that currently have an active paid service product bundle. - - name: has_active_listings - data_type: integer - description: | - Integer-based flag version of total_active_listings. - - name: has_listings_with_paid_service_applied data_type: integer description: | @@ -2665,6 +2689,7 @@ models: data_type: integer description: | Integer-based flag version of total_listings_with_active_product_bundle_with_paid_service. + # To be deleted until here - 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..984fe91 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 @@ -6,8 +6,8 @@ {% for dimension in dimensions %} select -- Unique Key -- - d.first_day_month as start_date, - d.date as end_date, + d.first_day_week as start_date, + d.last_day_week 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..242a782 100644 --- a/models/reporting/core/core__new_dash_user_overview.sql +++ b/models/reporting/core/core__new_dash_user_overview.sql @@ -20,14 +20,24 @@ 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_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_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, + -- To be deleted from here 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, - 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, + -- To be deleted until here 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..7bebd57 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1237,7 +1237,36 @@ models: It contains only those that can accept bookings (hard activation - not to be confused with activity-based segmentation). + + - name: total_active_listings_with_active_product_bundle + data_type: integer + description: | + Count of active listings that currently have an active product bundle. + - name: total_active_listings_with_active_product_bundle_with_paid_service + data_type: integer + description: | + Count of active listings that currently have an active paid service + product bundle. + + - name: has_active_listings + data_type: integer + description: | + Integer-based flag version of total_active_listings. + + - name: has_active_listings_with_active_product_bundle_applied + data_type: integer + description: | + Integer-based flag version of + total_active_listings_with_active_product_bundle. + + - name: has_active_listings_with_active_paid_service_applied + data_type: integer + description: | + Integer-based flag version of + total_active_listings_with_active_product_bundle_with_paid_service. + + # To be deleted from here - name: total_listings_with_product_bundle_with_paid_service data_type: integer description: | @@ -1250,11 +1279,6 @@ models: Count of listings that currently have an active paid service product bundle. - - name: has_active_listings - data_type: integer - description: | - Integer-based flag version of total_active_listings. - - name: has_listings_with_paid_service_applied data_type: integer description: | @@ -1264,6 +1288,7 @@ models: data_type: integer description: | Integer-based flag version of total_listings_with_active_product_bundle_with_paid_service. + # To be deleted until here - name: total_bookings_with_product_bundle data_type: integer