Merged PR 3588: First version of booking summary

# Description

This table provides the Booking that are under New Pricing. Some of them might also be under New Dashboard.

Changes on existing models:
* Added a few informative fields in the view `int_core__booking_to_service` that enables feeding Booking Service Detail and Booking Summary. These are: `id_verification_request`, `id_deal`, `is_user_in_new_dash`, `new_dash_version`, `user_in_new_dash_since_timestamp_at_utc`.

New models:
* Created a first version of `int_core__booking_summary`. This model mainly retrieves Booking attributes from `int_core__booking_to_service` and aggregates service information (paid services, upgraded services, types of services applied, total price, etc) from the detailed version of this table which is `int_core__booking_service_detail`.

# 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: #20809
This commit is contained in:
Oriol Roqué Paniagua 2024-11-19 16:42:34 +00:00
parent 1c1af44e76
commit 23cc5459e3
3 changed files with 388 additions and 2 deletions

View file

@ -1880,7 +1880,7 @@ models:
data_type: timestamp
description: |
For users that are in New Dash, the effective date since
these users can be considered in New Dash. It the user
these users can be considered in New Dash. If the user
has moved from Old Dash, it will be the new_dash_move_at_utc.
If not, it will correspond to the joined_at_utc.
@ -1932,7 +1932,7 @@ models:
data_type: timestamp
description: |
For users that are in New Dash, the effective date since
these users can be considered in New Dash. It the user
these users can be considered in New Dash. If the user
has moved from Old Dash, it will be the new_dash_move_at_utc.
If not, it will correspond to the joined_at_utc.
@ -3204,6 +3204,12 @@ models:
- not_null
- unique
- name: id_verification_request
data_type: bigint
description:
The identifier of the verification request. It acts as Foreign Key to
Verification Request table. It can be null.
- name: id_verification
data_type: bigint
description: |
@ -3222,6 +3228,11 @@ models:
The identifier of the protection plan, aka protection service. It acts as
Foreign Key to Product Plan table. It can be null.
- name: id_deal
data_type: string
description: |
Unique identifier of the account. It can be null.
- name: id_user_host
data_type: string
description: |
@ -3312,6 +3323,29 @@ models:
Iso 4217 currency code for the account of the Host.
It can be null.
- name: is_user_in_new_dash
data_type: boolean
description: |
Flag to determine if this user host is in New Dash or not.
tests:
- not_null
- name: new_dash_version
data_type: string
description: |
For users that are in New Dash, specifies the New Dash Version
in which these users were moved or joined. It can be null if
the user is not in new dash.
- name: user_in_new_dash_since_timestamp_at_utc
data_type: timestamp
description: |
For users that are in New Dash, the effective date since
these users can be considered in New Dash. If the user
has moved from Old Dash, it will be the new_dash_move_at_utc.
If not, it will correspond to the joined_at_utc. It can be null
if the user is not in new dash.
- name: is_missing_host_currency_code
data_type: boolean
description: |
@ -3571,3 +3605,242 @@ models:
meaning, it's not a Basic Screening.
tests:
- not_null
- name: int_core__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.
tests:
- 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
or_equal: True
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
column_A: number_of_applied_services
column_B: number_of_applied_paid_services
or_equal: True
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
column_A: number_of_applied_services
column_B: number_of_applied_upgraded_services
or_equal: True
columns:
- name: id_booking
data_type: bigint
description: |
The identifier of the booking. Acts as Primary Key to this table.
Cannot be null.
tests:
- not_null
- unique
- name: id_verification_request
data_type: bigint
description:
The identifier of the verification request. It acts as Foreign Key to
Verification Request table. It can be null.
- name: id_deal
data_type: string
description: |
Unique identifier of the account. It can be null.
- name: id_user_host
data_type: string
description: |
Unique identifier of the user that acts as a Host. Cannot be null.
tests:
- not_null
- name: id_user_guest
data_type: string
description: |
Unique identifier of the user that acts as a Guest.
Can be null if Superhog does not interact with the Guest.
- name: booking_status
data_type: string
description: |
The current status of the booking. Cannot be null.
tests:
- not_null
- name: booking_created_at_utc
data_type: timestamp
description: |
Timestamp of when the Booking record was created in the Backend.
Cannot be null.
tests:
- not_null
- name: booking_updated_at_utc
data_type: timestamp
description: |
Timestamp of when the Booking record was last updated in the Backend.
Cannot be null.
tests:
- not_null
- name: booking_check_in_at_utc
data_type: timestamp
description: |
Timestamp of the Check-in of the Booking.
Cannot be null.
tests:
- not_null
- name: booking_check_out_at_utc
data_type: timestamp
description: |
Timestamp of the Check-out of the Booking.
Cannot be null.
tests:
- not_null
- name: host_currency_code
data_type: string
description: |
Iso 4217 currency code for the account of the Host.
It can be null.
- name: is_user_in_new_dash
data_type: boolean
description: |
Flag to determine if this user host is in New Dash or not.
tests:
- not_null
- name: new_dash_version
data_type: string
description: |
For users that are in New Dash, specifies the New Dash Version
in which these users were moved or joined. It can be null if
the user is not in new dash.
- name: user_in_new_dash_since_timestamp_at_utc
data_type: timestamp
description: |
For users that are in New Dash, the effective date since
these users can be considered in New Dash. If the user
has moved from Old Dash, it will be the new_dash_move_at_utc.
If not, it will correspond to the joined_at_utc. It can be null
if the user is not in new dash.
- name: booking_total_price_in_gbp
data_type: decimal
description: |
Identifies the current total price of the booking by adding up the
prices of each service applied to this booking, converted in GBP.
Can be null. Can vary over time depending on the service status,
payments, etc, as well as it can vary over time until the charge
date due to the currency rate estimation in the future.
- name: first_service_charge_date_utc
data_type: date
description: |
Identifies the first moment in time in which the first
service applied to this booking is charged.
- name: last_service_charge_date_utc
data_type: date
description: |
Identifies the last moment in time in which the last
service applied to this booking is charged.
- name: first_service_detail_created_at_utc
data_type: timestamp
description: |
Timestamp corresponding to the first creation of a Service
record applied to this Booking, according to the Backend.
tests:
- not_null
- name: last_service_detail_created_at_utc
data_type: timestamp
description: |
Timestamp corresponding to the latest creation of a Service
record applied to this Booking, according to the Backend.
tests:
- not_null
- name: last_service_detail_updated_at_utc
data_type: timestamp
description: |
Timestamp corresponding to the latest update on any Service
record applied to this Booking, according to the Backend.
tests:
- not_null
- name: number_of_applied_services
data_type: integer
description: |
Total number of Services applied to this Booking.
- 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.
- name: number_of_applied_upgraded_services
data_type: integer
description: |
Total number of Services different from Basic Screening
applied to this Booking.
- name: is_missing_currency_code_in_service_detail
data_type: boolean
description: |
Flag to identify if the currency code is missing in any
Booking Service Detail record for this Booking.
- name: is_booking_cancelled
data_type: boolean
description: |
Flag to identify if the booking has been cancelled or not.
- name: has_paid_services
data_type: boolean
description: |
Flag to identify if the booking has any paid service or not.
- name: has_upgraded_services
data_type: boolean
description: |
Flag to identify if the booking has any service different from
Basic Screening or not.
- name: has_screening_service_business_type
data_type: boolean
description: |
Flag to identify if the booking contains any Screening service
or not.
- name: has_deposit_management_service_business_type
data_type: boolean
description: |
Flag to identify if the booking contains any Deposit
Management service or not.
- name: has_protection_service_business_type
data_type: boolean
description: |
Flag to identify if the booking contains any Protection
service or not.
- name: is_missing_id_deal
data_type: boolean
description: |
Flag to identify if the Host for this booking is missing
the Id Deal or not.
- name: is_missing_host_currency_code
data_type: boolean
description: |
Flag to identify if the Host for this booking is missing
the currency code or not.