save all guest journey check in attributed models

This commit is contained in:
Joaquin 2024-11-02 11:28:22 +01:00
parent 3e5fd5a761
commit 19337a9918
3 changed files with 470 additions and 0 deletions

View file

@ -80,6 +80,12 @@ Please note that strings should be encoded with " ' your_value_here ' ",
{% macro dim_dash() %}
{{ return({"dimension": "'by_dash_source'", "dimension_value": "dash_source"}) }}
{% endmacro %}
{% macro dim_has_payment() %}
{{ return({"dimension": "'by_has_payment'", "dimension_value": "'has_payment'"}) }}
{% endmacro %}
{% macro dim_has_id_check() %}
{{ return({"dimension": "'by_has_id_check'", "dimension_value": "'has_id_check'"}) }}
{% endmacro %}
/*
Macro: get_kpi_dimensions_per_model

View file

@ -0,0 +1,35 @@
{% set dimensions = get_kpi_dimensions_per_model("GUEST_JOURNEY_METRICS") %}
{{
config(
materialized="table", unique_key=["end_date", "dimension", "dimension_value"]
)
}}
{% for dimension in dimensions %}
select
-- Unique Key --
start_date,
end_date,
{{ dimension.dimension }} as dimension,
{{ dimension.dimension_value }} as dimension_value,
-- Metrics --
sum(
created_guest_journeys_not_cancelled
) as created_guest_journeys_not_cancelled,
sum(
started_guest_journeys_not_cancelled
) as started_guest_journeys_not_cancelled,
sum(
completed_guest_journeys_not_cancelled
) as completed_guest_journeys_not_cancelled,
sum(created_guest_journeys) as created_guest_journeys,
sum(started_guest_journeys) as started_guest_journeys,
sum(completed_guest_journeys) as completed_guest_journeys
from {{ ref("int_kpis__metric_mtd_check_in_attributed_guest_journeys") }}
group by 1, 2, 3, 4
{% if not loop.last %}
union all
{% endif %}
{% endfor %}

View file

@ -3177,3 +3177,432 @@ 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
attributed to Check-In date at the deepest granularity.
The unique key corresponds to:
- end_date,
- id_deal,
- has_payment,
- has_id_check,
- active_accommodations_per_deal_segmentation.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- end_date
- id_deal
- has_payment
- 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: id_deal
data_type: character varying
description: Unique identifier of an account.
tests:
- not_null
- name: has_payment
data_type: boolean
description: True if there has been any guest payments on the guest journey.
tests:
- not_null
- name: has_id_check
data_type: boolean
description: True if the verification in the guest journey includes Government ID Check for the bookings.
tests:
- not_null
- name: active_accommodations_per_deal_segmentation
data_type: text
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: character varying
description: |
Main billing country of the host aggregated at Deal level.
tests:
- not_null
- name: created_guest_journeys_not_cancelled
data_type: numeric
description: |
Count of daily guest journeys created, excluding cancelled bookings,
in a given date and per specified dimension.
tests:
- not_null
- name: started_guest_journeys_not_cancelled
data_type: numeric
description: |
Count of daily guest journeys started, excluding cancelled bookings,
in a given date and per specified dimension.
tests:
- not_null
- name: completed_guest_journeys_not_cancelled
data_type: numeric
description: |
Count of daily guest journeys completed, excluding cancelled bookings,
in a given date and per specified dimension.
tests:
- not_null
- name: created_guest_journeys
data_type: numeric
description: |
Count of daily guest journeys created in a given date and
per specified dimension.
tests:
- not_null
- name: started_guest_journeys
data_type: numeric
description: |
Count of daily guest journeys started in a given date and
per specified dimension.
tests:
- not_null
- name: completed_guest_journeys
data_type: numeric
description: |
Count of daily guest journeys completed in a given date and
per specified dimension.
tests:
- not_null
- name: int_kpis__aggregated_monthly_check_in_attributed_guest_journeys
description: |
This model computes the dimension aggregation for Monthly metrics associated
to Guest Journeys attributed to Check-In date.
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: text
description: |
The dimension or granularity of the metrics.
tests:
- assert_dimension_completeness:
metric_column_name: completed_guest_journeys
- accepted_values:
values: ["global", "by_deal", "by_has_payment", "by_has_id_check",
"by_billing_country", "by_number_of_listings"]
- name: dimension_value
data_type: text
description: |
The value or segment available for the selected dimension.
tests:
- not_null
- name: created_guest_journeys_not_cancelled
data_type: numeric
description: |
Monthly aggregated count of guest journeys created, excluding
cancelled bookings, for a given date, dimension, and value.
tests:
- not_null
- name: started_guest_journeys_not_cancelled
data_type: numeric
description: |
Monthly aggregated count of guest journeys started, excluding
cancelled bookings, for a given date, dimension, and value.
tests:
- not_null
- name: completed_guest_journeys_not_cancelled
data_type: numeric
description: |
Monthly aggregated count of guest journeys completed, excluding
cancelled bookings, for a given date, dimension, and value.
tests:
- not_null
- name: created_guest_journeys
data_type: numeric
description: |
Monthly aggregated count of guest journeys created for a given date,
dimension, and value.
tests:
- not_null
- name: started_guest_journeys
data_type: numeric
description: |
Monthly aggregated count of guest journeys started for a given date,
dimension, and value.
tests:
- not_null
- name: completed_guest_journeys
data_type: numeric
description: |
Monthly aggregated count of guest journeys completed for a given date,
dimension, and value.
tests:
- not_null
- name: int_kpis__metric_mtd_check_in_attributed_guest_journeys
description: |
This model computes the Month-To-Date metrics associated with Guest Journeys
attributed to Check-In date at the deepest granularity.
The unique key corresponds to:
- end_date,
- id_deal,
- has_payment,
- has_id_check,
- active_accommodations_per_deal_segmentation.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- end_date
- id_deal
- has_payment
- 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: id_deal
data_type: character varying
description: Unique identifier of an account.
tests:
- not_null
- name: has_payment
data_type: boolean
description: True if there has been any guest payments on the guest journey.
tests:
- not_null
- name: has_id_check
data_type: boolean
description: True if the verification in the guest journey includes
Government ID Check for the bookings.
tests:
- not_null
- name: active_accommodations_per_deal_segmentation
data_type: text
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: character varying
description: |
Main billing country of the host aggregated at Deal level.
tests:
- not_null
- name: created_guest_journeys_not_cancelled
data_type: numeric
description: |
Count of daily guest journeys created, excluding cancelled bookings,
in a given date and per specified dimension.
tests:
- not_null
- name: started_guest_journeys_not_cancelled
data_type: numeric
description: |
Count of daily guest journeys started, excluding cancelled bookings,
in a given date and per specified dimension.
tests:
- not_null
- name: completed_guest_journeys_not_cancelled
data_type: numeric
description: |
Count of daily guest journeys completed, excluding cancelled bookings,
in a given date and per specified dimension.
tests:
- not_null
- name: created_guest_journeys
data_type: numeric
description: |
Count of daily guest journeys created in a given date and
per specified dimension.
tests:
- not_null
- name: started_guest_journeys
data_type: numeric
description: |
Count of daily guest journeys started in a given date and
per specified dimension.
tests:
- not_null
- name: completed_guest_journeys
data_type: numeric
description: |
Count of daily guest journeys completed in a given date and
per specified dimension.
tests:
- not_null
- name: int_kpis__aggregated_mtd_check_in_attributed_guest_journeys
description: |
This model computes the dimension aggregation for Month-To-Date metrics associated
to Guest Journeys attributed to Check-In date.
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: text
description: |
The dimension or granularity of the metrics.
tests:
- assert_dimension_completeness:
metric_column_name: completed_guest_journeys
- accepted_values:
values: ["global", "by_deal", "by_has_payment", "by_has_id_check",
"by_billing_country", "by_number_of_listings"]
- name: dimension_value
data_type: text
description: |
The value or segment available for the selected dimension.
tests:
- not_null
- name: created_guest_journeys_not_cancelled
data_type: numeric
description: |
Monthly aggregated count of guest journeys created, excluding
cancelled bookings, for a given date, dimension, and value.
tests:
- not_null
- name: started_guest_journeys_not_cancelled
data_type: numeric
description: |
Monthly aggregated count of guest journeys started, excluding
cancelled bookings, for a given date, dimension, and value.
tests:
- not_null
- name: completed_guest_journeys_not_cancelled
data_type: numeric
description: |
Monthly aggregated count of guest journeys completed, excluding
cancelled bookings, for a given date, dimension, and value.
tests:
- not_null
- name: created_guest_journeys
data_type: numeric
description: |
Monthly aggregated count of guest journeys created for a given date,
dimension, and value.
tests:
- not_null
- name: started_guest_journeys
data_type: numeric
description: |
Monthly aggregated count of guest journeys started for a given date,
dimension, and value.
tests:
- not_null
- name: completed_guest_journeys
data_type: numeric
description: |
Monthly aggregated count of guest journeys completed for a given date,
dimension, and value.
tests:
- not_null