Merged PR 3419: Adds Host Resolutions metrics in new KPIs

# Description

Adds 2 new metrics:
- xero_host_resolution_amount_paid_in_gbp
- xero_host_resolution_payment_count

Effectively it will split the "real" invoicing sources of revenue from "host resolution payments". This was already reading from 2 different Xero models (bank transactions vs. sales).

We have as usual:
- 1 Daily metric model
- 2 MTD/Monthly metric model
- 2 MTD/Monthly agg model (I already changed the name to agg instead of aggregated)
- 1 test to compare the values match the current setup

# 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.
- [NA] I have checked for DRY opportunities with other models and docs.
- [X] 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: #23565
This commit is contained in:
Oriol Roqué Paniagua 2024-11-05 07:45:41 +00:00
parent 9b0c7161e3
commit b31a6ba194
7 changed files with 571 additions and 9 deletions

View file

@ -3123,7 +3123,7 @@ models:
- name: has_id_check
data_type: string
description: Does the verification in the guest journey
includes Government Id Check for the bookings.
includes Government Id Check for the bookings.
tests:
- not_null
- accepted_values:
@ -3189,7 +3189,7 @@ models:
description: |
Count of daily guest journeys completed in a given date and
per specified dimension.
- name: int_kpis__metric_monthly_check_in_attributed_guest_journeys
description: |
This model computes the Monthly metrics associated with Guest Journeys
@ -3245,7 +3245,7 @@ models:
- name: has_id_check
data_type: string
description: Does the verification in the guest journey
includes Government Id Check for the bookings.
include Government Id Check for the bookings.
tests:
- not_null
- accepted_values:
@ -3261,7 +3261,7 @@ models:
tests:
- not_null
- accepted_values:
values:
values:
- "0"
- "01-05"
- "06-20"
@ -3369,7 +3369,7 @@ models:
- assert_dimension_completeness:
metric_column_name: completed_guest_journeys
- accepted_values:
values:
values:
- global
- by_deal
- by_has_payment
@ -3487,7 +3487,7 @@ models:
- name: has_id_check
data_type: string
description: Does the verification in the guest journey
includes Government Id Check for the bookings.
include Government Id Check for the bookings.
tests:
- not_null
- accepted_values:
@ -3503,7 +3503,7 @@ models:
tests:
- not_null
- accepted_values:
values:
values:
- "0"
- "01-05"
- "06-20"
@ -3611,7 +3611,7 @@ models:
- assert_dimension_completeness:
metric_column_name: completed_guest_journeys
- accepted_values:
values:
values:
- global
- by_deal
- by_has_payment
@ -3672,4 +3672,342 @@ models:
Monthly aggregated count of guest journeys completed for a given date,
dimension, and value.
tests:
- not_null
- not_null
- name: int_kpis__metric_daily_host_resolutions
description: |
This model computes the Daily Host Resolutions at the deepest granularity.
The unique key corresponds to the deepest granularity of the model,
in this case:
- date,
- id_deal.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- date
- id_deal
columns:
- name: date
data_type: date
description: Date of when Host Resolutions transaction happened.
tests:
- not_null
- name: id_deal
data_type: string
description: Unique identifier of an account.
tests:
- not_null
- 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: xero_host_resolution_payment_count
data_type: bigint
description: |
Count of daily Host Resolution Payment Count in a given date and per specified dimension.
- name: xero_host_resolution_amount_paid_in_gbp
data_type: decimal
description: |
Sum of daily Host Resolution Amount Paid, in GBP, in a given
date and per specified dimension.
- name: int_kpis__metric_monthly_host_resolutions
description: |
This model computes the Monthly Host Resolutions 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,
- active_accommodations_per_deal_segmentation.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- end_date
- id_deal
- 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: id_deal
data_type: string
description: Unique identifier of an account.
tests:
- not_null
- 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: xero_host_resolution_payment_count
data_type: bigint
description: |
Count of accumulated Host Resolution Payment Count in a
given month and per specified dimension.
- name: xero_host_resolution_amount_paid_in_gbp
data_type: decimal
description: |
Sum of accumulated Host Resolution Amount Paid, in GBP, in a
given month and per specified dimension.
- name: int_kpis__metric_mtd_host_resolutions
description: |
This model computes the Month-To-Date Host Resolutions 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,
- active_accommodations_per_deal_segmentation.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- end_date
- id_deal
- 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: id_deal
data_type: string
description: Unique identifier of an account.
tests:
- not_null
- 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: xero_host_resolution_payment_count
data_type: bigint
description: |
Count of accumulated Host Resolution Payment Count in a
given month up to the given date and per specified dimension.
- name: xero_host_resolution_amount_paid_in_gbp
data_type: decimal
description: |
Sum of accumulated Host Resolution Amount Paid, in GBP, in a
given month up to the given date and per specified dimension.
- name: int_kpis__agg_monthly_host_resolutions
description: |
This model computes the dimension aggregation for
Monthly Host Resolutions.
The primary key of this model is end_date, dimension
and dimension_value.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- end_date
- dimension
- dimension_value
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: dimension
data_type: string
description: The dimension or granularity of the metrics.
tests:
- assert_dimension_completeness:
metric_column_name: xero_host_resolution_payment_count
- assert_dimension_completeness:
metric_column_name: xero_host_resolution_amount_paid_in_gbp
- accepted_values:
values:
- global
- by_number_of_listings
- by_billing_country
- by_deal
- name: dimension_value
data_type: string
description: The value or segment available for the selected dimension.
tests:
- not_null
- name: xero_host_resolution_payment_count
data_type: bigint
description: |
The monthly Host Resolution Payment Count for a given date, dimension and value.
- name: xero_host_resolution_amount_paid_in_gbp
data_type: decimal
description: |
The monthly Host Resolution Amount Paid, in GBP, for a
given date, dimension and value.
- name: int_kpis__agg_mtd_host_resolutions
description: |
This model computes the dimension aggregation for
Month-To-Date Host Resolutions.
The primary key of this model is end_date, dimension
and dimension_value.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- end_date
- dimension
- dimension_value
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: dimension
data_type: string
description: The dimension or granularity of the metrics.
tests:
- assert_dimension_completeness:
metric_column_name: xero_host_resolution_payment_count
- assert_dimension_completeness:
metric_column_name: xero_host_resolution_amount_paid_in_gbp
- accepted_values:
values:
- global
- by_number_of_listings
- by_billing_country
- by_deal
- name: dimension_value
data_type: string
description: The value or segment available for the selected dimension.
tests:
- not_null
- name: xero_host_resolution_payment_count
data_type: bigint
description: |
The month-to-date Host Resolution Payment Count for a given date, dimension and value.
- name: xero_host_resolution_amount_paid_in_gbp
data_type: decimal
description: |
The month-to-date Host Resolution Amount Paid, in GBP, for a
given date, dimension and value.