Merged PR 3469: Switches Listing and Deal metrics
# Description Switches Listings and Deal metrics to production. I also modified the dependencies on the old lifecycles to read from the news, so we can remove these in a following PR. I'm considering re-computing also the dimension - specific models to operate within KPIs folder, but will do this later on in a dedicated PR. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [ ] I have checked for DRY opportunities with other models and docs. - [ ] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #23761
This commit is contained in:
parent
335ba9a29b
commit
5e1b418570
4 changed files with 63 additions and 49 deletions
|
|
@ -3,8 +3,8 @@
|
|||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
with
|
||||
int_core__mtd_accommodation_segmentation as (
|
||||
select * from {{ ref("int_core__mtd_accommodation_segmentation") }}
|
||||
int_kpis__dimension_daily_accommodation as (
|
||||
select * from {{ ref("int_kpis__dimension_daily_accommodation") }}
|
||||
),
|
||||
int_core__user_host as (select * from {{ ref("int_core__user_host") }}),
|
||||
int_dates_mtd as (select * from {{ ref("int_dates_mtd") }})
|
||||
|
|
@ -23,7 +23,7 @@ with
|
|||
d.is_current_month
|
||||
from int_dates_mtd d
|
||||
{% if dimension.dimension == "'by_number_of_listings'" %}
|
||||
inner join int_core__mtd_accommodation_segmentation a on d.date = a.date
|
||||
inner join int_kpis__dimension_daily_accommodation a on d.date = a.date
|
||||
{% elif dimension.dimension == "'by_billing_country'" %}
|
||||
inner join
|
||||
int_core__user_host h
|
||||
|
|
|
|||
|
|
@ -4,9 +4,14 @@ This model aggregates the different metrics by deal for those hosts that have it
|
|||
*/
|
||||
with
|
||||
int_dates_by_deal as (select * from {{ ref("int_dates_by_deal") }}),
|
||||
int_mtd_deal_lifecycle as (select * from {{ ref("int_mtd_deal_lifecycle") }}),
|
||||
int_core__monthly_accommodation_history_by_deal as (
|
||||
select * from {{ ref("int_core__monthly_accommodation_history_by_deal") }}
|
||||
daily_deal_lifecycle as (select * from {{ ref("int_kpis__lifecycle_daily_deal") }}),
|
||||
listings as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_daily_listings") }}
|
||||
where
|
||||
dimension in ('by_deal')
|
||||
and dimension_value <> 'UNSET'
|
||||
and is_end_of_month = true
|
||||
),
|
||||
created_bookings as (
|
||||
select *
|
||||
|
|
@ -74,7 +79,7 @@ select
|
|||
d.main_billing_country_iso_3_per_deal,
|
||||
|
||||
-- DEAL LIFECYCLE --
|
||||
deal_lifecycle.deal_lifecycle_state,
|
||||
daily_deal_lifecycle.deal_lifecycle_state,
|
||||
|
||||
-- BOOKINGS --
|
||||
created_bookings.created_bookings,
|
||||
|
|
@ -98,16 +103,16 @@ select
|
|||
/ completed_guest_journeys.completed_guest_journeys as payment_rate_guest_journey,
|
||||
|
||||
-- LISTINGS --
|
||||
accommodations.new_listings,
|
||||
accommodations.never_booked_listings,
|
||||
accommodations.first_time_booked_listings,
|
||||
accommodations.active_listings,
|
||||
accommodations.churning_listings,
|
||||
accommodations.inactive_listings,
|
||||
accommodations.reactivated_listings,
|
||||
accommodations.listings_booked_in_month,
|
||||
accommodations.listings_booked_in_6_months,
|
||||
accommodations.listings_booked_in_12_months,
|
||||
listings.new_listings,
|
||||
listings.never_booked_listings,
|
||||
listings.first_time_booked_listings,
|
||||
listings.active_listings,
|
||||
listings.churning_listings,
|
||||
listings.inactive_listings,
|
||||
listings.reactivated_listings,
|
||||
listings.listings_booked_in_month,
|
||||
listings.listings_booked_in_6_months,
|
||||
listings.listings_booked_in_12_months,
|
||||
|
||||
-- HOST (OPERATOR) REVENUE --
|
||||
invoiced_revenue.xero_booking_net_fees_in_gbp,
|
||||
|
|
@ -171,14 +176,14 @@ select
|
|||
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
|
||||
) / nullif(
|
||||
accommodations.listings_booked_in_month, 0
|
||||
listings.listings_booked_in_month, 0
|
||||
) as total_revenue_per_listings_booked_in_month
|
||||
|
||||
from int_dates_by_deal d
|
||||
left join
|
||||
int_mtd_deal_lifecycle deal_lifecycle
|
||||
on d.date = deal_lifecycle.date
|
||||
and d.id_deal = deal_lifecycle.id_deal
|
||||
daily_deal_lifecycle
|
||||
on d.date = daily_deal_lifecycle.date
|
||||
and d.id_deal = daily_deal_lifecycle.id_deal
|
||||
left join
|
||||
created_bookings
|
||||
on d.date = created_bookings.end_date
|
||||
|
|
@ -215,10 +220,7 @@ left join
|
|||
guest_payments
|
||||
on d.date = guest_payments.end_date
|
||||
and d.id_deal = guest_payments.dimension_value
|
||||
left join
|
||||
int_core__monthly_accommodation_history_by_deal accommodations
|
||||
on d.date = accommodations.date
|
||||
and d.id_deal = accommodations.id_deal
|
||||
left join listings on d.date = listings.date and d.id_deal = listings.dimension_value
|
||||
left join
|
||||
invoiced_revenue
|
||||
on d.date = invoiced_revenue.end_date
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ with
|
|||
int_dates_mtd_by_dimension as (
|
||||
select * from {{ ref("int_dates_mtd_by_dimension") }}
|
||||
),
|
||||
int_core__mtd_accommodation_segmentation as (
|
||||
select * from {{ ref("int_core__mtd_accommodation_segmentation") }}
|
||||
int_kpis__dimension_daily_accommodation as (
|
||||
select * from {{ ref("int_kpis__dimension_daily_accommodation") }}
|
||||
),
|
||||
int_core__deal as (select * from {{ ref("int_core__deal") }}),
|
||||
churn_metrics_per_date as (
|
||||
|
|
@ -43,9 +43,9 @@ with
|
|||
from int_monthly_12m_window_contribution_by_deal m12wc
|
||||
{% if dimension.dimension == "'by_number_of_listings'" %}
|
||||
inner join
|
||||
int_core__mtd_accommodation_segmentation mas
|
||||
on m12wc.id_deal = mas.id_deal
|
||||
and m12wc.date = mas.date
|
||||
int_kpis__dimension_daily_accommodation dda
|
||||
on m12wc.id_deal = dda.id_deal
|
||||
and m12wc.date = dda.date
|
||||
{% elif dimension.dimension == "'by_billing_country'" %}
|
||||
inner join
|
||||
int_core__deal ud
|
||||
|
|
|
|||
|
|
@ -108,10 +108,22 @@ with
|
|||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
int_core__mtd_accommodation_metrics as (
|
||||
select * from {{ ref("int_core__mtd_accommodation_metrics") }}
|
||||
listings as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_daily_listings") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
and dimension_value <> 'UNSET'
|
||||
and (is_month_to_date = true or is_end_of_month = true)
|
||||
),
|
||||
deals as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_daily_deals") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
and dimension_value <> 'UNSET'
|
||||
and (is_month_to_date = true or is_end_of_month = true)
|
||||
),
|
||||
int_mtd_deal_metrics as (select * from {{ ref("int_mtd_deal_metrics") }}),
|
||||
guest_payments as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_guest_payments") }}
|
||||
|
|
@ -207,16 +219,16 @@ with
|
|||
deals.deals_booked_in_12_months,
|
||||
|
||||
-- LISTINGS (ACCOMMODATIONS) --
|
||||
accommodations.new_listings,
|
||||
accommodations.never_booked_listings,
|
||||
accommodations.first_time_booked_listings,
|
||||
accommodations.active_listings,
|
||||
accommodations.churning_listings,
|
||||
accommodations.inactive_listings,
|
||||
accommodations.reactivated_listings,
|
||||
accommodations.listings_booked_in_month,
|
||||
accommodations.listings_booked_in_6_months,
|
||||
accommodations.listings_booked_in_12_months,
|
||||
listings.new_listings,
|
||||
listings.never_booked_listings,
|
||||
listings.first_time_booked_listings,
|
||||
listings.active_listings,
|
||||
listings.churning_listings,
|
||||
listings.inactive_listings,
|
||||
listings.reactivated_listings,
|
||||
listings.listings_booked_in_month,
|
||||
listings.listings_booked_in_6_months,
|
||||
listings.listings_booked_in_12_months,
|
||||
|
||||
-- HOST (OPERATOR) REVENUE --
|
||||
invoiced_revenue.xero_booking_net_fees_in_gbp,
|
||||
|
|
@ -288,7 +300,7 @@ with
|
|||
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
|
||||
) / nullif(
|
||||
accommodations.listings_booked_in_month, 0
|
||||
listings.listings_booked_in_month, 0
|
||||
) as total_revenue_per_listings_booked_in_month,
|
||||
|
||||
-- CHURN --
|
||||
|
|
@ -338,12 +350,12 @@ with
|
|||
and d.dimension = guest_journeys_with_payment.dimension
|
||||
and d.dimension_value = guest_journeys_with_payment.dimension_value
|
||||
left join
|
||||
int_core__mtd_accommodation_metrics accommodations
|
||||
on d.date = accommodations.date
|
||||
and d.dimension = accommodations.dimension
|
||||
and d.dimension_value = accommodations.dimension_value
|
||||
listings
|
||||
on d.date = listings.date
|
||||
and d.dimension = listings.dimension
|
||||
and d.dimension_value = listings.dimension_value
|
||||
left join
|
||||
int_mtd_deal_metrics deals
|
||||
deals
|
||||
on d.date = deals.date
|
||||
and d.dimension = deals.dimension
|
||||
and d.dimension_value = deals.dimension_value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue