Staging model for resolution incidents
This commit is contained in:
parent
5942e4b81c
commit
725f2a54c3
3 changed files with 600 additions and 0 deletions
8
models/staging/resolutions/_resolutions_sources.yml
Normal file
8
models/staging/resolutions/_resolutions_sources.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
version: 2
|
||||
|
||||
sources:
|
||||
- name: resolutions
|
||||
schema: sync_cdb_resolutions
|
||||
tables:
|
||||
- name: incident
|
||||
identifier: incident
|
||||
363
models/staging/resolutions/schema.yml
Normal file
363
models/staging/resolutions/schema.yml
Normal file
|
|
@ -0,0 +1,363 @@
|
|||
version: 2
|
||||
|
||||
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."
|
||||
columns:
|
||||
- name: id_incident
|
||||
data_type: text
|
||||
description: "Unique identifier for the incident."
|
||||
data_tests:
|
||||
- unique
|
||||
- not_null
|
||||
|
||||
- name: id_user
|
||||
data_type: text
|
||||
description: "Id of the user who created the incident."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_verification
|
||||
data_type: text
|
||||
description: "Superhog unique validation ID, coming from other APIs."
|
||||
|
||||
- name: current_status_name
|
||||
data_type: text
|
||||
description: "current status of the incident."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: is_submission_complete
|
||||
data_type: boolean
|
||||
description: "Flag to indicate if the submission is complete."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: current_agent_name
|
||||
data_type: text
|
||||
description: "Name of the agent who is currently handling the incident."
|
||||
|
||||
- name: read_only_for_customers
|
||||
data_type: boolean
|
||||
description: "Flag to indicate if the incident is read only for customers."
|
||||
|
||||
- name: status_history_logs
|
||||
data_type: text
|
||||
description: "Log of the status history."
|
||||
|
||||
- name: document_version
|
||||
data_type: text
|
||||
description: "Reported document resCentre, Api, manual form"
|
||||
|
||||
- name: task_execution_logs
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: created_at_date
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp when the incident was created."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: created_date_date
|
||||
data_type: date
|
||||
description: "Date when the incident was created."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_at_date
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp when the incident was last updated."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_date_date
|
||||
data_type: date
|
||||
description: "Date when the incident was last updated."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_user_host
|
||||
data_type: text
|
||||
description: "Unique Id that identifies the host.
|
||||
Can be from SH or can be external from the client."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: host_user_claim_logs
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: host_account_name
|
||||
data_type: text
|
||||
description: "Name of the host account."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: host_email
|
||||
data_type: text
|
||||
description: "Email of the host."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: host_last_name
|
||||
data_type: text
|
||||
description: "Last name of the host."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: host_first_name
|
||||
data_type: text
|
||||
description: "First name of the host."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: host_phone_code
|
||||
data_type: text
|
||||
description: "Phone code of the host."
|
||||
|
||||
- name: host_phone_number
|
||||
data_type: text
|
||||
description: "Phone number of the host."
|
||||
|
||||
- name: host_phone_number_with_code
|
||||
data_type: text
|
||||
description: "Phone number of the host with the code."
|
||||
|
||||
- name: id_user_guest
|
||||
data_type: text
|
||||
description: "Superhog code that uniquely identifies a single guest."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: guest_email
|
||||
data_type: text
|
||||
description: "Email of the guest."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: guest_last_name
|
||||
data_type: text
|
||||
description: "Last name of the guest."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: guest_first_name
|
||||
data_type: text
|
||||
description: "First name of the guest."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: guest_phone_code
|
||||
data_type: text
|
||||
description: "Phone code of the guest."
|
||||
|
||||
- name: guest_phone_number
|
||||
data_type: text
|
||||
description: "Phone number of the guest."
|
||||
|
||||
- name: guest_phone_number_with_code
|
||||
data_type: text
|
||||
description: "Phone number of the guest with the code."
|
||||
|
||||
- name: is_guest_deposit_retained
|
||||
data_type: boolean
|
||||
description: "In case a deposit has been collected from the guest,
|
||||
whether it has been retained or not."
|
||||
|
||||
- name: is_guest_deposit_collected
|
||||
data_type: boolean
|
||||
description: "If the host has collected a deposit from the guest."
|
||||
|
||||
- name: deposit_retained_amount_in_txn_currency
|
||||
data_type: text
|
||||
description: "Amount of the deposit retained in local currency."
|
||||
|
||||
- name: deposit_retained_currency
|
||||
data_type: text
|
||||
description: "Currency of the deposit retained."
|
||||
|
||||
- name: has_guest_contributed_to_cost
|
||||
data_type: boolean
|
||||
description: "If the guest has agreed to contribute to the cost when
|
||||
talking to the host"
|
||||
|
||||
- name: has_host_taken_preventative_steps
|
||||
data_type: boolean
|
||||
description: "If the host has taken any action to prevent the damage
|
||||
or further damage once identified"
|
||||
|
||||
- name: guest_contribution_amount_in_txn_currency
|
||||
data_type: text
|
||||
description: "Amount of the guest contribution, in case they did,
|
||||
in local currency."
|
||||
|
||||
- name: guest_contribution_currency
|
||||
data_type: text
|
||||
description: "Currency of the guest contribution."
|
||||
|
||||
- name: guest_contacted_about_damage
|
||||
data_type: boolean
|
||||
description: "If the host has contacted the guest about the damage caused"
|
||||
|
||||
- name: guest_contacted_evidence_files
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: guest_preventative_steps_details
|
||||
data_type: text
|
||||
description: "Description of any action to prevent the damage or further
|
||||
damage once identified"
|
||||
|
||||
- name: id_accommodation
|
||||
data_type: text
|
||||
description: "Superhog code that uniquely identifies a single accommodation."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: accommodation_url
|
||||
data_type: text
|
||||
description: "Accommodation URL from any distribution channel,
|
||||
preferable direct website."
|
||||
|
||||
- name: accommodation_name
|
||||
data_type: text
|
||||
description: "Accommodation name."
|
||||
|
||||
- name: accommodation_address
|
||||
data_type: text
|
||||
description: "Address of the accommodation."
|
||||
|
||||
- name: are_pets_allowed
|
||||
data_type: boolean
|
||||
description: "Flag to indicate if pets are allowed in the accommodation."
|
||||
|
||||
- name: comment_logs
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: has_underlying_insurance
|
||||
data_type: boolean
|
||||
description: "If the property has underlying insurance"
|
||||
|
||||
- name: insurance_claim_submitted
|
||||
data_type: boolean
|
||||
description: "If an insurance claim has been submitted to an insurance company"
|
||||
|
||||
- name: insurance_evidence_files
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: check_in_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp of the check-in date in UTC of the booking."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: check_in_date_utc
|
||||
data_type: date
|
||||
description: "Date of the check-in date in UTC of the booking."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: check_out_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp of the check-out date in UTC of the booking."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: check_out_date_utc
|
||||
data_type: date
|
||||
description: "Date of the check-out date in UTC of the booking."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_booking
|
||||
data_type: text
|
||||
description: "Superhog unique booking ID"
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_status
|
||||
data_type: text
|
||||
description: "Status of the booking."
|
||||
|
||||
- name: id_reservation
|
||||
data_type: text
|
||||
description: "External unique ID"
|
||||
|
||||
- name: booking_details
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: number_of_guests
|
||||
data_type: text
|
||||
description: "Number of guests in the booking."
|
||||
|
||||
- name: booking_services
|
||||
data_type: text
|
||||
description: "List of services included in the booking."
|
||||
|
||||
- name: booking_protection
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: booking_platform_used
|
||||
data_type: text
|
||||
description: "The booking platform used"
|
||||
|
||||
- name: booking_platform_reference
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: agent_history
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: before_damage_evidence
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: original_invoice_evidence
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: damage_incident_details
|
||||
data_type: text
|
||||
description: "Description of what happened in general terms"
|
||||
|
||||
- name: has_confirmed_loss
|
||||
data_type: boolean
|
||||
description: "Confirmation that the information they have provided in
|
||||
the report is true to the best of their knowledge."
|
||||
|
||||
- name: damage_report_items
|
||||
data_type: text
|
||||
description: "List of items that were damaged."
|
||||
|
||||
- name: third_party_claim_submitted
|
||||
data_type: boolean
|
||||
description: "If the host is seeking compensation from another platform"
|
||||
|
||||
- name: third_party_claim_from
|
||||
data_type: text
|
||||
description: "For example, Aircover from Airbnb."
|
||||
|
||||
- name: third_party_claim_amount_in_txn_currency
|
||||
data_type: text
|
||||
description: "Claim amount in local currency if the host is seeking
|
||||
compensation from another platform."
|
||||
|
||||
- name: third_party_claim_currency
|
||||
data_type: text
|
||||
description: "Currency of the claim amount if the host is seeking
|
||||
compensation from another platform."
|
||||
|
||||
- name: cosmos_db_timestamp_utc
|
||||
data_type: timestamp
|
||||
description: Internal Cosmos DB timestamp of the last record update.
|
||||
data_tests:
|
||||
- not_null
|
||||
229
models/staging/resolutions/stg_resolutions__incidents.sql
Normal file
229
models/staging/resolutions/stg_resolutions__incidents.sql
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
with raw_incident as (select * from {{ source("resolutions", "incident") }})
|
||||
select
|
||||
-- Basic Incident Details
|
||||
{{ adapter.quote("documents") }} ->> 'id' as id_incident,
|
||||
{{ adapter.quote("documents") }} ->> 'partitionKey' as id_user,
|
||||
{{ adapter.quote("documents") }} ->> 'VerificationId' as id_verification,
|
||||
{{ adapter.quote("documents") }} ->> 'CurrentStatusName' as current_status_name,
|
||||
({{ adapter.quote("documents") }} ->> 'IsSubmissionComplete')::boolean
|
||||
as is_submission_complete,
|
||||
{{ adapter.quote("documents") }} ->> 'CurrentAgentName' as current_agent_name,
|
||||
({{ adapter.quote("documents") }} ->> 'ReadOnlyForCustomers')::boolean
|
||||
as read_only_for_customers,
|
||||
{{ adapter.quote("documents") }} ->> 'StatusHistory' as status_history_logs,
|
||||
{{ adapter.quote("documents") }} ->> 'documentVersion' as document_version,
|
||||
{{ adapter.quote("documents") }} ->> 'TaskExecutionLogs' as task_execution_logs,
|
||||
({{ adapter.quote("documents") }} ->> 'CreatedDate')::timestamp as created_at_date,
|
||||
({{ adapter.quote("documents") }} ->> 'CreatedDate')::date as created_date_date,
|
||||
({{ adapter.quote("documents") }} ->> 'UpdatedDate')::timestamp as updated_at_date,
|
||||
({{ adapter.quote("documents") }} ->> 'UpdatedDate')::date as updated_date_date,
|
||||
|
||||
-- Host Details
|
||||
{{ adapter.quote("documents") }} -> 'Host' ->> 'Id' as id_user_host,
|
||||
{{ adapter.quote("documents") }} -> 'Host' ->> 'UserClaims' as host_user_claim_logs,
|
||||
{{ adapter.quote("documents") }} -> 'Host' ->> 'AccountName' as host_account_name,
|
||||
|
||||
-- Host Contact Details
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Host'
|
||||
-> 'ContactDetails'
|
||||
->> 'Email' as host_email,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Host'
|
||||
-> 'ContactDetails'
|
||||
->> 'LastName' as host_last_name,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Host'
|
||||
-> 'ContactDetails'
|
||||
->> 'FirstName' as host_first_name,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Host'
|
||||
-> 'ContactDetails'
|
||||
->> 'PhoneCode' as host_phone_code,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Host'
|
||||
-> 'ContactDetails'
|
||||
->> 'PhoneNumber' as host_phone_number,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Host'
|
||||
-> 'ContactDetails'
|
||||
->> 'PhoneNumberWithCode' as host_phone_number_with_code,
|
||||
|
||||
-- Guest Details
|
||||
{{ adapter.quote("documents") }} -> 'Guest' ->> 'Id' as id_user_guest,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'ContactDetails'
|
||||
->> 'Email' as guest_email,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'ContactDetails'
|
||||
->> 'LastName' as guest_last_name,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'ContactDetails'
|
||||
->> 'FirstName' as guest_first_name,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'ContactDetails'
|
||||
->> 'PhoneCode' as guest_phone_code,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'ContactDetails'
|
||||
->> 'PhoneNumber' as guest_phone_number,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'ContactDetails'
|
||||
->> 'PhoneNumberWithCode' as guest_phone_number_with_code,
|
||||
|
||||
-- Guest Deposit Details
|
||||
({{ adapter.quote("documents") }} -> 'Guest' -> 'Deposit' ->> 'IsRetained')::boolean
|
||||
as is_guest_deposit_retained,
|
||||
(
|
||||
{{ adapter.quote("documents") }} -> 'Guest' -> 'Deposit' ->> 'IsCollected'
|
||||
)::boolean as is_guest_deposit_collected,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Deposit'
|
||||
->> 'RetainedAmount' as deposit_retained_amount_in_txn_currency,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Deposit'
|
||||
->> 'RetainedCurrency' as deposit_retained_currency,
|
||||
|
||||
-- Guest Involvements
|
||||
(
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Involvements'
|
||||
->> 'ContributedToCost'
|
||||
)::boolean as has_guest_contributed_to_cost,
|
||||
(
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Involvements'
|
||||
->> 'PreventativeSteps'
|
||||
)::boolean as has_host_taken_preventative_steps,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Involvements'
|
||||
->> 'ContributionAmount' as guest_contribution_amount_in_txn_currency,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Involvements'
|
||||
->> 'ContributionCurrency' as guest_contribution_currency,
|
||||
(
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Involvements'
|
||||
->> 'ContactedAboutDamage'
|
||||
)::boolean as guest_contacted_about_damage,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Involvements'
|
||||
->> 'ContactedEvidenceFiles' as guest_contacted_evidence_files,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Guest'
|
||||
-> 'Involvements'
|
||||
->> 'PreventativeStepsDetails' as guest_preventative_steps_details,
|
||||
|
||||
-- Accommodation Details
|
||||
{{ adapter.quote("documents") }} -> 'Listing' ->> 'Id' as id_accommodation,
|
||||
{{ adapter.quote("documents") }} -> 'Listing' ->> 'Url' as accommodation_url,
|
||||
{{ adapter.quote("documents") }} -> 'Listing' ->> 'Name' as accommodation_name,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Listing'
|
||||
->> 'Address' as accommodation_address,
|
||||
({{ adapter.quote("documents") }} -> 'Listing' ->> 'PetsAllowed')::boolean
|
||||
as are_pets_allowed,
|
||||
|
||||
-- Comments
|
||||
{{ adapter.quote("documents") }} ->> 'Comments' as comment_logs,
|
||||
|
||||
-- Insurance Details
|
||||
({{ adapter.quote("documents") }} -> 'Insurance' ->> 'UnderlyingInsurance')::boolean
|
||||
as has_underlying_insurance,
|
||||
({{ adapter.quote("documents") }} -> 'Insurance' ->> 'ClaimSubmitted')::boolean
|
||||
as insurance_claim_submitted,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Insurance'
|
||||
->> 'UnderlyingInsuranceEvidenceFiles' as insurance_evidence_files,
|
||||
|
||||
-- Booking Details
|
||||
({{ adapter.quote("documents") }} -> 'Reservation' ->> 'CheckIn')::timestamp
|
||||
as check_in_at_utc,
|
||||
({{ adapter.quote("documents") }} -> 'Reservation' ->> 'CheckIn')::date
|
||||
as check_in_date_utc,
|
||||
({{ adapter.quote("documents") }} -> 'Reservation' ->> 'CheckOut')::timestamp
|
||||
as check_out_at_utc,
|
||||
({{ adapter.quote("documents") }} -> 'Reservation' ->> 'CheckOut')::date
|
||||
as check_out_date_utc,
|
||||
{{ adapter.quote("documents") }} -> 'Reservation' ->> 'BookingId' as id_booking,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Reservation'
|
||||
->> 'BookingStatus' as booking_status,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Reservation'
|
||||
->> 'ReservationId' as id_reservation,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Reservation'
|
||||
->> 'BookingDetails' as booking_details,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Reservation'
|
||||
->> 'NumberOfGuests' as number_of_guests,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Reservation'
|
||||
->> 'BookingServices' as booking_services,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Reservation'
|
||||
->> 'BookingProtection' as booking_protection,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Reservation'
|
||||
->> 'BookingPlatformUsed' as booking_platform_used,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'Reservation'
|
||||
->> 'BookingPlatformReference' as booking_platform_reference,
|
||||
|
||||
-- Agent History
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'AgentHistory'
|
||||
->> 'AgentHistory' as agent_history,
|
||||
|
||||
-- Damage Report
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'BeforeDamageEvidence'
|
||||
->> 'BeforeDamageEvidence' as before_damage_evidence,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'OriginalInvoiceEvidence'
|
||||
->> 'OriginalInvoiceEvidence' as original_invoice_evidence,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'DamageReport'
|
||||
->> 'IncidentDetails' as damage_incident_details,
|
||||
(
|
||||
{{ adapter.quote("documents") }} -> 'DamageReport' ->> 'DeclarationOfLoss'
|
||||
)::boolean as has_confirmed_loss,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'DamageReport'
|
||||
->> 'Items' as damage_report_items,
|
||||
|
||||
-- Third Party Compensation Claim
|
||||
(
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'ThirdPartyCompensationClaim'
|
||||
->> 'ClaimSubmitted'
|
||||
)::boolean as third_party_claim_submitted,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'ThirdPartyCompensationClaim'
|
||||
->> 'From' as third_party_claim_from,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'ThirdPartyCompensationClaim'
|
||||
->> 'Amount' as third_party_claim_amount_in_txn_currency,
|
||||
{{ adapter.quote("documents") }}
|
||||
-> 'ThirdPartyCompensationClaim'
|
||||
->> 'Currency' as third_party_claim_currency,
|
||||
|
||||
to_timestamp(
|
||||
(({{ adapter.quote("documents") }} ->> '_ts'))::integer
|
||||
) as cosmos_db_timestamp_utc
|
||||
|
||||
from raw_incident
|
||||
Loading…
Add table
Add a link
Reference in a new issue