Merged PR 4912: Update to listing count in new dash overview

# Description

According to our previous conversation, modified the values for active listings and how they will be shown on the report's funnel.
_This changes will crash the report for now, I was thinking on adding a **work in progress** warning to both Overview and User Details tab in the meantime. After this the report should be soon ready_
Now we are going to have:
- **total_listings**
- **total_active_listings**
- **total_active_listings_with_active_product_bundle**
- **total_active_listings_with_active_product_bundle_with_paid_service**

![image.png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/4912/attachments/image.png)

Also fixed an aggregation mishap I had with the created bookings aggregated models

# Checklist

- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Update to listing count in new dash overview

Related work items: #28640
This commit is contained in:
Joaquin Ossa 2025-04-04 07:07:24 +00:00
commit 0cec376e49
6 changed files with 124 additions and 18 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -1238,6 +1238,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: |
@ -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