From 9af7b27e04e75c285ebcf290f17055e9ef3ba112 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 12 Feb 2025 15:00:31 +0100 Subject: [PATCH 1/4] new active_users data --- .../int_core__new_dash_services_offered.sql | 19 ++++++++++++++++++- models/intermediate/core/schema.yml | 15 +++++++++++++++ .../core/core__new_dash_services_offered.sql | 2 ++ models/reporting/core/schema.yml | 15 +++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/models/intermediate/core/int_core__new_dash_services_offered.sql b/models/intermediate/core/int_core__new_dash_services_offered.sql index fe604cc..1e36100 100644 --- a/models/intermediate/core/int_core__new_dash_services_offered.sql +++ b/models/intermediate/core/int_core__new_dash_services_offered.sql @@ -46,8 +46,23 @@ with ), users as ( select distinct - bs.service_display_name, count(distinct bs.id_user_host) as number_users + bs.service_display_name, + count(distinct bs.id_user_host) as number_users, + -- Count only users that have at least one active accommodation. + -- with this service. + count( + distinct case + when apb.id_accommodation is not null and a.is_active + then bs.id_user_host + else null + end + ) as number_active_users from bundle_services bs + left join + int_core__accommodation_to_product_bundle apb + on bs.id_user_product_bundle = apb.id_user_product_bundle + and bs.id_user_host = apb.id_user_host + left join int_core__accommodation a on apb.id_accommodation = a.id_accommodation group by 1 ), accommodations as ( @@ -141,6 +156,8 @@ with select u.service_display_name, u.number_users, + u.number_active_users, + u.number_users - u.number_active_users as number_inactive_users, a.number_accommodations, a.number_active_accommodations, a.number_inactive_accommodations, diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 05f7141..03225c3 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -5263,6 +5263,21 @@ models: that the service is active or used. Each user can associate any of their bundles with any of their accommodations." + - name: number_active_users + data_type: bigint + description: + "Number of user accounts that have a bundle that considers this service + and that bundle is active in at least one active accommodation. + In other words there is at least one active accommodation that offers + this service for this number of users." + - name: number_inactive_users + data_type: bigint + description: + "Number of user accounts that have a bundle that considers this service + but none of those bundle with the service is active in any active + accommodation. + It is basically the difference between number_users and number_active_users." + - name: number_accommodations data_type: bigint description: diff --git a/models/reporting/core/core__new_dash_services_offered.sql b/models/reporting/core/core__new_dash_services_offered.sql index 292d303..a24ab8e 100644 --- a/models/reporting/core/core__new_dash_services_offered.sql +++ b/models/reporting/core/core__new_dash_services_offered.sql @@ -5,6 +5,8 @@ with select service_display_name as service_display_name, number_users as number_users, + number_active_users as number_active_users, + number_inactive_users as number_inactive_users, number_accommodations as number_accommodations, number_active_accommodations as number_active_accommodations, number_inactive_accommodations as number_inactive_accommodations, diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index b3aff9c..c465f28 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1601,6 +1601,21 @@ models: that the service is active or used. Each user can associate any of their bundles with any of their accommodations." + - name: number_active_users + data_type: bigint + description: + "Number of user accounts that have a bundle that considers this service + and that bundle is active in at least one active accommodation. + In other words there is at least one active accommodation that offers + this service for this number of users." + - name: number_inactive_users + data_type: bigint + description: + "Number of user accounts that have a bundle that considers this service + but none of those bundle with the service is active in any active + accommodation. + It is basically the difference between number_users and number_active_users." + - name: number_accommodations data_type: bigint description: From 9e744f41b0480802f5853874db0196cfc701f828 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 12 Feb 2025 15:03:17 +0100 Subject: [PATCH 2/4] Format schema --- models/intermediate/core/schema.yml | 1 + models/reporting/core/schema.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 03225c3..74ee981 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -5270,6 +5270,7 @@ models: and that bundle is active in at least one active accommodation. In other words there is at least one active accommodation that offers this service for this number of users." + - name: number_inactive_users data_type: bigint description: diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index c465f28..6fc88bb 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1608,6 +1608,7 @@ models: and that bundle is active in at least one active accommodation. In other words there is at least one active accommodation that offers this service for this number of users." + - name: number_inactive_users data_type: bigint description: From 375c8679cd5a65a16087fee4dc57312e8c951d4c Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 12 Feb 2025 15:16:41 +0100 Subject: [PATCH 3/4] changed naming --- .../core/int_core__new_dash_services_offered.sql | 6 ++++-- models/intermediate/core/schema.yml | 4 ++-- models/reporting/core/core__new_dash_services_offered.sql | 6 ++++-- models/reporting/core/schema.yml | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/models/intermediate/core/int_core__new_dash_services_offered.sql b/models/intermediate/core/int_core__new_dash_services_offered.sql index 1e36100..cebfd84 100644 --- a/models/intermediate/core/int_core__new_dash_services_offered.sql +++ b/models/intermediate/core/int_core__new_dash_services_offered.sql @@ -56,7 +56,7 @@ with then bs.id_user_host else null end - ) as number_active_users + ) as number_users_with_service_applied_in_accommodation from bundle_services bs left join int_core__accommodation_to_product_bundle apb @@ -157,7 +157,9 @@ select u.service_display_name, u.number_users, u.number_active_users, - u.number_users - u.number_active_users as number_inactive_users, + u.number_users + - u.number_users_with_service_applied_in_accommodation + as number_users_without_service_applied_in_accommodation, a.number_accommodations, a.number_active_accommodations, a.number_inactive_accommodations, diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 74ee981..64ad222 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -5263,7 +5263,7 @@ models: that the service is active or used. Each user can associate any of their bundles with any of their accommodations." - - name: number_active_users + - name: number_users_with_service_applied_in_accommodation data_type: bigint description: "Number of user accounts that have a bundle that considers this service @@ -5271,7 +5271,7 @@ models: In other words there is at least one active accommodation that offers this service for this number of users." - - name: number_inactive_users + - name: number_users_without_service_applied_in_accommodation data_type: bigint description: "Number of user accounts that have a bundle that considers this service diff --git a/models/reporting/core/core__new_dash_services_offered.sql b/models/reporting/core/core__new_dash_services_offered.sql index a24ab8e..9b6de65 100644 --- a/models/reporting/core/core__new_dash_services_offered.sql +++ b/models/reporting/core/core__new_dash_services_offered.sql @@ -5,8 +5,10 @@ with select service_display_name as service_display_name, number_users as number_users, - number_active_users as number_active_users, - number_inactive_users as number_inactive_users, + number_users_with_service_applied_in_accommodation + as number_users_with_service_applied_in_accommodation, + number_users_without_service_applied_in_accommodation + as number_users_without_service_applied_in_accommodation, number_accommodations as number_accommodations, number_active_accommodations as number_active_accommodations, number_inactive_accommodations as number_inactive_accommodations, diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index 6fc88bb..96e49b9 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1601,7 +1601,7 @@ models: that the service is active or used. Each user can associate any of their bundles with any of their accommodations." - - name: number_active_users + - name: number_users_with_service_applied_in_accommodation data_type: bigint description: "Number of user accounts that have a bundle that considers this service @@ -1609,7 +1609,7 @@ models: In other words there is at least one active accommodation that offers this service for this number of users." - - name: number_inactive_users + - name: number_users_without_service_applied_in_accommodation data_type: bigint description: "Number of user accounts that have a bundle that considers this service From c7a8420de3b7681f16eea9d10038675128a7261e Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 12 Feb 2025 15:35:03 +0100 Subject: [PATCH 4/4] fixed schema --- models/intermediate/core/schema.yml | 3 ++- models/reporting/core/schema.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 64ad222..ee050a2 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -5277,7 +5277,8 @@ models: "Number of user accounts that have a bundle that considers this service but none of those bundle with the service is active in any active accommodation. - It is basically the difference between number_users and number_active_users." + It is basically the difference between number_users and + number_users_with_service_applied_in_accommodation." - name: number_accommodations data_type: bigint diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index 96e49b9..949d6d1 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1615,7 +1615,8 @@ models: "Number of user accounts that have a bundle that considers this service but none of those bundle with the service is active in any active accommodation. - It is basically the difference between number_users and number_active_users." + It is basically the difference between number_users and + number_users_with_service_applied_in_accommodation." - name: number_accommodations data_type: bigint