daily model for guest products
This commit is contained in:
parent
2f80642f6c
commit
98ba74481a
4 changed files with 333 additions and 1 deletions
|
|
@ -0,0 +1,8 @@
|
|||
with
|
||||
unique_dimensions as (
|
||||
select distinct has_payment, has_id_check
|
||||
from {{ ref("int_kpis__metric_daily_check_in_attributed_guest_journeys") }}
|
||||
)
|
||||
select d.date_day, ud.has_payment, ud.has_id_check
|
||||
from {{ ref("int_dates") }} as d
|
||||
cross join unique_dimensions as ud
|
||||
|
|
@ -9,6 +9,7 @@ select
|
|||
-- Unique Key --
|
||||
icvp.payment_paid_date_utc as date,
|
||||
coalesce(icuh.id_deal, 'UNSET') as id_deal,
|
||||
'With Payment' as has_payment,
|
||||
case
|
||||
when icv.id_verification is null then 'W/O Id Check' else 'With Id Check'
|
||||
end as has_id_check,
|
||||
|
|
@ -76,4 +77,4 @@ left join
|
|||
on icuh.id_deal = icmas.id_deal
|
||||
and icvp.payment_paid_date_utc = icmas.date
|
||||
where upper(icvp.payment_status) = {{ var("paid_payment_state") }}
|
||||
group by 1, 2, 3, 4, 5
|
||||
group by 1, 2, 3, 4, 5, 6
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
with
|
||||
guest_kpis as (
|
||||
select
|
||||
dd.date_day as date,
|
||||
dd.has_payment,
|
||||
dd.has_id_check,
|
||||
sum(
|
||||
gj.created_guest_journeys_not_cancelled
|
||||
) as created_guest_journeys_not_cancelled,
|
||||
sum(
|
||||
gj.started_guest_journeys_not_cancelled
|
||||
) as started_guest_journeys_not_cancelled,
|
||||
sum(
|
||||
gj.completed_guest_journeys_not_cancelled
|
||||
) as completed_guest_journeys_not_cancelled,
|
||||
sum(gj.created_guest_journeys) as created_guest_journeys,
|
||||
sum(gj.started_guest_journeys) as started_guest_journeys,
|
||||
sum(gj.completed_guest_journeys) as completed_guest_journeys,
|
||||
sum(gj.count_csat_score) as total_csat_score_count,
|
||||
case
|
||||
when sum(gj.count_csat_score) > 0
|
||||
then
|
||||
sum(gj.average_csat_score * gj.count_csat_score)
|
||||
/ sum(gj.count_csat_score)
|
||||
else null
|
||||
end as average_csat_score,
|
||||
sum(gp.deposit_fees_in_gbp) as deposit_fees_in_gbp,
|
||||
sum(gp.waiver_payments_in_gbp) as waiver_payments_in_gbp,
|
||||
sum(gp.checkin_cover_fees_in_gbp) as checkin_cover_fees_in_gbp,
|
||||
sum(gp.total_guest_payments_in_gbp) as total_guest_payments_in_gbp
|
||||
from {{ ref("int_kpis__dimension_daily_guest_product") }} dd
|
||||
left join
|
||||
{{ ref("int_kpis__metric_daily_check_in_attributed_guest_journeys") }} gj
|
||||
on gj.date = dd.date_day
|
||||
left join
|
||||
{{ ref("int_kpis__metric_daily_guest_payments") }} gp
|
||||
on gj.date = gp.date
|
||||
and gj.id_deal = gp.id_deal
|
||||
and gj.has_payment = gp.has_payment
|
||||
and gj.has_id_check = gp.has_id_check
|
||||
and gj.main_billing_country_iso_3_per_deal
|
||||
= gp.main_billing_country_iso_3_per_deal
|
||||
and gj.active_accommodations_per_deal_segmentation
|
||||
= gp.active_accommodations_per_deal_segmentation
|
||||
where dd.date_day = '2017-02-28'
|
||||
group by dd.date_day, dd.has_payment, dd.has_id_check
|
||||
)
|
||||
|
||||
select
|
||||
gk.date,
|
||||
gk.has_payment,
|
||||
gk.has_id_check,
|
||||
gk.created_guest_journeys_not_cancelled,
|
||||
gk.started_guest_journeys_not_cancelled,
|
||||
gk.completed_guest_journeys_not_cancelled,
|
||||
gk.created_guest_journeys,
|
||||
gk.started_guest_journeys,
|
||||
gk.completed_guest_journeys,
|
||||
gk.total_csat_score_count,
|
||||
gk.average_csat_score,
|
||||
gk.deposit_fees_in_gbp,
|
||||
gk.waiver_payments_in_gbp,
|
||||
gk.checkin_cover_fees_in_gbp,
|
||||
gk.total_guest_payments_in_gbp,
|
||||
gk_py.created_guest_journeys_not_cancelled
|
||||
as created_guest_journeys_not_cancelled_py,
|
||||
gk_py.started_guest_journeys_not_cancelled
|
||||
as started_guest_journeys_not_cancelled_py,
|
||||
gk_py.completed_guest_journeys_not_cancelled
|
||||
as completed_guest_journeys_not_cancelled_py,
|
||||
gk_py.created_guest_journeys as created_guest_journeys_py,
|
||||
gk_py.started_guest_journeys as started_guest_journeys_py,
|
||||
gk_py.completed_guest_journeys as completed_guest_journeys_py,
|
||||
gk_py.total_csat_score_count as total_csat_score_count_py,
|
||||
gk_py.average_csat_score as average_csat_score_py,
|
||||
gk_py.deposit_fees_in_gbp as deposit_fees_in_gbp_py,
|
||||
gk_py.waiver_payments_in_gbp as waiver_payments_in_gbp_py,
|
||||
gk_py.checkin_cover_fees_in_gbp as checkin_cover_fees_in_gbp_py,
|
||||
gk_py.total_guest_payments_in_gbp as total_guest_payments_in_gbp_py
|
||||
from guest_kpis gk
|
||||
left join
|
||||
guest_kpis gk_py
|
||||
on gk.date = gk_py.date + interval '1 year'
|
||||
and gk.has_payment = gk_py.has_payment
|
||||
and gk.has_id_check = gk_py.has_id_check
|
||||
|
|
@ -1957,6 +1957,16 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: has_payment
|
||||
data_type: string
|
||||
description: Has there been any guest payments on the guest journey.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- W/O Payment
|
||||
- With Payment
|
||||
|
||||
- name: has_id_check
|
||||
data_type: string
|
||||
description: Does the verification in the guest journey
|
||||
|
|
@ -5781,3 +5791,231 @@ models:
|
|||
data_type: bigint
|
||||
description: |
|
||||
Count of listings booked within the past 12 months for a given date, dimension and value.
|
||||
|
||||
- name: int_kpis__dimension_daily_guest_product
|
||||
description: |
|
||||
This model computes a cross join of dates with all combinations of
|
||||
guest products dimensions.
|
||||
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date_day
|
||||
- has_payment
|
||||
- has_id_check
|
||||
columns:
|
||||
- name: date_day
|
||||
data_type: date
|
||||
description: "Date of when Guest Journeys have been completed."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: has_payment
|
||||
data_type: string
|
||||
description: Has there been any guest payments on the guest journey.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- W/O Payment
|
||||
- With Payment
|
||||
|
||||
- name: has_id_check
|
||||
data_type: string
|
||||
description: Does the verification in the guest journey
|
||||
includes Government Id Check for the bookings.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- W/O Id Check
|
||||
- With Id Check
|
||||
|
||||
- name: int_kpis__product_guest_daily_metrics
|
||||
description: |
|
||||
This model computes the Daily Guest Metrics at the deepest granularity.
|
||||
Here all metrics are attributed to the Check-in Date of the associated
|
||||
booking, except for payments which are attributed to payment date.
|
||||
|
||||
The unique key corresponds to the deepest granularity of the model,
|
||||
in this case:
|
||||
- date,
|
||||
- id_deal,
|
||||
- has_id_check.
|
||||
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- has_payment
|
||||
- has_id_check
|
||||
columns:
|
||||
- name: date
|
||||
data_type: date
|
||||
description: "Date of when Guest Journeys have been completed."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: has_payment
|
||||
data_type: string
|
||||
description: Has there been any guest payments on the guest journey.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- W/O Payment
|
||||
- With Payment
|
||||
|
||||
- name: has_id_check
|
||||
data_type: string
|
||||
description: Does the verification in the guest journey
|
||||
includes Government Id Check for the bookings.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- W/O Id Check
|
||||
- With Id Check
|
||||
|
||||
- name: created_guest_journeys_not_cancelled
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys created, excluding cancelled bookings,
|
||||
in a given date and per specified dimension.
|
||||
|
||||
- name: started_guest_journeys_not_cancelled
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys started, excluding cancelled bookings,
|
||||
in a given date and per specified dimension.
|
||||
|
||||
- name: completed_guest_journeys_not_cancelled
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys completed, excluding cancelled bookings,
|
||||
in a given date and per specified dimension.
|
||||
|
||||
- name: created_guest_journeys
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys created in a given date and
|
||||
per specified dimension.
|
||||
|
||||
- name: started_guest_journeys
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys started in a given date and
|
||||
per specified dimension.
|
||||
|
||||
- name: completed_guest_journeys
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys completed in a given date and
|
||||
per specified dimension.
|
||||
|
||||
- name: count_csat_score
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys with CSAT (customer satisfaction score)
|
||||
in a given date and per specified dimension.
|
||||
|
||||
- name: average_csat_score
|
||||
data_type: bigint
|
||||
description: |
|
||||
Average daily CSAT score in a given date and per specified dimension.
|
||||
|
||||
- name: deposit_fees_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Sum of deposit fees paid by guests, without taxes, in GBP
|
||||
in a given date and per specified dimension.
|
||||
|
||||
- name: waiver_payments_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Sum of waiver payments paid by guests, without taxes, in GBP
|
||||
in a given date and per specified dimension.
|
||||
|
||||
- name: checkin_cover_fees_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Sum of checkin cover fees paid by guests, without taxes, in GBP
|
||||
in a given date and per specified dimension.
|
||||
|
||||
- name: total_guest_payments_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Sum of total payments paid by guests, without taxes, in GBP
|
||||
in a given date and per specified dimension.
|
||||
|
||||
- name: created_guest_journeys_not_cancelled_py
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys created (excluding canceled bookings)
|
||||
on the same date in the previous year, segmented by the specified dimension.
|
||||
|
||||
- name: started_guest_journeys_not_cancelled_py
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys started (excluding canceled bookings)
|
||||
on the same date in the previous year, segmented by the specified dimension.
|
||||
|
||||
- name: completed_guest_journeys_not_cancelled_py
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys completed (excluding canceled bookings)
|
||||
on the same date in the previous year, segmented by the specified dimension.
|
||||
|
||||
- name: created_guest_journeys_py
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys created on the same date in the previous year,
|
||||
segmented by the specified dimension.
|
||||
|
||||
- name: started_guest_journeys_py
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys started on the same date in the previous year,
|
||||
segmented by the specified dimension.
|
||||
|
||||
- name: completed_guest_journeys_py
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys completed on the same date in the previous year,
|
||||
segmented by the specified dimension.
|
||||
|
||||
- name: count_csat_score_py
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily guest journeys with CSAT (customer satisfaction score)
|
||||
on the same date in the previous year, segmented by the specified dimension.
|
||||
|
||||
- name: average_csat_score_py
|
||||
data_type: bigint
|
||||
description: |
|
||||
Average daily CSAT score on the same date in the previous year,
|
||||
segmented by the specified dimension.
|
||||
|
||||
- name: deposit_fees_in_gbp_py
|
||||
data_type: decimal
|
||||
description: |
|
||||
Sum of deposit fees paid by guests, excluding taxes, in GBP
|
||||
on the same date in the previous year, segmented by the specified dimension.
|
||||
|
||||
- name: waiver_payments_in_gbp_py
|
||||
data_type: decimal
|
||||
description: |
|
||||
Sum of waiver payments paid by guests, excluding taxes, in GBP
|
||||
on the same date in the previous year, segmented by the specified dimension.
|
||||
|
||||
- name: checkin_cover_fees_in_gbp_py
|
||||
data_type: decimal
|
||||
description: |
|
||||
Sum of check-in cover fees paid by guests, excluding taxes, in GBP
|
||||
on the same date in the previous year, segmented by the specified dimension.
|
||||
|
||||
- name: total_guest_payments_in_gbp_py
|
||||
data_type: decimal
|
||||
description: |
|
||||
Sum of total payments paid by guests, excluding taxes, in GBP
|
||||
on the same date in the previous year, segmented by the specified dimension.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue