monthly and weekly metric models

This commit is contained in:
Joaquin Ossa 2024-11-07 08:45:17 +01:00
parent 8c23f91242
commit cf553cfcb1
4 changed files with 185 additions and 4 deletions

View file

@ -4,6 +4,7 @@
unique_key=[
"end_date",
"id_deal",
"has_id_check",
"active_accommodations_per_deal_segmentation",
],
)
@ -14,6 +15,7 @@ select
d.first_day_month as start_date,
d.date as end_date,
gp.id_deal,
gp.has_id_check,
gp.active_accommodations_per_deal_segmentation,
-- Dimensions --
gp.main_billing_country_iso_3_per_deal,
@ -27,4 +29,4 @@ left join
{{ ref("int_kpis__metric_daily_guest_payments") }} gp
on date_trunc('month', gp.date)::date = d.first_day_month
where d.is_end_of_month = true and gp.id_deal is not null
group by 1, 2, 3, 4, 5
group by 1, 2, 3, 4, 5, 6

View file

@ -4,6 +4,7 @@
unique_key=[
"end_date",
"id_deal",
"has_id_check",
"active_accommodations_per_deal_segmentation",
],
)
@ -14,6 +15,7 @@ select
d.first_day_month as start_date,
d.date as end_date,
gp.id_deal,
gp.has_id_check,
gp.active_accommodations_per_deal_segmentation,
-- Dimensions --
gp.main_billing_country_iso_3_per_deal,
@ -28,4 +30,4 @@ left join
on date_trunc('month', gp.date)::date = d.first_day_month
and extract(day from gp.date) <= d.day
where d.is_month_to_date = true and gp.id_deal is not null
group by 1, 2, 3, 4, 5
group by 1, 2, 3, 4, 5, 6

View file

@ -0,0 +1,33 @@
{{
config(
materialized="view",
unique_key=[
"end_date",
"id_deal",
"has_id_check",
"active_accommodations_per_deal_segmentation",
],
)
}}
select
-- Unique Key --
d.first_day_week as start_date,
d.date as end_date,
d.week,
gp.id_deal,
gp.has_id_check,
gp.active_accommodations_per_deal_segmentation,
-- Dimensions --
gp.main_billing_country_iso_3_per_deal,
-- Metrics --
sum(gp.deposit_fees_in_gbp) as deposit_fees_in_gbp,
sum(gp.waiver_payments_in_gbp) as waiver_payments_in_gbp,
sum(gp.checkin_cover_fees_in_gbp) as checkin_cover_fees_in_gbp,
sum(gp.total_guest_payments_in_gbp) as total_guest_payments_in_gbp
from {{ ref("int_kpis__dimension_dates") }} d
left join
{{ ref("int_kpis__metric_daily_guest_payments") }} gp
on date_trunc('week', gp.date)::date = d.first_day_week
where d.is_end_of_week = true and gp.id_deal is not null
group by 1, 2, 3, 4, 5, 6, 7

View file

@ -1957,6 +1957,17 @@ models:
tests:
- not_null
- name: has_id_check
data_type: string
description: Does the verification in the guest journey
includes Government Id Check for the bookings.
tests:
- not_null
- accepted_values:
values:
- W/O Id Check
- With Id Check
- name: active_accommodations_per_deal_segmentation
data_type: string
description: |
@ -2014,7 +2025,8 @@ models:
The unique key corresponds to:
- end_date,
- id_deal,
- id_deal,
- has_id_check,
- active_accommodations_per_deal_segmentation.
tests:
@ -2022,6 +2034,7 @@ models:
combination_of_columns:
- end_date
- id_deal
- has_id_check
- active_accommodations_per_deal_segmentation
columns:
@ -2045,6 +2058,17 @@ models:
tests:
- not_null
- name: has_id_check
data_type: string
description: Does the verification in the guest journey
includes Government Id Check for the bookings.
tests:
- not_null
- accepted_values:
values:
- W/O Id Check
- With Id Check
- name: active_accommodations_per_deal_segmentation
data_type: string
description: |
@ -2102,7 +2126,8 @@ models:
The unique key corresponds to:
- end_date,
- id_deal,
- id_deal,
- has_id_check,
- active_accommodations_per_deal_segmentation.
tests:
@ -2110,6 +2135,7 @@ models:
combination_of_columns:
- end_date
- id_deal
- has_id_check
- active_accommodations_per_deal_segmentation
columns:
@ -2133,6 +2159,17 @@ models:
tests:
- not_null
- name: has_id_check
data_type: string
description: Does the verification in the guest journey
includes Government Id Check for the bookings.
tests:
- not_null
- accepted_values:
values:
- W/O Id Check
- With Id Check
- name: active_accommodations_per_deal_segmentation
data_type: string
description: |
@ -2180,6 +2217,113 @@ models:
Sum of accumulated total payments paid by guests, without taxes,
in GBP in a given month up to the given date and per specified dimension.
- name: int_kpis__metric_weekly_guest_payments
description: |
This model computes the Weekly Guest Payments at the
deepest granularity.
Be aware that any dimension that can change over the monthly period,
such as daily segmentations, are included in the primary key of the
model.
The unique key corresponds to:
- end_date,
- id_deal,
- has_id_check,
- active_accommodations_per_deal_segmentation.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- end_date
- id_deal
- has_id_check
- active_accommodations_per_deal_segmentation
columns:
- name: start_date
data_type: date
description: |
The start date of the time range considered for the metrics in this record.
tests:
- not_null
- name: end_date
data_type: date
description: |
The end date of the time range considered for the metrics in this record.
tests:
- not_null
- name: week
data_type: int
description: ISO week number of the given date.
tests:
- not_null
- name: id_deal
data_type: string
description: Unique identifier of an account.
tests:
- not_null
- name: has_id_check
data_type: string
description: Does the verification in the guest journey
includes Government Id Check for the bookings.
tests:
- not_null
- accepted_values:
values:
- W/O Id Check
- With Id Check
- 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.
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: |
Main billing country of the host aggregated at Deal level.
tests:
- not_null
- name: deposit_fees_in_gbp
data_type: decimal
description: |
Sum of accumulated deposit fees paid by guests, without taxes,
in GBP in a given week up to the given date and per specified dimension.
- name: waiver_payments_in_gbp
data_type: decimal
description: |
Sum of accumulated waiver payments paid by guests, without taxes,
in GBP in a given week up to the given date and per specified dimension.
- name: checkin_cover_fees_in_gbp
data_type: decimal
description: |
Sum of accumulated checkin cover fees by guests, without taxes,
in GBP in a given week up to the given date and per specified dimension.
- name: total_guest_payments_in_gbp
data_type: decimal
description: |
Sum of accumulated total payments paid by guests, without taxes,
in GBP in a given week up to the given date and per specified dimension.
- name: int_kpis__agg_monthly_guest_payments
description: |
This model computes the dimension aggregation for