set references for v1

This commit is contained in:
Pablo Martin 2024-09-10 12:49:32 +02:00
parent 2cd115eede
commit f58e97a3f2
7 changed files with 60 additions and 36 deletions

View file

@ -1,6 +1,6 @@
with with
int_core__verification_payments as ( int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }} select * from {{ ref("int_core__verification_payments", version=1) }}
), ),
stg_core__guest_satisfaction_responses as ( stg_core__guest_satisfaction_responses as (
select * from {{ ref("stg_core__guest_satisfaction_responses") }} select * from {{ ref("stg_core__guest_satisfaction_responses") }}

View file

@ -9,7 +9,7 @@ with
select * from {{ ref("int_core__verification_requests") }} select * from {{ ref("int_core__verification_requests") }}
), ),
int_core__verification_payments as ( int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }} select * from {{ ref("int_core__verification_payments", version=1) }}
), ),
int_dates_by_deal as (select * from {{ ref("int_dates_by_deal") }}), int_dates_by_deal as (select * from {{ ref("int_dates_by_deal") }}),
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}), int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}),

View file

@ -13,7 +13,7 @@ with
select * from {{ ref("int_core__verification_requests") }} select * from {{ ref("int_core__verification_requests") }}
), ),
int_core__verification_payments as ( int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }} select * from {{ ref("int_core__verification_payments", version=1) }}
), ),
int_dates_by_deal as (select * from {{ ref("int_dates_by_deal") }}), int_dates_by_deal as (select * from {{ ref("int_dates_by_deal") }}),
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}), int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}),

View file

@ -2,7 +2,6 @@
This model provides Month-To-Date (MTD) based on Guest Journey metrics. This model provides Month-To-Date (MTD) based on Guest Journey metrics.
*/ */
{% set dimensions = get_kpi_dimensions() %} {% set dimensions = get_kpi_dimensions() %}
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} {{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
@ -12,14 +11,16 @@ with
select * from {{ ref("int_core__verification_requests") }} select * from {{ ref("int_core__verification_requests") }}
), ),
int_core__verification_payments as ( int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }} select * from {{ ref("int_core__verification_payments", version=1) }}
), ),
int_core__user_host as (select * from {{ ref("int_core__user_host") }}), int_core__user_host as (select * from {{ ref("int_core__user_host") }}),
int_core__mtd_accommodation_segmentation as ( int_core__mtd_accommodation_segmentation as (
select * from {{ ref("int_core__mtd_accommodation_segmentation") }} select * from {{ ref("int_core__mtd_accommodation_segmentation") }}
), ),
int_dates_mtd as (select * from {{ ref("int_dates_mtd") }}), int_dates_mtd as (select * from {{ ref("int_dates_mtd") }}),
int_dates_mtd_by_dimension as (select * from {{ ref("int_dates_mtd_by_dimension") }}), int_dates_mtd_by_dimension as (
select * from {{ ref("int_dates_mtd_by_dimension") }}
),
first_payment_per_verification_request as ( first_payment_per_verification_request as (
select select
@ -46,11 +47,13 @@ with
and extract(day from vr.created_date_utc) <= d.day and extract(day from vr.created_date_utc) <= d.day
{% if dimension.dimension == "'by_number_of_listings'" %} {% if dimension.dimension == "'by_number_of_listings'" %}
inner join int_core__user_host u on vr.id_user_host = u.id_user_host inner join int_core__user_host u on vr.id_user_host = u.id_user_host
inner join int_core__mtd_accommodation_segmentation mas inner join
int_core__mtd_accommodation_segmentation mas
on u.id_deal = mas.id_deal on u.id_deal = mas.id_deal
and d.date = mas.date and d.date = mas.date
{% elif dimension.dimension == "'by_billing_country'" %} {% elif dimension.dimension == "'by_billing_country'" %}
inner join int_core__user_host u inner join
int_core__user_host u
on vr.id_user_host = u.id_user_host on vr.id_user_host = u.id_user_host
and u.main_billing_country_iso_3_per_deal is not null and u.main_billing_country_iso_3_per_deal is not null
{% endif %} {% endif %}
@ -71,15 +74,19 @@ with
from int_dates_mtd d from int_dates_mtd d
inner join inner join
int_core__verification_requests vr int_core__verification_requests vr
on date_trunc('month', vr.verification_estimated_started_date_utc)::date = d.first_day_month on date_trunc('month', vr.verification_estimated_started_date_utc)::date
and extract(day from vr.verification_estimated_started_date_utc) <= d.day = d.first_day_month
and extract(day from vr.verification_estimated_started_date_utc)
<= d.day
{% if dimension.dimension == "'by_number_of_listings'" %} {% if dimension.dimension == "'by_number_of_listings'" %}
inner join int_core__user_host u on vr.id_user_host = u.id_user_host inner join int_core__user_host u on vr.id_user_host = u.id_user_host
inner join int_core__mtd_accommodation_segmentation mas inner join
int_core__mtd_accommodation_segmentation mas
on u.id_deal = mas.id_deal on u.id_deal = mas.id_deal
and d.date = mas.date and d.date = mas.date
{% elif dimension.dimension == "'by_billing_country'" %} {% elif dimension.dimension == "'by_billing_country'" %}
inner join int_core__user_host u inner join
int_core__user_host u
on vr.id_user_host = u.id_user_host on vr.id_user_host = u.id_user_host
and u.main_billing_country_iso_3_per_deal is not null and u.main_billing_country_iso_3_per_deal is not null
{% endif %} {% endif %}
@ -100,15 +107,21 @@ with
from int_dates_mtd d from int_dates_mtd d
inner join inner join
int_core__verification_requests vr int_core__verification_requests vr
on date_trunc('month', vr.verification_estimated_completed_date_utc)::date = d.first_day_month on date_trunc(
and extract(day from vr.verification_estimated_completed_date_utc) <= d.day 'month', vr.verification_estimated_completed_date_utc
)::date
= d.first_day_month
and extract(day from vr.verification_estimated_completed_date_utc)
<= d.day
{% if dimension.dimension == "'by_number_of_listings'" %} {% if dimension.dimension == "'by_number_of_listings'" %}
inner join int_core__user_host u on vr.id_user_host = u.id_user_host inner join int_core__user_host u on vr.id_user_host = u.id_user_host
inner join int_core__mtd_accommodation_segmentation mas inner join
int_core__mtd_accommodation_segmentation mas
on u.id_deal = mas.id_deal on u.id_deal = mas.id_deal
and d.date = mas.date and d.date = mas.date
{% elif dimension.dimension == "'by_billing_country'" %} {% elif dimension.dimension == "'by_billing_country'" %}
inner join int_core__user_host u inner join
int_core__user_host u
on vr.id_user_host = u.id_user_host on vr.id_user_host = u.id_user_host
and u.main_billing_country_iso_3_per_deal is not null and u.main_billing_country_iso_3_per_deal is not null
{% endif %} {% endif %}
@ -129,17 +142,24 @@ with
from int_dates_mtd d from int_dates_mtd d
inner join inner join
first_payment_per_verification_request p first_payment_per_verification_request p
on date_trunc('month', p.first_payment_paid_date_utc)::date = d.first_day_month on date_trunc('month', p.first_payment_paid_date_utc)::date
= d.first_day_month
and extract(day from p.first_payment_paid_date_utc) <= d.day and extract(day from p.first_payment_paid_date_utc) <= d.day
{% if dimension.dimension == "'by_number_of_listings'" %} {% if dimension.dimension == "'by_number_of_listings'" %}
inner join int_core__verification_requests vr on vr.id_verification_request = p.id_verification_request inner join
int_core__verification_requests vr
on vr.id_verification_request = p.id_verification_request
inner join int_core__user_host u on vr.id_user_host = u.id_user_host inner join int_core__user_host u on vr.id_user_host = u.id_user_host
inner join int_core__mtd_accommodation_segmentation mas inner join
int_core__mtd_accommodation_segmentation mas
on u.id_deal = mas.id_deal on u.id_deal = mas.id_deal
and d.date = mas.date and d.date = mas.date
{% elif dimension.dimension == "'by_billing_country'" %} {% elif dimension.dimension == "'by_billing_country'" %}
inner join int_core__verification_requests vr on vr.id_verification_request = p.id_verification_request inner join
inner join int_core__user_host u int_core__verification_requests vr
on vr.id_verification_request = p.id_verification_request
inner join
int_core__user_host u
on vr.id_user_host = u.id_user_host on vr.id_user_host = u.id_user_host
and u.main_billing_country_iso_3_per_deal is not null and u.main_billing_country_iso_3_per_deal is not null
{% endif %} {% endif %}
@ -188,7 +208,8 @@ left join
on d.date = coym.date on d.date = coym.date
and d.dimension = coym.dimension and d.dimension = coym.dimension
and d.dimension_value = coym.dimension_value and d.dimension_value = coym.dimension_value
left join paid_year_month pym left join
paid_year_month pym
on d.date = pym.date on d.date = pym.date
and d.dimension = pym.dimension and d.dimension = pym.dimension
and d.dimension_value = pym.dimension_value and d.dimension_value = pym.dimension_value

View file

@ -11,7 +11,7 @@ This model provides Month-To-Date (MTD) based on Guest Revenue metrics.
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }} {{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
with with
int_core__verification_payments as ( int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }} select * from {{ ref("int_core__verification_payments", version=1) }}
), ),
int_core__verification_requests as ( int_core__verification_requests as (
select * from {{ ref("int_core__verification_requests") }} select * from {{ ref("int_core__verification_requests") }}
@ -62,7 +62,8 @@ with
from int_dates_mtd d from int_dates_mtd d
inner join inner join
int_core__verification_payments vp int_core__verification_payments vp
on date_trunc('month', vp.payment_paid_date_utc)::date = d.first_day_month on date_trunc('month', vp.payment_paid_date_utc)::date
= d.first_day_month
and extract(day from vp.payment_paid_date_utc) <= d.day and extract(day from vp.payment_paid_date_utc) <= d.day
{% if dimension.dimension == "'by_number_of_listings'" %} {% if dimension.dimension == "'by_number_of_listings'" %}
inner join int_core__user_host u on vp.id_user_host = u.id_user_host inner join int_core__user_host u on vp.id_user_host = u.id_user_host
@ -71,7 +72,9 @@ with
on u.id_deal = mas.id_deal on u.id_deal = mas.id_deal
and d.date = mas.date and d.date = mas.date
{% elif dimension.dimension == "'by_billing_country'" %} {% elif dimension.dimension == "'by_billing_country'" %}
inner join int_core__user_host u on vp.id_user_host = u.id_user_host inner join
int_core__user_host u
on vp.id_user_host = u.id_user_host
and u.main_billing_country_iso_3_per_deal is not null and u.main_billing_country_iso_3_per_deal is not null
{% endif %} {% endif %}
where upper(vp.payment_status) = {{ var("paid_payment_state") }} where upper(vp.payment_status) = {{ var("paid_payment_state") }}

View file

@ -18,7 +18,7 @@ with
amount_in_gbp, amount_in_gbp,
payment_status, payment_status,
payment_paid_date_utc payment_paid_date_utc
from {{ ref("int_core__verification_payments") }} from {{ ref("int_core__verification_payments", version=1) }}
where where
verification_payment_type = 'CheckInCover' -- 5 is check-in cover verification_payment_type = 'CheckInCover' -- 5 is check-in cover
and payment_status in ('Paid', 'Refunded') and payment_status in ('Paid', 'Refunded')

View file

@ -1,6 +1,6 @@
with with
int_core__verification_payments as ( int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }} select * from {{ ref("int_core__verification_payments", version=1) }}
) )
select select
vp.id_verification_to_payment as id_verification_to_payment, vp.id_verification_to_payment as id_verification_to_payment,