Merged PR 3902: Exposes New Dash Booking Summary

# Description

Exposes Booking Summary to reporting, but only for New Dash users.

# 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: #25228
This commit is contained in:
Oriol Roqué Paniagua 2024-12-27 12:22:19 +00:00
parent a51ad3dd69
commit fda6c06222
2 changed files with 234 additions and 0 deletions

View file

@ -0,0 +1,38 @@
with
int_core__booking_summary as (select * from {{ ref("int_core__booking_summary") }}),
int_core__deal as (select * from {{ ref("int_core__deal") }}),
int_hubspot__deal as (select * from {{ ref("int_hubspot__deal") }})
select
b.id_booking as id_booking,
b.id_deal as id_deal,
d.main_deal_name as main_deal_name,
hd.deal_name as hubspot_deal_name,
d.main_billing_country_iso_3_per_deal as main_billing_country,
hd.account_manager as account_manager,
b.booking_status as booking_status,
b.program_name as program_name,
b.booking_created_date_utc as booking_created_date_utc,
b.booking_check_in_date_utc as booking_check_in_date_utc,
b.booking_check_out_date_utc as booking_check_out_date_utc,
b.booking_number_of_nights as booking_number_of_nights,
b.host_currency_code as host_currency_code,
b.new_dash_version as new_dash_version,
date(b.user_in_new_dash_since_timestamp_at_utc) as user_in_new_dash_since_date_utc,
b.booking_total_price_in_gbp as booking_total_price_in_gbp,
b.service_first_chargeable_date_utc as service_first_chargeable_date_utc,
b.service_last_chargeable_date_utc as service_last_chargeable_date_utc,
b.number_of_applied_services as number_of_applied_services,
b.number_of_applied_upgraded_services as number_of_applied_upgraded_services,
b.is_booking_chargeable as is_booking_chargeable,
b.is_booking_cancelled as is_booking_cancelled,
b.has_upgraded_services as has_upgraded_services,
b.has_screening_service_business_type as has_screening_service_business_type,
b.has_deposit_management_service_business_type
as has_deposit_management_service_business_type,
b.has_protection_service_business_type as has_protection_service_business_type
from int_core__booking_summary b
left join int_core__deal d on b.id_deal = d.id_deal
left join int_hubspot__deal hd on b.id_deal = hd.id_deal
-- Select only New Dash bookings
where b.is_missing_id_deal = false and b.is_user_in_new_dash = true

View file

@ -1172,3 +1172,199 @@ models:
- GAIN
- MAJOR GAIN
- UNSET
- name: new_dash_booking_summary
description: |
This model contains enriched information aggregated at Booking level regarding
the services that are applied within a Booking, only for users in New Dash.
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.
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_deal
data_type: string
description: |
Unique identifier of the account. It cannot be null.
tests:
- not_null
- name: main_billing_country
data_type: string
description: |
ISO 3166-1 alpha-3 main country code in which the Deal is billed.
- name: main_deal_name
data_type: string
description: |
Main name for this ID deal, according to some logic from
backend (core) data.
It's a clean version of the most repeated name within the
user tables in the fields of first_name, last_name and company name.
This field should be modified at the moment we have
a proper way to retrieve a common account name per deal.
It can contain duplicates.
tests:
- not_null
- name: hubspot_deal_name
data_type: string
description: |
Name of the deal according to Hubspot. Preferred over main_deal_name.
- name: account_manager
data_type: string
description: |
The name of the account manager that is currently taking care of this
deal.
- name: booking_status
data_type: string
description: |
The current status of the booking. Cannot be null.
tests:
- not_null
- name: program_name
data_type: string
description: |
The name of the program, or product bundle, applied to the booking.
Cannot be null.
tests:
- not_null
- name: booking_created_date_utc
data_type: date
description: |
Date of when the Booking record was created in the Backend.
Cannot be null.
tests:
- not_null
- name: booking_check_in_date_utc
data_type: timestamp
description: |
Date of the Check-in of the Booking.
Cannot be null.
tests:
- not_null
- name: booking_check_out_date_utc
data_type: date
description: |
Date of the Check-out of the Booking.
tests:
- not_null
- name: booking_number_of_nights
data_type: integer
description: |
Number of nights between Check-in date and Check-out date.
- name: host_currency_code
data_type: string
description: |
Iso 4217 currency code for the account of the Host.
It can be null.
- name: new_dash_version
data_type: string
description: |
Specifies the New Dash Version in which these users were
moved or joined.
tests:
- not_null
- name: user_in_new_dash_since_date_utc
data_type: date
description: |
The effective date since the user can be considered in New Dash. If the user
has moved from Old Dash, it will be the date of new_dash_move_at_utc.
If not, it will correspond to the date of joined_at_utc.
- 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 chargeable
date due to the currency rate estimation in the future.
- name: service_first_chargeable_date_utc
data_type: date
description: |
Identifies the first moment in time in which the first
service applied to this booking is supposed to be charged.
- name: service_last_chargeable_date_utc
data_type: date
description: |
Identifies the last moment in time in which the last
service applied to this booking is supposed to be charged.
- name: number_of_applied_services
data_type: integer
description: |
Total number of Services 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_booking_chargeable
data_type: boolean
description: |
Flag to identify it the Booking is chargeable or not.
In essence, it solves the question: are we supposed to get
money out of this booking, or not?
To be considered as chargeable, a chargeable date needs to exist
as well as the total price converted to GBP needs to be strictly
greater than 0. The fact that a booking is not chargeable does
not necessarily mean that it won't be in the future. Similarly, if
the booking is chargeable it does not necessarily mean that is actually
charged. It cannot be null.
tests:
- not_null
- name: is_booking_cancelled
data_type: boolean
description: |
Flag to identify if the booking has been cancelled 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.