commit wip
This commit is contained in:
parent
7551f6e515
commit
47d9b6f292
1 changed files with 38 additions and 3 deletions
|
|
@ -1,11 +1,28 @@
|
||||||
with
|
with
|
||||||
stg_resolutions__incidents as (
|
stg_resolutions__incidents as (
|
||||||
select * from {{ ref("stg_resolutions__incidents") }}
|
select * from {{ ref("stg_resolutions__incidents") }}
|
||||||
|
),
|
||||||
|
comments_timeline as (
|
||||||
|
select
|
||||||
|
i.id_incident,
|
||||||
|
(
|
||||||
|
select (comment ->> 'CreatedDate')::timestamp
|
||||||
|
from jsonb_array_elements(i.comment_logs::jsonb) comment
|
||||||
|
order by (comment ->> 'CreatedDate')::timestamp
|
||||||
|
limit 1
|
||||||
|
) as first_comment_date,
|
||||||
|
(
|
||||||
|
select (comment ->> 'CreatedDate')::timestamp
|
||||||
|
from jsonb_array_elements(i.comment_logs::jsonb) comment
|
||||||
|
order by (comment ->> 'CreatedDate')::timestamp desc
|
||||||
|
limit 1
|
||||||
|
) as last_comment_date
|
||||||
|
from stg_resolutions__incidents i
|
||||||
)
|
)
|
||||||
|
|
||||||
select
|
select
|
||||||
-- Basic Incident Details
|
-- Basic Incident Details
|
||||||
id_incident,
|
i.id_incident,
|
||||||
id_user,
|
id_user,
|
||||||
id_verification,
|
id_verification,
|
||||||
current_status_name,
|
current_status_name,
|
||||||
|
|
@ -20,6 +37,10 @@ select
|
||||||
updated_at_date,
|
updated_at_date,
|
||||||
updated_date_date,
|
updated_date_date,
|
||||||
|
|
||||||
|
-- Resolution Details
|
||||||
|
first_comment_date,
|
||||||
|
last_comment_date,
|
||||||
|
|
||||||
-- Host Details
|
-- Host Details
|
||||||
id_user_host,
|
id_user_host,
|
||||||
host_user_claim_logs,
|
host_user_claim_logs,
|
||||||
|
|
@ -69,7 +90,6 @@ select
|
||||||
check_out_at_utc,
|
check_out_at_utc,
|
||||||
check_out_date_utc,
|
check_out_date_utc,
|
||||||
id_booking,
|
id_booking,
|
||||||
|
|
||||||
booking_status,
|
booking_status,
|
||||||
id_reservation,
|
id_reservation,
|
||||||
booking_details,
|
booking_details,
|
||||||
|
|
@ -86,4 +106,19 @@ select
|
||||||
has_confirmed_loss,
|
has_confirmed_loss,
|
||||||
damage_report_items,
|
damage_report_items,
|
||||||
|
|
||||||
from raw_incident
|
-- Calculator
|
||||||
|
protection_name,
|
||||||
|
was_overriden,
|
||||||
|
waiver_or_deposit_name,
|
||||||
|
guest_verification_status,
|
||||||
|
lower_protection_limit_usd,
|
||||||
|
upper_protection_limit_usd,
|
||||||
|
calculated_payout_amount_in_txn_currency,
|
||||||
|
calculated_payout_currency,
|
||||||
|
calculated_payout_amount_in_usd,
|
||||||
|
calculated_guest_charge_amount_in_txn_currency,
|
||||||
|
calculated_guest_charge_currency,
|
||||||
|
calculated_guest_charge_amount_in_usd
|
||||||
|
|
||||||
|
from stg_resolutions__incidents i
|
||||||
|
left join comments_timeline ct on i.id_incident = ct.id_incident
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue