commit wip
This commit is contained in:
parent
9fa62e0bf2
commit
3f224d8fed
2 changed files with 154 additions and 265 deletions
|
|
@ -31,7 +31,11 @@ with
|
|||
from jsonb_array_elements(status_history_logs::jsonb) status_step
|
||||
order by (status_step ->> 'CreatedDate')::timestamp desc
|
||||
limit 1
|
||||
) as last_status_at_utc
|
||||
) as last_status_at_utc,
|
||||
(
|
||||
select count(*)
|
||||
from jsonb_array_elements(host_user_claim_logs::jsonb) comment
|
||||
) as claims_count
|
||||
from stg_resolutions__incidents
|
||||
),
|
||||
damage_reported_items as (
|
||||
|
|
@ -41,13 +45,16 @@ with
|
|||
damage_report as (
|
||||
select
|
||||
id_incident,
|
||||
count(distinct item ->> 'Id') as number_damaged_items, -- Counting unique damaged items
|
||||
count(distinct item ->> 'Id') as number_damaged_items,
|
||||
sum(
|
||||
coalesce((corrective_measures ->> 'OriginalAmount')::numeric, 0)
|
||||
) as original_value_amount_in_txn_currency,
|
||||
sum(
|
||||
coalesce((corrective_measures ->> 'Amount')::numeric, 0)
|
||||
) as asked_repair_amount,
|
||||
) as asked_repair_amount_in_txn_currency,
|
||||
sum(
|
||||
coalesce((corrective_measures ->> 'SettlementAmount')::numeric, 0)
|
||||
) as accepted_amount
|
||||
) as accepted_amount_in_txn_currency
|
||||
from
|
||||
damage_reported_items,
|
||||
jsonb_array_elements(item -> 'CorrectiveMeasures') as corrective_measures
|
||||
|
|
@ -62,10 +69,7 @@ select
|
|||
current_status_name,
|
||||
is_submission_complete,
|
||||
current_agent_name,
|
||||
read_only_for_customers,
|
||||
status_history_logs,
|
||||
document_version,
|
||||
task_execution_logs,
|
||||
created_at_date,
|
||||
created_date_date,
|
||||
updated_at_date,
|
||||
|
|
@ -87,75 +91,11 @@ select
|
|||
else null
|
||||
end as resolution_time_in_hours,
|
||||
dr.number_damaged_items,
|
||||
dr.asked_repair_amount,
|
||||
dr.accepted_amount,
|
||||
dr.original_value_amount_in_txn_currency,
|
||||
dr.asked_repair_amount_in_txn_currency,
|
||||
dr.accepted_amount_in_txn_currency,
|
||||
|
||||
-- Host Details
|
||||
id_user_host,
|
||||
host_user_claim_logs,
|
||||
host_account_name,
|
||||
|
||||
-- Host Contact Details
|
||||
host_email,
|
||||
host_last_name,
|
||||
host_first_name,
|
||||
host_phone_code,
|
||||
host_phone_number,
|
||||
host_phone_number_with_code,
|
||||
|
||||
-- Guest Details
|
||||
id_user_guest,
|
||||
guest_email,
|
||||
guest_last_name,
|
||||
guest_first_name,
|
||||
guest_phone_code,
|
||||
guest_phone_number,
|
||||
guest_phone_number_with_code,
|
||||
|
||||
-- Guest Deposit Details
|
||||
is_guest_deposit_retained,
|
||||
is_guest_deposit_collected,
|
||||
deposit_retained_amount_in_txn_currency,
|
||||
deposit_retained_currency,
|
||||
|
||||
-- Guest Involvements
|
||||
has_guest_contributed_to_cost,
|
||||
has_host_taken_preventative_steps,
|
||||
guest_contribution_amount_in_txn_currency,
|
||||
guest_contribution_currency,
|
||||
guest_contacted_about_damage,
|
||||
guest_contacted_evidence_files,
|
||||
guest_preventative_steps_details,
|
||||
|
||||
-- Accommodation Details
|
||||
id_accommodation,
|
||||
accommodation_url,
|
||||
accommodation_name,
|
||||
are_pets_allowed,
|
||||
|
||||
-- Booking Details
|
||||
check_in_at_utc,
|
||||
check_in_date_utc,
|
||||
check_out_at_utc,
|
||||
check_out_date_utc,
|
||||
id_booking,
|
||||
booking_status,
|
||||
id_reservation,
|
||||
booking_details,
|
||||
number_of_guests,
|
||||
booking_services,
|
||||
booking_protection,
|
||||
booking_platform_used,
|
||||
booking_platform_reference,
|
||||
|
||||
-- Damage Report
|
||||
before_damage_evidence,
|
||||
original_invoice_evidence,
|
||||
damage_incident_details,
|
||||
has_confirmed_loss,
|
||||
damage_report_items,
|
||||
|
||||
-- Calculator
|
||||
-- Resolutions calculator
|
||||
protection_name,
|
||||
was_overriden,
|
||||
waiver_or_deposit_name,
|
||||
|
|
@ -169,6 +109,53 @@ select
|
|||
calculated_guest_charge_currency,
|
||||
calculated_guest_charge_amount_in_usd
|
||||
|
||||
-- Host Details
|
||||
id_user_host,
|
||||
lt.claims_count,
|
||||
host_account_name,
|
||||
|
||||
-- Host Contact Details
|
||||
host_email,
|
||||
host_last_name,
|
||||
host_first_name,
|
||||
host_phone_code,
|
||||
host_phone_number,
|
||||
|
||||
-- Guest Details
|
||||
id_user_guest,
|
||||
guest_email,
|
||||
guest_last_name,
|
||||
guest_first_name,
|
||||
guest_phone_code,
|
||||
guest_phone_number,
|
||||
|
||||
-- Guest Deposit Details
|
||||
is_guest_deposit_retained,
|
||||
is_guest_deposit_collected,
|
||||
deposit_retained_amount_in_txn_currency,
|
||||
deposit_retained_currency,
|
||||
|
||||
-- Guest Involvements
|
||||
has_guest_contributed_to_cost,
|
||||
has_host_taken_preventative_steps,
|
||||
guest_contribution_amount_in_txn_currency,
|
||||
guest_contribution_currency,
|
||||
guest_contacted_about_damage,
|
||||
|
||||
-- Accommodation Details
|
||||
id_accommodation,
|
||||
accommodation_name,
|
||||
|
||||
-- Booking Details
|
||||
check_in_at_utc,
|
||||
check_in_date_utc,
|
||||
check_out_at_utc,
|
||||
check_out_date_utc,
|
||||
id_booking,
|
||||
booking_status,
|
||||
id_reservation,
|
||||
booking_protection
|
||||
|
||||
from stg_resolutions__incidents i
|
||||
left join logs_timeline lt on i.id_incident = lt.id_incident
|
||||
left join damage_report dr on i.id_incident = dr.id_incident
|
||||
|
|
|
|||
|
|
@ -2,23 +2,15 @@ version: 2
|
|||
|
||||
models:
|
||||
- name: int_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."
|
||||
description: ""
|
||||
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
|
||||
|
|
@ -27,93 +19,142 @@ models:
|
|||
- 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: first_comment_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: ""
|
||||
|
||||
- name: last_comment_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: ""
|
||||
|
||||
- name: comment_count
|
||||
data_type: bigint
|
||||
description: ""
|
||||
|
||||
- name: first_status_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: ""
|
||||
|
||||
- name: last_status_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: ""
|
||||
|
||||
- name: resolution_time_in_hours
|
||||
data_type: numeric
|
||||
description: ""
|
||||
|
||||
- name: number_damaged_items
|
||||
data_type: bigint
|
||||
description: ""
|
||||
|
||||
- name: original_value_amount_in_txn_currency
|
||||
data_type: numeric
|
||||
description: ""
|
||||
|
||||
- name: asked_repair_amount_in_txn_currency
|
||||
data_type: numeric
|
||||
description: ""
|
||||
|
||||
- name: accepted_amount_in_txn_currency
|
||||
data_type: numeric
|
||||
description: ""
|
||||
|
||||
- name: protection_name
|
||||
data_type: text
|
||||
description: "Protection name."
|
||||
|
||||
- name: was_overriden
|
||||
data_type: boolean
|
||||
description: "Flag to indicate if the proposed settlement value from the calculator was overriden."
|
||||
|
||||
- name: waiver_or_deposit_name
|
||||
data_type: text
|
||||
description: "Waiver or deposit name."
|
||||
|
||||
- name: guest_verification_status
|
||||
data_type: text
|
||||
description: "Guest verification status for this booking."
|
||||
|
||||
- name: lower_protection_limit_usd
|
||||
data_type: text
|
||||
description: "Lower protection limit in USD."
|
||||
|
||||
- name: upper_protection_limit_usd
|
||||
data_type: text
|
||||
description: "Upper protection limit in USD."
|
||||
|
||||
- name: calculated_payout_amount_in_txn_currency
|
||||
data_type: text
|
||||
description: "Calculated payout amount in local currency."
|
||||
|
||||
- name: calculated_payout_currency
|
||||
data_type: text
|
||||
description: "Currency of the calculated payout amount."
|
||||
|
||||
- name: calculated_payout_amount_in_usd
|
||||
data_type: text
|
||||
description: "Calculated payout amount in USD."
|
||||
|
||||
- name: calculated_guest_charge_amount_in_txn_currency
|
||||
data_type: text
|
||||
description: "Calculated guest charge amount in local currency."
|
||||
|
||||
- name: calculated_guest_charge_currency
|
||||
data_type: text
|
||||
description: "Currency of the calculated guest charge amount."
|
||||
|
||||
- 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
|
||||
description: "Unique Id that identifies the host. Can be from SH or can be external from the client."
|
||||
|
||||
- name: host_user_claim_logs
|
||||
data_type: text
|
||||
- name: claims_count
|
||||
data_type: bigint
|
||||
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
|
||||
|
|
@ -123,33 +164,21 @@ models:
|
|||
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
|
||||
|
|
@ -159,14 +188,9 @@ models:
|
|||
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."
|
||||
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
|
||||
|
|
@ -182,18 +206,15 @@ models:
|
|||
|
||||
- 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"
|
||||
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"
|
||||
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."
|
||||
description: "Amount of the guest contribution, in case they did, in local currency."
|
||||
|
||||
- name: guest_contribution_currency
|
||||
data_type: text
|
||||
|
|
@ -203,83 +224,33 @@ models:
|
|||
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
|
||||
|
|
@ -289,75 +260,6 @@ models:
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue