From eb8e59f8c583da2b5586ce354696073374eaee64 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Mon, 4 Nov 2024 18:15:13 +0100 Subject: [PATCH] Addressed comments --- ...hly_check_in_attributed_guest_journeys.sql | 2 +- ...mtd_check_in_attributed_guest_journeys.sql | 2 +- ...ily_check_in_attributed_guest_journeys.sql | 2 +- ...hly_check_in_attributed_guest_journeys.sql | 2 +- ...mtd_check_in_attributed_guest_journeys.sql | 2 +- models/intermediate/kpis/schema.yml | 90 ++++++++----------- 6 files changed, 43 insertions(+), 57 deletions(-) diff --git a/models/intermediate/kpis/int_kpis__agg_monthly_check_in_attributed_guest_journeys.sql b/models/intermediate/kpis/int_kpis__agg_monthly_check_in_attributed_guest_journeys.sql index 768f71b..02d6fe6 100644 --- a/models/intermediate/kpis/int_kpis__agg_monthly_check_in_attributed_guest_journeys.sql +++ b/models/intermediate/kpis/int_kpis__agg_monthly_check_in_attributed_guest_journeys.sql @@ -28,7 +28,7 @@ sum(started_guest_journeys) as started_guest_journeys, sum(completed_guest_journeys) as completed_guest_journeys, sum(count_csat_score) as count_csat_score, - sum(count_csat_score * average_csat_score)/sum(count_csat_score) as average_csat_score + sum(count_csat_score * average_csat_score) / nullif(sum(count_csat_score), 0) as average_csat_score from {{ ref("int_kpis__metric_monthly_check_in_attributed_guest_journeys") }} group by 1, 2, 3, 4 {% if not loop.last %} diff --git a/models/intermediate/kpis/int_kpis__agg_mtd_check_in_attributed_guest_journeys.sql b/models/intermediate/kpis/int_kpis__agg_mtd_check_in_attributed_guest_journeys.sql index 5c87b29..27a9b7e 100644 --- a/models/intermediate/kpis/int_kpis__agg_mtd_check_in_attributed_guest_journeys.sql +++ b/models/intermediate/kpis/int_kpis__agg_mtd_check_in_attributed_guest_journeys.sql @@ -28,7 +28,7 @@ sum(started_guest_journeys) as started_guest_journeys, sum(completed_guest_journeys) as completed_guest_journeys, sum(count_csat_score) as count_csat_score, - sum(count_csat_score * average_csat_score)/sum(count_csat_score) as average_csat_score + sum(count_csat_score * average_csat_score) / nullif(sum(count_csat_score), 0) as average_csat_score from {{ ref("int_kpis__metric_mtd_check_in_attributed_guest_journeys") }} group by 1, 2, 3, 4 {% if not loop.last %} diff --git a/models/intermediate/kpis/int_kpis__metric_daily_check_in_attributed_guest_journeys.sql b/models/intermediate/kpis/int_kpis__metric_daily_check_in_attributed_guest_journeys.sql index ae4d365..8317ed7 100644 --- a/models/intermediate/kpis/int_kpis__metric_daily_check_in_attributed_guest_journeys.sql +++ b/models/intermediate/kpis/int_kpis__metric_daily_check_in_attributed_guest_journeys.sql @@ -78,7 +78,7 @@ select end ) as count_csat_score, avg( - distinct case + case when gsr.id_verification_request is not null then gsr.experience_rating else null diff --git a/models/intermediate/kpis/int_kpis__metric_monthly_check_in_attributed_guest_journeys.sql b/models/intermediate/kpis/int_kpis__metric_monthly_check_in_attributed_guest_journeys.sql index bd70d0e..41c37db 100644 --- a/models/intermediate/kpis/int_kpis__metric_monthly_check_in_attributed_guest_journeys.sql +++ b/models/intermediate/kpis/int_kpis__metric_monthly_check_in_attributed_guest_journeys.sql @@ -25,7 +25,7 @@ select sum(b.started_guest_journeys) as started_guest_journeys, sum(b.completed_guest_journeys) as completed_guest_journeys, sum(b.count_csat_score) as count_csat_score, - sum(b.count_csat_score * b.average_csat_score)/sum(b.count_csat_score) as average_csat_score + sum(b.count_csat_score * b.average_csat_score) / nullif(sum(b.count_csat_score), 0) as average_csat_score from {{ ref("int_kpis__dimension_dates") }} d left join {{ ref("int_kpis__metric_daily_check_in_attributed_guest_journeys") }} b diff --git a/models/intermediate/kpis/int_kpis__metric_mtd_check_in_attributed_guest_journeys.sql b/models/intermediate/kpis/int_kpis__metric_mtd_check_in_attributed_guest_journeys.sql index a692631..b93cab7 100644 --- a/models/intermediate/kpis/int_kpis__metric_mtd_check_in_attributed_guest_journeys.sql +++ b/models/intermediate/kpis/int_kpis__metric_mtd_check_in_attributed_guest_journeys.sql @@ -25,7 +25,7 @@ select sum(b.started_guest_journeys) as started_guest_journeys, sum(b.completed_guest_journeys) as completed_guest_journeys, sum(b.count_csat_score) as count_csat_score, - sum(b.count_csat_score * b.average_csat_score)/sum(b.count_csat_score) as average_csat_score + sum(b.count_csat_score * b.average_csat_score) / nullif(sum(b.count_csat_score), 0) as average_csat_score from {{ ref("int_kpis__dimension_dates") }} d left join {{ ref("int_kpis__metric_daily_check_in_attributed_guest_journeys") }} b diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index 493b00c..0d627e3 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -3290,31 +3290,31 @@ models: - 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. + Accumulated 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. + Accumulated 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. + Accumulated 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 + Accumulated count of daily guest journeys created in a given date and per specified dimension. tests: - not_null @@ -3322,7 +3322,7 @@ models: - name: started_guest_journeys data_type: numeric description: | - Count of daily guest journeys started in a given date and + Accumulated count of daily guest journeys started in a given date and per specified dimension. tests: - not_null @@ -3330,7 +3330,7 @@ models: - name: completed_guest_journeys data_type: numeric description: | - Count of daily guest journeys completed in a given date and + Accumulated count of daily guest journeys completed in a given date and per specified dimension. tests: - not_null @@ -3338,17 +3338,13 @@ models: - name: count_csat_score data_type: numeric description: | - Count of daily guest journeys with CSAT (customer satisfaction score) - in a given date and per specified dimension. - tests: - - dbt_expectations.expect_column_values_to_be_between: - min_value: 0 - strictly: false + Accumulated count of guest journeys with CSAT + (customer satisfaction score) in a given date, dimension, and value.. - name: average_csat_score data_type: numeric description: | - Average daily CSAT score in a given date and per specified dimension. + Accumulated average CSAT score in a given date, dimension, and value. tests: - dbt_expectations.expect_column_values_to_be_between: min_value: 0 @@ -3468,17 +3464,14 @@ models: - name: count_csat_score data_type: numeric description: | - Count of daily guest journeys with CSAT (customer satisfaction score) - in a given date and per specified dimension. - tests: - - dbt_expectations.expect_column_values_to_be_between: - min_value: 0 - strictly: false + Monthly aggregated count of guest journeys with CSAT + (customer satisfaction score) in a given date, dimension, and value. - name: average_csat_score data_type: numeric description: | - Average daily CSAT score in a given date and per specified dimension. + Monthly aggregated average CSAT score in a given date, + dimension, and value. tests: - dbt_expectations.expect_column_values_to_be_between: min_value: 0 @@ -3574,31 +3567,31 @@ models: - 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. + Accumulated 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. + Accumulated 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. + Accumulated 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 + Accumulated count of daily guest journeys created in a given date and per specified dimension. tests: - not_null @@ -3606,7 +3599,7 @@ models: - name: started_guest_journeys data_type: numeric description: | - Count of daily guest journeys started in a given date and + Accumulated count of daily guest journeys started in a given date and per specified dimension. tests: - not_null @@ -3614,7 +3607,7 @@ models: - name: completed_guest_journeys data_type: numeric description: | - Count of daily guest journeys completed in a given date and + Accumulated count of daily guest journeys completed in a given date and per specified dimension. tests: - not_null @@ -3622,17 +3615,13 @@ models: - name: count_csat_score data_type: numeric description: | - Count of daily guest journeys with CSAT (customer satisfaction score) - in a given date and per specified dimension. - tests: - - dbt_expectations.expect_column_values_to_be_between: - min_value: 0 - strictly: false + Accumulated count of guest journeys with CSAT + (customer satisfaction score) in a given date, dimension, and value.. - name: average_csat_score data_type: numeric description: | - Average daily CSAT score in a given date and per specified dimension. + Accumulated average CSAT score in a given date, dimension, and value. tests: - dbt_expectations.expect_column_values_to_be_between: min_value: 0 @@ -3704,7 +3693,7 @@ models: - name: created_guest_journeys_not_cancelled data_type: numeric description: | - Monthly aggregated count of guest journeys created, excluding + Month-to-date aggregated count of guest journeys created, excluding cancelled bookings, for a given date, dimension, and value. tests: - not_null @@ -3712,7 +3701,7 @@ models: - name: started_guest_journeys_not_cancelled data_type: numeric description: | - Monthly aggregated count of guest journeys started, excluding + Month-to-date aggregated count of guest journeys started, excluding cancelled bookings, for a given date, dimension, and value. tests: - not_null @@ -3720,7 +3709,7 @@ models: - name: completed_guest_journeys_not_cancelled data_type: numeric description: | - Monthly aggregated count of guest journeys completed, excluding + Month-to-date aggregated count of guest journeys completed, excluding cancelled bookings, for a given date, dimension, and value. tests: - not_null @@ -3728,7 +3717,7 @@ models: - name: created_guest_journeys data_type: numeric description: | - Monthly aggregated count of guest journeys created for a given date, + Month-to-date aggregated count of guest journeys created for a given date, dimension, and value. tests: - not_null @@ -3736,7 +3725,7 @@ models: - name: started_guest_journeys data_type: numeric description: | - Monthly aggregated count of guest journeys started for a given date, + Month-to-date aggregated count of guest journeys started for a given date, dimension, and value. tests: - not_null @@ -3744,7 +3733,7 @@ models: - name: completed_guest_journeys data_type: numeric description: | - Monthly aggregated count of guest journeys completed for a given date, + Month-to-date aggregated count of guest journeys completed for a given date, dimension, and value. tests: - not_null @@ -3752,17 +3741,14 @@ models: - name: count_csat_score data_type: numeric description: | - Count of daily guest journeys with CSAT (customer satisfaction score) - in a given date and per specified dimension. - tests: - - dbt_expectations.expect_column_values_to_be_between: - min_value: 0 - strictly: false + Month-to-date aggregated count of guest journeys with CSAT + (customer satisfaction score) in a given date, dimension, and value. - name: average_csat_score data_type: numeric description: | - Average daily CSAT score in a given date and per specified dimension. + Month-to-date aggregated average CSAT score in a given date, + dimension, and value. tests: - dbt_expectations.expect_column_values_to_be_between: min_value: 0