Addressed comments
This commit is contained in:
parent
1c6f23f269
commit
25a89208c4
7 changed files with 148 additions and 36 deletions
|
|
@ -69,6 +69,18 @@ vars:
|
|||
# States should be strings in capital letters. Models need to force an upper()
|
||||
"cancelled_booking_state": "'CANCELLED'"
|
||||
|
||||
# Booking state variables
|
||||
# States should be strings in capital letters. Models need to force an upper()
|
||||
"approved_booking_state": "'APPROVED'"
|
||||
|
||||
# Booking state variables
|
||||
# States should be strings in capital letters. Models need to force an upper()
|
||||
"flagged_booking_state": "'FLAGGED'"
|
||||
|
||||
# Payment state variables
|
||||
# States should be strings in capital letters. Models need to force an upper()
|
||||
"paid_payment_state": "'PAID'"
|
||||
|
||||
# Protection service state variables
|
||||
# States should be strings in capital letters. Models need to force an upper()
|
||||
"default_service": "'BASIC SCREENING'"
|
||||
|
|
|
|||
|
|
@ -9,36 +9,38 @@ with
|
|||
int_core__accommodation_to_product_bundle as (
|
||||
select * from {{ ref("int_core__accommodation_to_product_bundle") }}
|
||||
),
|
||||
int_core__new_dash_users as (select * from {{ ref("int_core__new_dash_users") }}),
|
||||
int_core__accommodation as (select * from {{ ref("int_core__accommodation") }}),
|
||||
int_core__booking_to_product_bundle as (
|
||||
select * from {{ ref("int_core__booking_to_product_bundle") }}
|
||||
),
|
||||
int_core__bookings as (select * from {{ ref("int_core__bookings") }}),
|
||||
bundle_services as (
|
||||
select id_user_product_bundle, id_user_host, product_service_name
|
||||
select id_user_product_bundle, id_user_host, product_service_display_name
|
||||
from int_core__user_product_bundle_contains_services
|
||||
-- Union of all product services with all protection plan services.
|
||||
-- This is because there are basically two types of services: product services
|
||||
-- and protection plan services and they are stored in different tables.
|
||||
union all
|
||||
select
|
||||
id_user_product_bundle,
|
||||
id_user_host,
|
||||
coalesce(
|
||||
replace(protection_display_name, ' ', ''), 'BASICSCREENING'
|
||||
) as product_service_name
|
||||
protection_display_name, {{ var("default_service") }}
|
||||
) as product_service_display_name
|
||||
from int_core__user_product_bundle
|
||||
),
|
||||
users as (
|
||||
select distinct
|
||||
(bs.product_service_name), count(distinct bs.id_user_host) as number_users
|
||||
(bs.product_service_display_name),
|
||||
count(distinct bs.id_user_host) as number_users
|
||||
from bundle_services bs
|
||||
inner join
|
||||
int_core__user_host uh
|
||||
on bs.id_user_host = uh.id_user_host
|
||||
and uh.is_test_account is false
|
||||
inner join int_core__user_host uh on bs.id_user_host = uh.id_user_host
|
||||
group by 1
|
||||
),
|
||||
accommodations as (
|
||||
select distinct
|
||||
(bs.product_service_name),
|
||||
(bs.product_service_display_name),
|
||||
count(distinct apb.id_accommodation) as number_accommodations,
|
||||
count(
|
||||
distinct case when a.is_active then apb.id_accommodation else null end
|
||||
|
|
@ -56,29 +58,30 @@ with
|
|||
apb.original_ends_at_utc, '2050-12-31'
|
||||
)
|
||||
left join int_core__accommodation a on apb.id_accommodation = a.id_accommodation
|
||||
inner join int_core__new_dash_users ndu on bs.id_user_host = ndu.id_user_host
|
||||
group by 1
|
||||
),
|
||||
bookings as (
|
||||
select distinct
|
||||
(bs.product_service_name),
|
||||
(bs.product_service_display_name),
|
||||
count(distinct bpb.id_booking) as number_bookings,
|
||||
count(
|
||||
distinct case
|
||||
when upper(b.booking_state) = 'APPROVED'
|
||||
when upper(b.booking_state) = {{ var("approved_booking_state") }}
|
||||
then bpb.id_booking
|
||||
else null
|
||||
end
|
||||
) as number_approved_bookings,
|
||||
count(
|
||||
distinct case
|
||||
when upper(b.booking_state) = 'CANCELLED'
|
||||
when upper(b.booking_state) = {{ var("cancelled_booking_state") }}
|
||||
then bpb.id_booking
|
||||
else null
|
||||
end
|
||||
) as number_cancelled_bookings,
|
||||
count(
|
||||
distinct case
|
||||
when upper(b.booking_state) = 'FLAGGED'
|
||||
when upper(b.booking_state) = {{ var("flagged_booking_state") }}
|
||||
then bpb.id_booking
|
||||
else null
|
||||
end
|
||||
|
|
@ -91,10 +94,11 @@ with
|
|||
int_core__bookings b
|
||||
on b.id_booking = bpb.id_booking
|
||||
and b.is_duplicate_booking is false
|
||||
inner join int_core__new_dash_users ndu on bs.id_user_host = ndu.id_user_host
|
||||
group by 1
|
||||
)
|
||||
select
|
||||
u.product_service_name,
|
||||
u.product_service_display_name,
|
||||
u.number_users,
|
||||
a.number_accommodations,
|
||||
a.number_active_accommodations,
|
||||
|
|
@ -104,5 +108,6 @@ select
|
|||
b.number_cancelled_bookings,
|
||||
b.number_flagged_bookings
|
||||
from users u
|
||||
left join accommodations a on u.product_service_name = a.product_service_name
|
||||
left join bookings b on u.product_service_name = b.product_service_name
|
||||
left join
|
||||
accommodations a on u.product_service_display_name = a.product_service_display_name
|
||||
left join bookings b on u.product_service_display_name = b.product_service_display_name
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
{% set product_bundles_without_paid_service = "('BASIC SCREENING')" %}
|
||||
with
|
||||
int_core__user_product_bundle as (
|
||||
select * from {{ ref("int_core__user_product_bundle") }}
|
||||
|
|
@ -43,7 +42,7 @@ with
|
|||
distinct case
|
||||
when
|
||||
atpb.user_product_bundle_name
|
||||
not in {{ product_bundles_without_paid_service }}
|
||||
not in ({{ var("default_service") }})
|
||||
then atpb.id_accommodation
|
||||
else null
|
||||
end
|
||||
|
|
@ -52,7 +51,7 @@ with
|
|||
distinct case
|
||||
when
|
||||
atpb.user_product_bundle_name
|
||||
not in {{ product_bundles_without_paid_service }}
|
||||
not in ({{ var("default_service") }})
|
||||
and atpb.has_no_end_date = true
|
||||
then atpb.id_accommodation
|
||||
else null
|
||||
|
|
@ -72,7 +71,7 @@ with
|
|||
distinct case
|
||||
when
|
||||
btpb.user_product_bundle_name
|
||||
not in {{ product_bundles_without_paid_service }}
|
||||
not in ({{ var("default_service") }})
|
||||
then btpb.id_booking
|
||||
else null
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ select
|
|||
pb.id_product_bundle,
|
||||
ps.id_product_service,
|
||||
pb.product_bundle_name,
|
||||
ps.product_service_name
|
||||
ps.product_service_name,
|
||||
ps.product_service_display_name
|
||||
from stg_core__user_product_bundle pb
|
||||
cross join stg_core__product_service ps
|
||||
where
|
||||
|
|
|
|||
|
|
@ -3023,6 +3023,13 @@ models:
|
|||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: product_service_display_name
|
||||
data_type: string
|
||||
description: |
|
||||
The display name of the product service.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: int_core__product_service_to_price
|
||||
description: |
|
||||
This model provides the information related to the prices of the different
|
||||
|
|
@ -5166,30 +5173,30 @@ models:
|
|||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose CheckIn Cover."
|
||||
|
||||
- name: int_core__new_dash_services_usage
|
||||
description: "This model contains the usage of the services in New Dash.
|
||||
This usage is displayed by different levels, such as the number of users,
|
||||
- name: int_core__new_dash_services_offered
|
||||
description: "This model contains the the services offered in New Dash.
|
||||
This offers are displayed by different levels, such as the number of users,
|
||||
accommodations and bookings."
|
||||
|
||||
columns:
|
||||
- name: product_service_name
|
||||
- name: product_service_display_name
|
||||
data_type: text
|
||||
description: "The name of the product service."
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "BASICSCREENING"
|
||||
- "SCREENINGPLUS"
|
||||
- "IDVERIFICATION"
|
||||
- "SEXOFFENDERSCHECK"
|
||||
- "BASICDAMAGEDEPOSIT"
|
||||
- "BASICWAIVER"
|
||||
- "WAIVERPLUS"
|
||||
- "WAIVERPRO"
|
||||
- "BASICPROTECTION"
|
||||
- "PROTECTIONPLUS"
|
||||
- "PROTECTIONPRO"
|
||||
- "BASIC SCREENING"
|
||||
- "SCREENING PLUS"
|
||||
- "ID VERIFICATION"
|
||||
- "SEX OFFENDERS CHECK"
|
||||
- "BASIC DAMAGE DEPOSIT"
|
||||
- "BASIC WAIVER"
|
||||
- "WAIVER PLUS"
|
||||
- "WAIVER PRO"
|
||||
- "BASIC PROTECTION"
|
||||
- "PROTECTION PLUS"
|
||||
- "PROTECTION PRO"
|
||||
|
||||
- name: number_users
|
||||
data_type: bigint
|
||||
|
|
|
|||
15
models/reporting/core/core__new_dash_services_offered.sql
Normal file
15
models/reporting/core/core__new_dash_services_offered.sql
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
with
|
||||
int_core__new_dash_services_offered as (
|
||||
select * from {{ ref("int_core__new_dash_services_offered") }}
|
||||
)
|
||||
select
|
||||
product_service_display_name as product_service_display_name,
|
||||
number_users as number_users,
|
||||
number_accommodations as number_accommodations,
|
||||
number_active_accommodations as number_active_accommodations,
|
||||
number_inactive_accommodations as number_inactive_accommodations,
|
||||
number_bookings as number_bookings,
|
||||
number_approved_bookings as number_approved_bookings,
|
||||
number_cancelled_bookings as number_cancelled_bookings,
|
||||
number_flagged_bookings as number_flagged_bookings
|
||||
from int_core__new_dash_services_offered
|
||||
|
|
@ -1567,3 +1567,76 @@ models:
|
|||
- name: chose_checkin_cover
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose CheckIn Cover."
|
||||
|
||||
- name: core__new_dash_services_offered
|
||||
description: "This model contains the the services offered in New Dash.
|
||||
This offers are displayed by different levels, such as the number of users,
|
||||
accommodations and bookings."
|
||||
|
||||
columns:
|
||||
- name: product_service_display_name
|
||||
data_type: text
|
||||
description: "The name of the product service."
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "BASIC SCREENING"
|
||||
- "SCREENING PLUS"
|
||||
- "ID VERIFICATION"
|
||||
- "SEX OFFENDERS CHECK"
|
||||
- "BASIC DAMAGE DEPOSIT"
|
||||
- "BASIC WAIVER"
|
||||
- "WAIVER PLUS"
|
||||
- "WAIVER PRO"
|
||||
- "BASIC PROTECTION"
|
||||
- "PROTECTION PLUS"
|
||||
- "PROTECTION PRO"
|
||||
|
||||
- name: number_users
|
||||
data_type: bigint
|
||||
description:
|
||||
"Number of user accounts that have a bundle that considers this service.
|
||||
The fact that a user has a bundle with the service included does not mean
|
||||
that the service is active or used. Each user can associate any of their
|
||||
bundles with any of their accommodations."
|
||||
|
||||
- name: number_accommodations
|
||||
data_type: bigint
|
||||
description:
|
||||
"Number of accommodations or listings that have a bundle that considers
|
||||
this service."
|
||||
|
||||
- name: number_active_accommodations
|
||||
data_type: bigint
|
||||
description:
|
||||
"Number of accommodations or listings that have a bundle that considers
|
||||
this service and are active."
|
||||
|
||||
- name: number_inactive_accommodations
|
||||
data_type: bigint
|
||||
description:
|
||||
"Number of accommodations or listings that have a bundle that considers
|
||||
this service and are inactive."
|
||||
|
||||
- name: number_bookings
|
||||
data_type: bigint
|
||||
description: "Number of bookings that have a bundle that considers this service."
|
||||
|
||||
- name: number_approved_bookings
|
||||
data_type: bigint
|
||||
description:
|
||||
"Number of bookings that have a bundle that considers this service and
|
||||
are approved."
|
||||
|
||||
- name: number_cancelled_bookings
|
||||
data_type: bigint
|
||||
description:
|
||||
"Number of bookings that have a bundle that considers this service and
|
||||
are cancelled."
|
||||
|
||||
- name: number_flagged_bookings
|
||||
data_type: bigint
|
||||
description:
|
||||
"Number of bookings that have a bundle that considers this service and
|
||||
are flagged."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue