Merged PR 2179: Computes aggregated metrics by deal id and exposes it to reporting
This PR creates 2 new models: - `int_core__monthly_aggregated_metrics_history_by_deal`, which just gathers the information of the previously created models that compute the kpis by deal id. - `core__monthly_aggregated_metrics_history_by_deal`, effectively a copy from intermediate to reporting It also includes documentation of these 2 models, differences between these and the `mtd_aggregated_metrics` equivalents and references it to exposures. I took the opportunity to update the documentation of the `core__mtd_aggregated_metrics` now that it's a bit more mature. This should be the last PR for the first draft of 'by deal' metrics. Related work items: #17689
This commit is contained in:
parent
f9741d6f69
commit
ed5d7828a7
5 changed files with 205 additions and 25 deletions
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
This model aggregates the different metrics by deal for those hosts that have it assigned.
|
||||
|
||||
*/
|
||||
|
||||
with
|
||||
int_dates_by_deal as (select * from {{ ref("int_dates_by_deal") }}),
|
||||
int_core__mtd_deal_lifecycle as (select * from {{ ref("int_core__mtd_deal_lifecycle") }}),
|
||||
int_core__monthly_guest_journey_history_by_deal as (select * from {{ ref("int_core__monthly_guest_journey_history_by_deal") }}),
|
||||
int_core__monthly_accommodation_history_by_deal as (select * from {{ ref("int_core__monthly_accommodation_history_by_deal") }}),
|
||||
int_core__monthly_booking_history_by_deal as (select * from {{ ref("int_core__monthly_booking_history_by_deal") }})
|
||||
|
||||
select
|
||||
d.year,
|
||||
d.month,
|
||||
d.day,
|
||||
d.date,
|
||||
d.id_deal,
|
||||
l.deal_lifecycle_state,
|
||||
b.created_bookings,
|
||||
b.check_out_bookings,
|
||||
b.cancelled_bookings,
|
||||
gj.created_guest_journeys,
|
||||
gj.started_guest_journeys,
|
||||
gj.completed_guest_journeys,
|
||||
gj.start_rate_guest_journey,
|
||||
gj.completion_rate_guest_journey,
|
||||
gj.incompletion_rate_guest_journey,
|
||||
a.new_listings,
|
||||
a.first_time_booked_listings,
|
||||
a.churning_listings,
|
||||
a.listings_booked_in_month,
|
||||
a.listings_booked_in_6_months,
|
||||
a.listings_booked_in_12_months
|
||||
from int_dates_by_deal d
|
||||
left join int_core__mtd_deal_lifecycle l
|
||||
on d.date = l.date
|
||||
and d.id_deal = l.id_deal
|
||||
left join int_core__monthly_booking_history_by_deal b
|
||||
on d.date = b.date
|
||||
and d.id_deal = b.id_deal
|
||||
left join int_core__monthly_guest_journey_history_by_deal gj
|
||||
on d.date = gj.date
|
||||
and d.id_deal = gj.id_deal
|
||||
left join int_core__monthly_accommodation_history_by_deal a
|
||||
on d.date = a.date
|
||||
and d.id_deal = a.id_deal
|
||||
|
||||
|
||||
|
|
@ -143,6 +143,41 @@ models:
|
|||
- not_null
|
||||
- unique
|
||||
|
||||
- name: int_core__monthly_aggregated_metrics_history_by_deal
|
||||
description: |
|
||||
This model aggregates the monthly historic information regarding the different metrics computed
|
||||
at deal level. The primary sources of data are the `int_core__monthly_XXXXX_history_by_deal`
|
||||
models which contain the raw metrics data per source.
|
||||
|
||||
Unlike the int_core__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_core__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.
|
||||
|
||||
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.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: character varying
|
||||
description: Id of the deal associated to the host.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: int_core__monthly_accommodation_history_by_deal
|
||||
description: |
|
||||
This model contains the historic information regarding the accommodations, also known
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue