Merged PR 2178: New model for guests satisfaction report

New model for guests satisfaction report, I included columns to check what is the guest paying for that might be helpful for analysis as well

Related work items: #16947
This commit is contained in:
Joaquin Ossa 2024-07-04 10:13:11 +00:00
commit 2efc1d8b65
5 changed files with 278 additions and 3 deletions

View file

@ -0,0 +1,59 @@
with
int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }}
),
stg_core__guest_satisfaction_responses as (
select * from {{ ref("stg_core__guest_satisfaction_responses") }}
),
stg_core__verification_request as (
select * from {{ ref("stg_core__verification_request") }}
),
stg_core__verification as (select * from {{ ref("stg_core__verification") }}),
stg_core__user as (select * from {{ ref("stg_core__user") }}),
-- Create columns for which services did the guest pay for
payment_types as (
select
id_verification_request,
max(
case when verification_payment_type = 'CheckInCover' then 1 else 0 end
)::boolean as has_check_in_cover_payment,
max(
case when verification_payment_type = 'Deposit' then 1 else 0 end
)::boolean as has_deposit_payment,
max(
case when verification_payment_type = 'Waiver' then 1 else 0 end
)::boolean as has_waiver_payment,
max(case when verification_payment_type = 'Fee' then 1 else 0 end)::boolean
as has_fee_payment
from int_core__verification_payments
group by id_verification_request
)
select
gss.id_verification_request,
u.id_user as id_user_guest,
-- not show email if the guest is not contactable
case when gss.is_contactable is true then u.email else '' end as guest_email,
gss.experience_rating,
gss.guest_comments,
coalesce(gss.is_contactable, false) as is_contactable,
gss.created_at_utc,
gss.updated_at_utc,
coalesce(
v.verification_value, 'No Payment Validation Option'
) as selected_payment_option,
u.date_of_birth,
extract(year from age(u.date_of_birth)) as age_of_guest,
coalesce(pt.has_check_in_cover_payment, false) as has_check_in_cover_payment,
coalesce(pt.has_waiver_payment, false) as has_waiver_payment,
coalesce(pt.has_deposit_payment, false) as has_deposit_payment,
coalesce(pt.has_fee_payment, false) as has_fee_payment
from staging.stg_core__guest_satisfaction_responses gss
left join
staging.stg_core__verification_request vr
on vr.id_verification_request = gss.id_verification_request
left join
staging.stg_core__verification v
on v.id_verification = gss.id_verification_request
and v.verification = 'PaymentValidation'
left join staging.stg_core__user u on u.id_user = vr.id_user_guest
left join payment_types pt on gss.id_verification_request = pt.id_verification_request

View file

@ -995,4 +995,83 @@ models:
- name: company_name
data_type: character varying
description: ""
description: ""
- name: int_core__guest_satisfaction_responses
description:
This model contains information on guests satisfaction survey responses,
it contains some basic information on the guests, a rating of their experience
and some comments on it.
It also includes information on the services provided by Superhog that they payed for.
columns:
- name: id_verification_request
data_type: bigint
description: Unique id value for the verification request
tests:
- not_null
- unique
- name: id_user_guest
data_type: character varying
description: Unique id value for the guest
- name: guest_email
data_type: character varying
description: Guest email
- name: experience_rating
data_type: bigint
description:
Guest rating of their experience with Superhog from 1 to 5
- name: guest_comments
data_type: character varying
description:
Guest comments on their experience with Superhog
- name: is_contactable
data_type: boolean
description: |
True if the guest allows to be contacted for more feedback
- name: created_at_utc
data_type: timestamp without time zone
description:
Date and time of response creation
- name: updated_at_utc
data_type: timestamp without time zone
description:
Date and time of last update of response
- name: selected_payment_option
data_type: character varying
description: ""
- name: date_of_birth
data_type: numeric
description: ""
- name: age_of_guest
data_type: numeric
description: ""
- name: has_check_in_cover_payment
data_type: boolean
description: |
True if guest payed for check-in cover
- name: has_waiver_payment
data_type: boolean
description: |
True if guest payed the waiver
- name: has_deposit_payment
data_type: boolean
description: |
True if guest payed the deposit
- name: has_fee_payment
data_type: boolean
description: |
True if guest payed the fee