change logic in new CTE to use new tables
This commit is contained in:
parent
58c1ae5b8f
commit
7339cf4c87
1 changed files with 37 additions and 18 deletions
|
|
@ -2,9 +2,16 @@ with
|
||||||
int_core__verification_requests as (
|
int_core__verification_requests as (
|
||||||
select * from {{ ref("int_core__verification_requests") }}
|
select * from {{ ref("int_core__verification_requests") }}
|
||||||
),
|
),
|
||||||
|
stg_core__currency as (select * from {{ ref("stg_core__currency") }}),
|
||||||
stg_core__verification_set_to_verification_type as (
|
stg_core__verification_set_to_verification_type as (
|
||||||
select * from {{ ref("stg_core__verification_set_to_verification_type") }}
|
select * from {{ ref("stg_core__verification_set_to_verification_type") }}
|
||||||
),
|
),
|
||||||
|
stg_core__verification_request_to_guest_product as (
|
||||||
|
select * from {{ ref("stg_core__verification_request_to_guest_product") }}
|
||||||
|
),
|
||||||
|
stg_core__guest_product_configuration_price_plan as (
|
||||||
|
select * from {{ ref("stg_core__guest_product_configuration_price_plan") }}
|
||||||
|
),
|
||||||
int_core__bookings as (select * from {{ ref("int_core__bookings") }}),
|
int_core__bookings as (select * from {{ ref("int_core__bookings") }}),
|
||||||
int_core__check_in_cover_prices as (
|
int_core__check_in_cover_prices as (
|
||||||
select * from {{ ref("int_core__check_in_cover_prices") }}
|
select * from {{ ref("int_core__check_in_cover_prices") }}
|
||||||
|
|
@ -121,9 +128,9 @@ with
|
||||||
select
|
select
|
||||||
vr.id_verification_request,
|
vr.id_verification_request,
|
||||||
vr.uuid_verification_request,
|
vr.uuid_verification_request,
|
||||||
vr.id_verification_set,
|
null as id_verification_set,
|
||||||
vr.id_superhog_verified_set,
|
null as id_superhog_verified_set,
|
||||||
vr.id_payment_validation_set,
|
null as id_payment_validation_set,
|
||||||
vr.id_user_guest,
|
vr.id_user_guest,
|
||||||
vr.id_user_host,
|
vr.id_user_host,
|
||||||
b.id_booking,
|
b.id_booking,
|
||||||
|
|
@ -187,33 +194,45 @@ with
|
||||||
p.amount_without_taxes_in_txn_currency,
|
p.amount_without_taxes_in_txn_currency,
|
||||||
p.total_amount_in_gbp,
|
p.total_amount_in_gbp,
|
||||||
p.amount_without_taxes_in_gbp,
|
p.amount_without_taxes_in_gbp,
|
||||||
ccp.checkin_cover_limit_amount_local_curr,
|
gpcpp.protection_limit_in_local_currency
|
||||||
|
as checkin_cover_limit_amount_local_curr,
|
||||||
(
|
(
|
||||||
ccp.checkin_cover_limit_amount_local_curr
|
gpcpp.protection_limit_in_local_currency
|
||||||
* (p.total_amount_in_gbp / p.total_amount_in_txn_currency)
|
* (p.total_amount_in_gbp / p.total_amount_in_txn_currency)
|
||||||
)::numeric(18, 4) as checkin_cover_limit_amount_in_gbp
|
)::numeric(18, 4) as checkin_cover_limit_amount_in_gbp
|
||||||
from int_core__verification_requests vr
|
from int_core__verification_requests vr
|
||||||
|
inner join
|
||||||
|
stg_core__verification_request_to_guest_product vrtogp
|
||||||
|
on vr.id_verification_request = vrtogp.id_verification_request
|
||||||
|
inner join
|
||||||
|
stg_core__guest_product_configuration_price_plan gpcpp
|
||||||
|
on vrtogp.id_guest_product_configuration_price_plan
|
||||||
|
= gpcpp.id_guest_product_configuration_price_plan
|
||||||
|
inner join stg_core__currency c on c.id_currency = gpcpp.id_currency
|
||||||
left join
|
left join
|
||||||
int_core__bookings b
|
int_core__bookings b
|
||||||
on vr.id_verification_request = b.id_verification_request
|
on vr.id_verification_request = b.id_verification_request
|
||||||
left join
|
|
||||||
stg_core__verification_set_to_verification_type vstvt
|
|
||||||
on vr.id_verification_set = vstvt.id_verification_set
|
|
||||||
left join
|
left join
|
||||||
check_in_cover_payments p
|
check_in_cover_payments p
|
||||||
on vr.id_verification_request = p.id_verification_request
|
on vr.id_verification_request = p.id_verification_request
|
||||||
left join
|
|
||||||
int_core__check_in_cover_prices ccp
|
|
||||||
on p.currency = ccp.local_currency_iso_4217
|
|
||||||
left join int_core__unified_user gu on gu.id_user = vr.id_user_guest
|
left join int_core__unified_user gu on gu.id_user = vr.id_user_guest
|
||||||
-- 15 is Check-in cover.
|
where
|
||||||
-- Adding this condition results in only keeping guest journeys that offered the
|
p.currency = c.iso4217_code
|
||||||
-- check-in cover
|
and vrtogp.id_guest_product = 2 -- 2 is CIH
|
||||||
where vstvt.id_verification_type = 99
|
and vr.link_used_at_utc
|
||||||
|
>= {{ var("guest_products_feature_flag_activation_timestamp") }} -- This logic path only applies to VRs started after the FF was activated
|
||||||
)
|
)
|
||||||
|
|
||||||
select *
|
select *
|
||||||
from pre_feature_flag_verification_requests
|
from pre_feature_flag_verification_requests
|
||||||
union all
|
|
||||||
select *
|
{%- if modules.datetime.datetime.now(
|
||||||
from post_feature_flag_verification_requests
|
modules.pytz.timezone("UTC")
|
||||||
|
) > modules.datetime.datetime.strptime(
|
||||||
|
var("guest_products_feature_flag_activation_timestamp"),
|
||||||
|
"'%Y-%m-%dT%H:%M:%S%z'",
|
||||||
|
) -%}
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from post_feature_flag_verification_requests
|
||||||
|
{% endif %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue