Merged PR 5366: Adds Incident data to Booking Summary
# Description This PR moves the categorisation of Bookings with Incidents from the flagging specific model to Booking Summary, effectively keeping this at Booking ID level. This also handles the direct dependency with the flagging categorisation model. I also improved the documentation and test coverage on the Booking Summary as it's becoming more and more central to many areas. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #30676
This commit is contained in:
parent
92b144d78e
commit
affeac612a
3 changed files with 453 additions and 258 deletions
|
|
@ -3406,20 +3406,42 @@ models:
|
|||
|
||||
- name: int_booking_summary
|
||||
description: |
|
||||
This model contains enriched information aggregated at Booking level regarding
|
||||
the services that are applied within a Booking.
|
||||
Specifically, contains both Booking and Services attributes (aggregated), as well
|
||||
as the total price in GBP at this specific moment in time. In other words,
|
||||
it's the snapshot of the current status of the Booking.
|
||||
It's a subset of all bookings since it only applies to bookings that come from
|
||||
hosts that have been migrated into the New Dash or New Pricing.
|
||||
This model contains enriched information aggregated at Booking level under New Pricing
|
||||
regarding the services that are applied within a Booking.
|
||||
|
||||
If you want to retrieve only New Dash Bookings, you will need to apply the following
|
||||
filters:
|
||||
Specifically, contains both Booking and Services attributes (aggregated), as well
|
||||
as the total price in GBP at this specific moment in time. This model also contains
|
||||
information on the potential Resolution Incidents linked to a Booking, as long as
|
||||
these appear in the Resolution Center.
|
||||
|
||||
In other words, it's the snapshot of the current status of the Booking.
|
||||
|
||||
Be aware that this model only contains a subset of all bookings. It only applies to
|
||||
1) Platform (Dashboard) bookings, so APIs are excluded and,
|
||||
2) that come from hosts that have been migrated into the New Pricing.
|
||||
|
||||
In essence, that the Booking is linked to a User Product Bundle.
|
||||
|
||||
It's likely that you are just interested in retrieveing only New Dash Bookings. For this,
|
||||
you will need to apply the following filters:
|
||||
- is_user_in_new_dash = True
|
||||
- is_missing_id_deal = False
|
||||
|
||||
For Data-Driven Flagging purposes, you're likely going to be interested in applying all or
|
||||
part of the following filters:
|
||||
1. Bookings from New Dash users with Id Deal
|
||||
- is_user_in_new_dash = True
|
||||
- is_missing_id_deal = False
|
||||
2. Protected Bookings with a Protection or a Deposit Management service
|
||||
- has_protection_service_business_type or has_deposit_management_service_business_type
|
||||
3. Bookings with flagging categorisation (this excludes Cancelled/Incomplete/Rejected bookings)
|
||||
- is_booking_flagged_as_risk is not null
|
||||
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
|
||||
column_A: booking_completed_date_utc
|
||||
column_B: booking_check_out_at_utc
|
||||
or_equal: False
|
||||
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
|
||||
column_A: booking_check_out_at_utc
|
||||
column_B: booking_check_in_at_utc
|
||||
|
|
@ -3490,6 +3512,15 @@ models:
|
|||
The current status of the booking. Cannot be null.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- APPROVED
|
||||
- NOFLAGS
|
||||
- NOTAPPROVED
|
||||
- FLAGGED
|
||||
- CANCELLED
|
||||
- INCOMPLETEINFORMATION
|
||||
- REJECTED
|
||||
|
||||
- name: program_name
|
||||
data_type: string
|
||||
|
|
@ -3562,6 +3593,16 @@ models:
|
|||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_completed_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of the Booking completion. This is assumed to be 14 days
|
||||
after Check-out date, and it is used to determine the limit in
|
||||
which the Host can raise a Resolution Incident regarding this
|
||||
booking.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_number_of_nights
|
||||
data_type: integer
|
||||
description: |
|
||||
|
|
@ -3661,24 +3702,51 @@ models:
|
|||
data_type: integer
|
||||
description: |
|
||||
Total number of Services applied to this Booking.
|
||||
data_tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
|
||||
- name: number_of_applied_paid_services
|
||||
data_type: integer
|
||||
description: |
|
||||
Total number of Services that require a monetary
|
||||
income to Superhog applied to this Booking.
|
||||
data_tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: number_of_applied_upgraded_services
|
||||
strictly: false
|
||||
|
||||
- name: number_of_applied_upgraded_services
|
||||
data_type: integer
|
||||
description: |
|
||||
Total number of Services different from Basic Screening
|
||||
applied to this Booking.
|
||||
data_tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: number_of_applied_services
|
||||
strictly: false
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
where: (has_protection_service_business_type = True or has_deposit_management_service_business_type = True)
|
||||
|
||||
- name: number_of_applied_billable_services
|
||||
data_type: integer
|
||||
description: |
|
||||
Total number of Services that require an invoice to the Host
|
||||
to the Host, that are applied to this Booking.
|
||||
that are applied to this Booking.
|
||||
data_tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: number_of_applied_upgraded_services
|
||||
strictly: false
|
||||
|
||||
- name: is_booking_chargeable
|
||||
data_type: boolean
|
||||
|
|
@ -3784,3 +3852,97 @@ models:
|
|||
description: |
|
||||
Flag to identify if the Host for this booking is missing
|
||||
the currency code or not.
|
||||
|
||||
- name: is_booking_past_completion_date
|
||||
data_type: boolean
|
||||
description: |
|
||||
Flag to identify if the booking is past the completion date or not.
|
||||
This is used to determine if the booking can be considered as completed
|
||||
or not, and therefore, if it can be used for further risk-assessment
|
||||
analysis.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: is_booking_flagged_as_risk
|
||||
data_type: boolean
|
||||
description: |
|
||||
Flag to identify if the booking has been flagged as risk or not.
|
||||
This is based on the Booking Status and will return:
|
||||
- True if the status is "NOTAPPROVED" or "FLAGGED"
|
||||
- False if the status is "APPROVED" or "NOFLAGS"
|
||||
- Null otherwise, such as "CANCELLED", "INCOMPLETEINFORMATION" or "REJECTED"
|
||||
data_tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
- true
|
||||
where: (upper(booking_status) in ('NOTAPPROVED', 'FLAGGED'))
|
||||
|
||||
- accepted_values:
|
||||
values:
|
||||
- false
|
||||
where: (upper(booking_status) in ('APPROVED', 'NOFLAGS'))
|
||||
|
||||
- dbt_expectations.expect_column_values_to_be_null:
|
||||
where: (upper(booking_status) not in ('NOTAPPROVED', 'FLAGGED', 'APPROVED', 'NOFLAGS'))
|
||||
|
||||
- name: has_resolution_incident
|
||||
data_type: boolean
|
||||
description: |
|
||||
Flag to identify if the booking has a Resolution Incident or not. This might
|
||||
imply that the resolution is in progress or that has been resolved, so it's not
|
||||
necessarily finished.
|
||||
If True, then the booking has at least one Resolution Incident.
|
||||
If False, then the booking has no Resolution Incidents - but this does not
|
||||
guarantee that the booking might have a resolution incident in the future.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- true
|
||||
where: (has_resolution_incident_finished = True or has_resolution_submitted_payout = True)
|
||||
- accepted_values:
|
||||
values:
|
||||
- false
|
||||
where: (is_booking_flagged_as_risk is null)
|
||||
|
||||
- name: has_resolution_incident_finished
|
||||
data_type: boolean
|
||||
description: |
|
||||
Flag to identify if the booking has a Resolution Incident that has been
|
||||
finished or not. This means that the resolution has been resolved and
|
||||
no further action is required.
|
||||
If True, then the booking has at least one Resolution Incident that has
|
||||
been finished.
|
||||
If False, then the booking has no Resolution Incidents that have been
|
||||
finished - but this does not guarantee that the booking might have a
|
||||
resolution incident ongoing or in the future.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: has_resolution_submitted_payout
|
||||
data_type: boolean
|
||||
description: |
|
||||
Flag to identify if the booking has a Resolution Incident that has
|
||||
submitted a resolution payout or not.
|
||||
If True, then the booking has at least one Resolution Incident that has
|
||||
submitted a payout.
|
||||
If False, then the booking has no Resolution Incidents that have
|
||||
submitted a payout - but this does not guarantee that the booking might
|
||||
have a resolution incident with a payout in the future.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: resolution_submitted_payout_amount_in_gbp
|
||||
data_type: decimal
|
||||
description: |
|
||||
Amount in GBP that has been submitted as a payout for the
|
||||
Resolution Incident. This is only populated if has_resolution_submitted_payout
|
||||
is True.
|
||||
It can be null if the booking has no Resolution Incidents or if the
|
||||
Resolution Incident has not submitted a payout.
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
- is_null:
|
||||
where: "has_resolution_submitted_payout = False"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue