data-dwh-dbt-project/models/reporting/general/new_dash_booking_summary.sql
Oriol Roqué Paniagua d33e5ff2b2 Merged PR 5353: Switch int_core__booking_summary to int_booking_summary
# Description

This PR does the following:
* Moves `core/int_core__booking_summary` to `cross/int_core__booking_summary`
* Renames the model `cross/int_core__booking_summary` to `cross/int_booking_summary`
* Same for schema entry. In the new schema, I just added in the description how to retrieve exclusively New Dash Bookings for usability purposes.

Then, it adapts any dependency on `int_core__booking_summary` to `int_booking_summary`

No additional changes - inclusion of Resolution Incidents data will come later in a different PR.

# 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
2025-05-30 12:51:10 +00:00

44 lines
2.4 KiB
SQL

with
int_booking_summary as (select * from {{ ref("int_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.has_verification_request as has_verification_request,
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,
date_trunc('month', b.booking_created_date_utc)::date as booking_created_month,
date_trunc('month', b.booking_check_in_date_utc)::date as booking_check_in_month,
date_trunc('month', b.booking_check_out_date_utc)::date as booking_check_out_month,
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_upgraded_screening_service_business_type
as has_upgraded_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_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