commit wip

This commit is contained in:
Joaquin Ossa 2025-02-22 14:16:41 +01:00
parent 05adc07674
commit 9704426dd6
2 changed files with 25 additions and 7 deletions

View file

@ -4,8 +4,11 @@ models:
- name: stg_resolutions__incidents
description: |
"Contains all incidents stored by the resolutions team in Cosmos DB.
This includes data about the incident, the user claiming the incident, the booking,
the accommodation, the host and the guest."
This includes data about the incident, the user claiming the incident, the booking,
the accommodation, the host and the guest.
Some records (document_version <> 'OldClaimToIncidentModel') are older versions
of the incident model and don't have the same data structure as the current one.
Many of them don't have the same necessary fields as the current model."
columns:
- name: id_incident
data_type: text
@ -90,6 +93,9 @@ models:
Can be from SH or can be external from the client."
data_tests:
- not_null
- relationships:
to: ref('stg_core__user')
field: id_user
- name: host_user_claim_logs
data_type: text
@ -140,6 +146,9 @@ models:
data_tests:
- not_null:
where: "document_version <> 'OldClaimToIncidentModel'"
- relationships:
to: ref('stg_core__user')
field: id_user
- name: guest_email
data_type: text
@ -224,10 +233,13 @@ models:
damage once identified"
- name: id_accommodation
data_type: text
data_type: numeric
description: "Superhog code that uniquely identifies a single accommodation."
data_tests:
- not_null
- relationships:
to: ref('stg_core__accommodation')
field: id_accommodation
- name: accommodation_url
data_type: text
@ -287,11 +299,14 @@ models:
- not_null
- name: id_booking
data_type: text
data_type: numeric
description: "Superhog unique booking ID"
data_tests:
- not_null:
where: "document_version <> 'OldClaimToIncidentModel'"
- relationships:
to: ref('stg_core__booking')
field: id_booking
- name: booking_status
data_type: text

View file

@ -50,7 +50,7 @@ select
->> 'PhoneNumberWithCode' as host_phone_number_with_code,
-- Guest Details
{{ adapter.quote("documents") }} -> 'Guest' ->> 'Id' as id_user_guest,
nullif({{ adapter.quote("documents") }} -> 'Guest' ->> 'Id', '') as id_user_guest,
{{ adapter.quote("documents") }}
-> 'Guest'
-> 'ContactDetails'
@ -128,7 +128,8 @@ select
->> 'PreventativeStepsDetails' as guest_preventative_steps_details,
-- Accommodation Details
{{ adapter.quote("documents") }} -> 'Listing' ->> 'Id' as id_accommodation,
(nullif({{ adapter.quote("documents") }} -> 'Listing' ->> 'Id', ''))::numeric
as id_accommodation,
{{ adapter.quote("documents") }} -> 'Listing' ->> 'Url' as accommodation_url,
{{ adapter.quote("documents") }} -> 'Listing' ->> 'Name' as accommodation_name,
{{ adapter.quote("documents") }}
@ -158,7 +159,9 @@ select
as check_out_at_utc,
({{ adapter.quote("documents") }} -> 'Reservation' ->> 'CheckOut')::date
as check_out_date_utc,
{{ adapter.quote("documents") }} -> 'Reservation' ->> 'BookingId' as id_booking,
nullif(
({{ adapter.quote("documents") }} -> 'Reservation' ->> 'BookingId'), ''
)::numeric as id_booking,
{{ adapter.quote("documents") }}
-> 'Reservation'
->> 'BookingStatus' as booking_status,