Merged PR 5131: Remove old models
# Description Remove old models: - `monthly_aggregated_metrics_history_by_deal` - `int_monthly_aggregated_metrics_history_by_deal` # Checklist - [ ] The edited models and dependants run properly with production data. - [ ] The edited models are sufficiently documented. - [ ] 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. Remove old models Related work items: #29672
This commit is contained in:
commit
fb3a8c7bfa
4 changed files with 0 additions and 739 deletions
|
|
@ -1,307 +0,0 @@
|
|||
/*
|
||||
This model aggregates the different metrics by deal for those hosts that have it assigned.
|
||||
|
||||
*/
|
||||
with
|
||||
int_kpis__dimension_deals as (select * from {{ ref("int_kpis__dimension_deals") }}),
|
||||
int_kpis__agg_dates_main_kpis as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_dates_main_kpis") }}
|
||||
where
|
||||
dimension in ('by_deal')
|
||||
and dimension_value <> 'UNSET'
|
||||
and is_end_of_month = true
|
||||
),
|
||||
daily_deal_lifecycle as (select * from {{ ref("int_kpis__lifecycle_daily_deal") }}),
|
||||
int_kpis__dimension_daily_accommodation as (
|
||||
select * from {{ ref("int_kpis__dimension_daily_accommodation") }}
|
||||
),
|
||||
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 *
|
||||
from {{ ref("int_kpis__agg_monthly_created_bookings") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
check_out_bookings as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_check_out_bookings") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
billable_bookings as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_billable_bookings") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
created_guest_journeys as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_created_guest_journeys") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
started_guest_journeys as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_started_guest_journeys") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
completed_guest_journeys as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_completed_guest_journeys") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
guest_journeys_with_payment as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_guest_journeys_with_payment") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
guest_payments as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_guest_payments") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
invoiced_revenue as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_invoiced_revenue") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
host_resolutions as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_host_resolutions") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
),
|
||||
total_and_retained_revenue as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_total_and_retained_revenue") }}
|
||||
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||
)
|
||||
|
||||
select
|
||||
d.year,
|
||||
d.month,
|
||||
d.day,
|
||||
d.date,
|
||||
-- DEAL STATIC ATTRIBUTES --
|
||||
ikdd.id_deal,
|
||||
ikdd.client_type,
|
||||
ikdd.main_deal_name,
|
||||
ikdd.has_active_pms,
|
||||
ikdd.active_pms_list,
|
||||
coalesce(
|
||||
dda.active_accommodations_per_deal_segmentation, 'UNSET'
|
||||
) as active_accommodations_per_deal_segmentation,
|
||||
ikdd.main_billing_country_iso_3_per_deal,
|
||||
-- DEAL BUSINESS SCOPE
|
||||
case
|
||||
when ikdd.client_type = 'API'
|
||||
then 'API'
|
||||
when ikdd.client_type = 'PLATFORM'
|
||||
then
|
||||
case
|
||||
when
|
||||
ikdd.id_deal is not null
|
||||
and d.date >= ikdd.min_user_in_new_dash_since_date_utc
|
||||
then 'New Dash'
|
||||
else 'Old Dash'
|
||||
end
|
||||
else 'UNSET'
|
||||
end as business_scope,
|
||||
|
||||
-- DEAL LIFECYCLE --
|
||||
daily_deal_lifecycle.deal_lifecycle_state,
|
||||
|
||||
-- CREATED BOOKINGS --
|
||||
created_bookings.created_bookings,
|
||||
created_bookings.cancelled_created_bookings,
|
||||
created_bookings.not_cancelled_created_bookings,
|
||||
created_bookings.cancelled_created_bookings_rate,
|
||||
|
||||
-- CHECK OUT BOOKINGS --
|
||||
check_out_bookings.check_out_bookings,
|
||||
check_out_bookings.cancelled_check_out_bookings,
|
||||
check_out_bookings.not_cancelled_check_out_bookings,
|
||||
check_out_bookings.billable_check_out_bookings,
|
||||
check_out_bookings.cancelled_check_out_bookings_rate,
|
||||
|
||||
-- OTHER BOOKINGS --
|
||||
billable_bookings.billable_bookings,
|
||||
|
||||
-- GUEST JOURNEYS --
|
||||
created_guest_journeys.created_guest_journeys,
|
||||
started_guest_journeys.started_guest_journeys,
|
||||
completed_guest_journeys.completed_guest_journeys,
|
||||
guest_journeys_with_payment.guest_journeys_with_payment as paid_guest_journeys,
|
||||
cast(started_guest_journeys.started_guest_journeys as decimal)
|
||||
/ created_guest_journeys.created_guest_journeys as start_rate_guest_journey,
|
||||
cast(completed_guest_journeys.completed_guest_journeys as decimal)
|
||||
/ started_guest_journeys.started_guest_journeys as completion_rate_guest_journey,
|
||||
1
|
||||
- cast(completed_guest_journeys.completed_guest_journeys as decimal)
|
||||
/ started_guest_journeys.started_guest_journeys as incompletion_rate_guest_journey,
|
||||
cast(guest_journeys_with_payment.guest_journeys_with_payment as decimal)
|
||||
/ completed_guest_journeys.completed_guest_journeys as payment_rate_guest_journey,
|
||||
|
||||
-- LISTINGS --
|
||||
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 --
|
||||
-- OLD DASH --
|
||||
invoiced_revenue.xero_old_dashboard_booking_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_listing_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_verification_net_fees_in_gbp,
|
||||
-- NEW DASH --
|
||||
invoiced_revenue.xero_basic_protection_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_waiver_pro_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_id_verification_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_protection_plus_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_screening_plus_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_sex_offenders_check_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_protection_pro_net_fees_in_gbp,
|
||||
-- GLOBAL --
|
||||
invoiced_revenue.xero_booking_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_operator_net_fees_in_gbp,
|
||||
|
||||
-- APIs REVENUE --
|
||||
invoiced_revenue.xero_apis_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_e_deposit_net_fees_in_gbp,
|
||||
invoiced_revenue.xero_guesty_net_fees_in_gbp,
|
||||
|
||||
-- HOST RESOLUTIONS --
|
||||
host_resolutions.xero_host_resolution_amount_paid_in_gbp,
|
||||
host_resolutions.xero_host_resolution_payment_count,
|
||||
cast(host_resolutions.xero_host_resolution_amount_paid_in_gbp as decimal)
|
||||
/ created_bookings.created_bookings
|
||||
as host_resolution_amount_paid_per_created_booking,
|
||||
{{
|
||||
return_capped_value(
|
||||
"cast(host_resolutions.xero_host_resolution_payment_count as decimal)/created_bookings.created_bookings",
|
||||
-1,
|
||||
1,
|
||||
)
|
||||
}}
|
||||
as host_resolution_payment_per_created_booking_ratio,
|
||||
|
||||
-- GUEST REVENUE AND PAYMENTS --
|
||||
guest_payments.deposit_fees_in_gbp,
|
||||
guest_payments.waiver_payments_in_gbp,
|
||||
invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp,
|
||||
nullif(
|
||||
coalesce(guest_payments.waiver_payments_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0),
|
||||
0
|
||||
) as waiver_net_fees_in_gbp,
|
||||
guest_payments.checkin_cover_fees_in_gbp,
|
||||
guest_payments.total_guest_payments_in_gbp,
|
||||
|
||||
-- TOTAL REVENUE --
|
||||
total_and_retained_revenue.total_revenue_in_gbp,
|
||||
|
||||
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
|
||||
guest_payments.total_guest_payments_in_gbp / nullif(
|
||||
completed_guest_journeys.completed_guest_journeys, 0
|
||||
) as guest_payments_per_completed_guest_journey,
|
||||
guest_payments.total_guest_payments_in_gbp / nullif(
|
||||
guest_journeys_with_payment.guest_journeys_with_payment, 0
|
||||
) as guest_payments_per_paid_guest_journey,
|
||||
|
||||
-- TOTAL REVENUE WEIGHTED METRICS --
|
||||
coalesce(total_and_retained_revenue.total_revenue_in_gbp, 0)
|
||||
/ nullif(created_bookings.created_bookings, 0) as total_revenue_per_created_booking,
|
||||
coalesce(total_and_retained_revenue.total_revenue_in_gbp, 0) / nullif(
|
||||
created_guest_journeys.created_guest_journeys, 0
|
||||
) as total_revenue_per_created_guest_journey,
|
||||
coalesce(total_and_retained_revenue.total_revenue_in_gbp, 0) / nullif(
|
||||
listings.listings_booked_in_month, 0
|
||||
) as total_revenue_per_listings_booked_in_month,
|
||||
|
||||
-- INCOME RETAINED --
|
||||
total_and_retained_revenue.revenue_retained_in_gbp,
|
||||
{{
|
||||
return_capped_value(
|
||||
"total_and_retained_revenue.revenue_retained_in_gbp/total_and_retained_revenue.total_revenue_in_gbp",
|
||||
-1,
|
||||
1,
|
||||
)
|
||||
}}
|
||||
as revenue_retained_ratio,
|
||||
|
||||
-- INCOME RETAINED POST RESOLUTIONS--
|
||||
total_and_retained_revenue.revenue_retained_post_resolutions_in_gbp,
|
||||
{{
|
||||
return_capped_value(
|
||||
"total_and_retained_revenue.revenue_retained_post_resolutions_in_gbp/total_and_retained_revenue.total_revenue_in_gbp",
|
||||
-1,
|
||||
1,
|
||||
)
|
||||
}}
|
||||
as revenue_retained_post_resolutions_ratio
|
||||
|
||||
from int_kpis__agg_dates_main_kpis d
|
||||
left join int_kpis__dimension_deals ikdd on d.dimension_value = ikdd.id_deal
|
||||
left join
|
||||
daily_deal_lifecycle
|
||||
on d.date = daily_deal_lifecycle.date
|
||||
and d.dimension_value = daily_deal_lifecycle.id_deal
|
||||
left join
|
||||
int_kpis__dimension_daily_accommodation as dda
|
||||
on d.date = dda.date
|
||||
and d.dimension_value = dda.id_deal
|
||||
left join
|
||||
created_bookings
|
||||
on d.date = created_bookings.end_date
|
||||
and d.dimension_value = created_bookings.dimension_value
|
||||
left join
|
||||
check_out_bookings
|
||||
on d.date = check_out_bookings.end_date
|
||||
and d.dimension_value = check_out_bookings.dimension_value
|
||||
left join
|
||||
billable_bookings
|
||||
on d.date = billable_bookings.end_date
|
||||
and d.dimension_value = billable_bookings.dimension_value
|
||||
left join
|
||||
created_guest_journeys
|
||||
on d.date = created_guest_journeys.end_date
|
||||
and d.dimension_value = created_guest_journeys.dimension_value
|
||||
left join
|
||||
started_guest_journeys
|
||||
on d.date = started_guest_journeys.end_date
|
||||
and d.dimension_value = started_guest_journeys.dimension_value
|
||||
left join
|
||||
completed_guest_journeys
|
||||
on d.date = completed_guest_journeys.end_date
|
||||
and d.dimension_value = completed_guest_journeys.dimension_value
|
||||
left join
|
||||
guest_journeys_with_payment
|
||||
on d.date = guest_journeys_with_payment.end_date
|
||||
and d.dimension_value = guest_journeys_with_payment.dimension_value
|
||||
left join
|
||||
guest_payments
|
||||
on d.date = guest_payments.end_date
|
||||
and d.dimension_value = guest_payments.dimension_value
|
||||
left join
|
||||
listings on d.date = listings.date and d.dimension_value = listings.dimension_value
|
||||
left join
|
||||
invoiced_revenue
|
||||
on d.date = invoiced_revenue.end_date
|
||||
and d.dimension_value = invoiced_revenue.dimension_value
|
||||
left join
|
||||
host_resolutions
|
||||
on d.date = host_resolutions.end_date
|
||||
and d.dimension_value = host_resolutions.dimension_value
|
||||
left join
|
||||
total_and_retained_revenue
|
||||
on d.date = total_and_retained_revenue.end_date
|
||||
and d.dimension_value = total_and_retained_revenue.dimension_value
|
||||
|
|
@ -350,108 +350,6 @@ models:
|
|||
positive impact for Superhog, otherwise is equal to relative_increment.
|
||||
This value is specially created for formatting in PBI
|
||||
|
||||
- name: int_monthly_aggregated_metrics_history_by_deal
|
||||
deprecation_date: 2025-04-28 08:00:00
|
||||
description: |
|
||||
This model aggregates the monthly historic information regarding the different metrics computed
|
||||
at deal level. The primary sources of data are the `int_yyy__monthly_XXXXX_history_by_deal`
|
||||
models which contain the raw metrics data per source.
|
||||
|
||||
Unlike the int_mtd_aggregated_metrics, this model does not abstract each metric, since
|
||||
no comparison versus last year is performed. In short, it just gathers the information stored
|
||||
in the abovementioned models.
|
||||
|
||||
To keep in mind: aggregating the information of this model will not necessarily result into
|
||||
the int_mtd_aggregated metrics because 1) the mtd version contains more computing dates
|
||||
than the by deal version, the latest being a subset of the first, and 2) the deal based model
|
||||
enforces that a booking/guest journey/listing/etc has a host with a deal assigned, which is
|
||||
not necessarily the case.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- id_deal
|
||||
|
||||
columns:
|
||||
- name: date
|
||||
data_type: date
|
||||
description: The last day of the month or yesterday for historic metrics.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: character varying
|
||||
description: Id of the deal associated to the host.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: client_type
|
||||
data_type: string
|
||||
description: |
|
||||
Type of client. It can be either PLATFORM or API.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- PLATFORM
|
||||
- API
|
||||
|
||||
- name: business_scope
|
||||
data_type: string
|
||||
description: |
|
||||
Business scope identifying the metric source.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "Old Dash"
|
||||
- "New Dash"
|
||||
- "API"
|
||||
- "UNSET"
|
||||
|
||||
- name: main_deal_name
|
||||
data_type: string
|
||||
description: |
|
||||
Main name for this ID deal.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: has_active_pms
|
||||
data_type: boolean
|
||||
description: |
|
||||
Does the deal have an active associated PMS.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: active_pms_list
|
||||
data_type: string
|
||||
description: |
|
||||
Name of the active PMS associated with the deal. It can have more than
|
||||
one PMS associated with it. It can be null if it doesn't have any PMS associated.
|
||||
|
||||
- name: active_accommodations_per_deal_segmentation
|
||||
data_type: string
|
||||
description: |
|
||||
Segment value based on the number of listings booked in 12 months
|
||||
for a given deal and date.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "0"
|
||||
- "01-05"
|
||||
- "06-20"
|
||||
- "21-60"
|
||||
- "61+"
|
||||
- "UNSET"
|
||||
|
||||
- name: main_billing_country_iso_3_per_deal
|
||||
data_type: string
|
||||
description: |
|
||||
ISO 3166-1 alpha-3 main country code in which the Deal is billed.
|
||||
In some cases it's null.
|
||||
|
||||
- name: int_monthly_growth_score_by_deal
|
||||
deprecation_date: 2025-05-23 08:00:00
|
||||
description: |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue