Merged PR 3539: Normalise service names and create booking to service table

# Description

Goal of the PR is start modelising the Services and Revenue for New Dash/New Pricing. Be aware that this is a first model and it's not by all means the definitive nor complete version.

Changes:
* Services name normalisation: It's a bit painful because we usually had two names: 'MyService' and 'My Service'. The initial setup I built was considering the first, but in some new integrated tables it only has the second. So I just standardised everything to be in upper case and with spaces such as 'MY SERVICE'. Might make more sense later on. This affects many existing models.
* Compute a new Service Business Type field in `stg_core__product_service`: Main reason is that effectively Platform scope in New Pricing have business differences in the services types but this does not exist in the backend. I do it at staging level with a dedicated accepted values test to ensure any new update is captured and notified. You can read more about the business logic in this [Notion page](https://www.notion.so/knowyourguest-superhog/All-Services-Definitions-333fba1fbed54715b6b1c3b5133f0d4f).
* Create a new model `int_core__booking_to_service`: this model joins the information of BookingViewToService with BookingView and Booking tables to retrieve a more consolidated version of what we will needed downstream for the future table of Booking Service Detail and the Aggregated version (not included in this PR). This table likely can be enriched in future PRs. At the moment it just contains the bare minimum fields needed for the lines/aggregated versions. (NB: Booking information is needed, for instance, for the services which unit price need to be applied for the number of nights of the booking)

# 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

- [X] Check if a full-refresh is required after this PR is merged. **stg_core__booking_view_to_service needs full refresh**

Related work items: #20809
This commit is contained in:
Oriol Roqué Paniagua 2024-11-15 10:04:02 +00:00
parent 321f48ca7d
commit c209e670ca
13 changed files with 224 additions and 19 deletions

View file

@ -522,11 +522,11 @@ models:
- name: product_service_name
data_type: string
description: |
CamelCase name of the product service. Uniquely identifies the product service.
Name of the product service. Uniquely identifies the product service.
tests:
- unique
- not_null
- name: product_service_full_name
- name: product_service_display_name
data_type: string
description: |
A more readable way to display the product service. It's mainly product_service_name
@ -556,6 +556,17 @@ models:
tests:
- not_null
- unique
- name: service_business_type
data_type: string
description: |
Specifies the business type of the service, in essence, whether it is a Screening service
or a Deposit Management service.
tests:
- not_null
- accepted_values:
values:
- "SCREENING"
- "DEPOSIT_MANAGEMENT"
- name: dwh_extracted_at_utc
data_type: timestamp
description: |

View file

@ -11,7 +11,7 @@ with
{{ adapter.quote("ProductServiceId") }} as id_product_service,
{{ adapter.quote("ProtectionPlanId") }} as id_protection_plan,
{{ adapter.quote("ServiceName") }} as service_name,
upper({{ adapter.quote("ServiceName") }}) as service_name,
{{ adapter.quote("ProtectionAmount") }} as service_protection_amount,
upper({{ adapter.quote("Status") }}) as service_status,

View file

@ -4,8 +4,8 @@ with
select
{{ adapter.quote("Id") }} as id_product_service,
{{ adapter.quote("Name") }} as product_service_name,
{{ adapter.quote("FullName") }} as product_service_full_name,
upper({{ adapter.quote("Name") }}) as product_service_name,
upper({{ adapter.quote("FullName") }}) as product_service_display_name,
{{ adapter.quote("Description") }} as product_service_description,
{{ adapter.quote("ProductServiceFlag") }} as product_service_binary_tier,
@ -13,5 +13,33 @@ with
from raw_product_service
)
select *
select
id_product_service,
case
when
id_product_service in (
1, -- 'BASIC SCREENING'
2, -- 'SEX OFFENDERS CHECK'
3, -- 'ID VERIFICATION'
4 -- 'SCREENING PLUS'
)
then 'SCREENING'
when
id_product_service in (
5, -- 'BASIC DAMAGE DEPOSIT'
6, -- 'DAMAGE DEPOSIT PLUS'
7, -- 'BASIC WAIVER'
8, -- 'WAIVER PLUS'
9 -- 'WAIVER PRO'
)
then 'DEPOSIT_MANAGEMENT'
else null
end as service_business_type,
product_service_name,
product_service_display_name,
product_service_description,
product_service_binary_tier,
dwh_extracted_at_utc
from stg_core__product_service

View file

@ -3,8 +3,8 @@ with
select
{{ adapter.quote("Id") }} as id,
{{ adapter.quote("Name") }} as protection_name,
{{ adapter.quote("DisplayName") }} as protection_display_name,
upper({{ adapter.quote("Name") }}) as protection_name,
upper({{ adapter.quote("DisplayName") }}) as protection_display_name,
{{ adapter.quote("RequiredProductServices") }}
as required_product_services_binary_tier

View file

@ -9,8 +9,8 @@ with
{{ adapter.quote("ProductBundleId") }} as id_product_bundle,
{{ adapter.quote("ProtectionPlanId") }} as id_protection_plan,
{{ adapter.quote("Name") }} as product_bundle_name,
{{ adapter.quote("DisplayName") }} as product_bundle_display_name,
upper({{ adapter.quote("Name") }}) as product_bundle_name,
upper({{ adapter.quote("DisplayName") }}) as product_bundle_display_name,
{{ adapter.quote("DisplayOnFrontEnd") }} as display_on_front_end,
{{ adapter.quote("ChosenProductServices") }} as chosen_product_services,