Addressed comments

This commit is contained in:
Joaquin Ossa 2025-02-14 08:35:51 +01:00
parent a00a4b4e4b
commit ca9188b1ab
5 changed files with 105 additions and 106 deletions

View file

@ -1,3 +1,17 @@
{% set protected_service_status = "'PROTECTED'" %}
{% set rejected_service_status = "'REJECTED'" %}
{% set no_checks_service_status = "'NOCHECKS'" %}
{% set no_flags_service_status = "'NOFLAGS'" %}
{% set paid_service_status = "'PAID'" %}
{% set pending_service_status = "'PENDING'" %}
{% set unknown_service_status = "'-'" %}
{% set partially_protected_service_status = "'PARTIALLY PROTECTED'" %}
{% set not_protected_service_status = "'NOT PROTECTED'" %}
{% set not_paid_service_status = "'NOT PAID'" %}
{% set confirmed_service_status = "'CONFIRMED'" %}
{% set for_review_service_status = "'FORREVIEW'" %}
{% set flagged_service_status = "'FLAGGED'" %}
with
int_core__user_product_bundle_contains_services as (
select * from {{ ref("int_core__user_product_bundle_contains_services") }}
@ -95,104 +109,97 @@ with
count(distinct sd.id_booking) as number_bookings,
count(
distinct case
when
upper(sd.service_status) = {{ var("protected_service_status") }}
when upper(sd.service_status) = {{ protected_service_status }}
then sd.id_booking
else null
end
) as number_protected_bookings,
) as number_bookings_with_service_status_protected,
count(
distinct case
when upper(sd.service_status) = {{ var("rejected_service_status") }}
when upper(sd.service_status) = {{ rejected_service_status }}
then sd.id_booking
else null
end
) as number_rejected_bookings,
) as number_bookings_with_service_status_rejected,
count(
distinct case
when
upper(sd.service_status) = {{ var("no_checks_service_status") }}
when upper(sd.service_status) = {{ no_checks_service_status }}
then sd.id_booking
else null
end
) as number_no_checks_bookings,
) as number_bookings_with_service_status_no_checks,
count(
distinct case
when upper(sd.service_status) = {{ var("no_flags_service_status") }}
when upper(sd.service_status) = {{ no_flags_service_status }}
then sd.id_booking
else null
end
) as number_no_flags_bookings,
) as number_bookings_with_service_status_no_flags,
count(
distinct case
when upper(sd.service_status) = {{ var("paid_service_status") }}
when upper(sd.service_status) = {{ paid_service_status }}
then sd.id_booking
else null
end
) as number_paid_bookings,
) as number_bookings_with_service_status_paid,
count(
distinct case
when upper(sd.service_status) = {{ var("pending_service_status") }}
when upper(sd.service_status) = {{ paid_service_status }}
then sd.id_booking
else null
end
) as number_pending_bookings,
) as number_bookings_with_service_status_pending,
count(
distinct case
when upper(sd.service_status) = {{ var("unknown_service_status") }}
when upper(sd.service_status) = {{ unknown_service_status }}
then sd.id_booking
else null
end
) as number_unknown_status_bookings,
) as number_bookings_with_service_status_unknown_status,
count(
distinct case
when
upper(sd.service_status)
= {{ var("partially_protected_service_status") }}
= {{ partially_protected_service_status }}
then sd.id_booking
else null
end
) as number_partially_protected_bookings,
) as number_bookings_with_service_status_partially_protected,
count(
distinct case
when
upper(sd.service_status)
= {{ var("not_protected_service_status") }}
when upper(sd.service_status) = {{ not_protected_service_status }}
then sd.id_booking
else null
end
) as number_not_protected_bookings,
) as number_bookings_with_service_status_not_protected,
count(
distinct case
when upper(sd.service_status) = {{ var("not_paid_service_status") }}
when upper(sd.service_status) = {{ not_paid_service_status }}
then sd.id_booking
else null
end
) as number_not_paid_bookings,
) as number_bookings_with_service_status_not_paid,
count(
distinct case
when
upper(sd.service_status) = {{ var("confirmed_service_status") }}
when upper(sd.service_status) = {{ confirmed_service_status }}
then sd.id_booking
else null
end
) as number_confirmed_bookings,
) as number_bookings_with_service_status_confirmed,
count(
distinct case
when
upper(sd.service_status)
= {{ var("for_review_service_status") }}
when upper(sd.service_status) = {{ for_review_service_status }}
then sd.id_booking
else null
end
) as number_for_review_bookings,
) as number_bookings_with_service_status_for_review,
count(
distinct case
when upper(sd.service_status) = {{ var("flagged_service_status") }}
when upper(sd.service_status) = {{ flagged_service_status }}
then sd.id_booking
else null
end
) as number_flagged_bookings
) as number_bookings_with_service_status_flagged
from int_core__booking_service_detail sd
group by 1
)
@ -207,19 +214,19 @@ select
a.number_active_accommodations,
a.number_inactive_accommodations,
b.number_bookings,
b.number_protected_bookings,
b.number_rejected_bookings,
b.number_no_checks_bookings,
b.number_no_flags_bookings,
b.number_paid_bookings,
b.number_pending_bookings,
b.number_unknown_status_bookings,
b.number_partially_protected_bookings,
b.number_not_protected_bookings,
b.number_not_paid_bookings,
b.number_confirmed_bookings,
b.number_for_review_bookings,
b.number_flagged_bookings
b.number_bookings_with_service_status_protected,
b.number_bookings_with_service_status_rejected,
b.number_bookings_with_service_status_no_checks,
b.number_bookings_with_service_status_no_flags,
b.number_bookings_with_service_status_paid,
b.number_bookings_with_service_status_pending,
b.number_bookings_with_service_status_unknown_status,
b.number_bookings_with_service_status_partially_protected,
b.number_bookings_with_service_status_not_protected,
b.number_bookings_with_service_status_not_paid,
b.number_bookings_with_service_status_confirmed,
b.number_bookings_with_service_status_for_review,
b.number_bookings_with_service_status_flagged
from users u
left join accommodations a on u.service_display_name = a.service_display_name
full outer join bookings b on u.service_display_name = b.service_display_name

View file

@ -5289,55 +5289,55 @@ models:
data_type: bigint
description: "Number of bookings that have a bundle that considers this service."
- name: number_protected_bookings
- name: number_bookings_with_service_status_protected
data_type: bigint
description: "Number of bookings with status PROTECTED for this service."
- name: number_rejected_bookings
- name: number_bookings_with_service_status_rejected
data_type: bigint
description: "Number of bookings with status REJECTED for this service."
- name: number_no_checks_bookings
- name: number_bookings_with_service_status_no_checks
data_type: bigint
description: "Number of bookings with status NO CHECKS for this service."
- name: number_no_flags_bookings
- name: number_bookings_with_service_status_no_flags
data_type: bigint
description: "Number of bookings with status NO FLAGS for this service."
- name: number_paid_bookings
- name: number_bookings_with_service_status_paid
data_type: bigint
description: "Number of bookings with status PAID for this service."
- name: number_pending_bookings
- name: number_bookings_with_service_status_pending
data_type: bigint
description: "Number of bookings with status PENDING for this service."
- name: number_unknown_status_bookings
- name: number_bookings_with_service_status_unknown
data_type: bigint
description: "Number of bookings with unknown status for this service."
- name: number_partially_protected_bookings
- name: number_bookings_with_service_status_partially_protected
data_type: bigint
description: "Number of bookings with status PARTIALLY PROTECTED for this service."
- name: number_not_protected_bookings
- name: number_bookings_with_service_status_not_protected
data_type: bigint
description: "Number of bookings with status NOT PROTECTED for this service."
- name: number_not_paid_bookings
- name: number_bookings_with_service_status_not_paid
data_type: bigint
description: "Number of bookings with status NOT PAID for this service."
- name: number_confirmed_bookings
- name: number_bookings_with_service_status_confirmed
data_type: bigint
description: "Number of bookings with status CONFIRMED for this service."
- name: number_for_review_bookings
- name: number_bookings_with_service_status_for_review
data_type: bigint
description: "Number of bookings with status FOR REVIEW for this service."
- name: number_flagged_bookings
- name: number_bookings_with_service_status_flagged
data_type: bigint
description: "Number of bookings with status FLAGGED for this service."