data-dwh-dbt-project/models/reporting/general/new_dash_booking_summary.sql
Oriol Roqué Paniagua fda6c06222 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
2024-12-27 12:22:19 +00:00

38 lines
2 KiB
SQL

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