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 8f0ef70..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 @@ -26,7 +26,9 @@ ) 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 + sum(completed_guest_journeys) as completed_guest_journeys, + sum(count_csat_score) as count_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 6544f1c..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 @@ -26,7 +26,9 @@ ) 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 + sum(completed_guest_journeys) as completed_guest_journeys, + sum(count_csat_score) as count_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 ebbf068..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 @@ -69,7 +69,21 @@ select then vr.id_verification_request else null end - ) as completed_guest_journeys + ) as completed_guest_journeys, + count( + distinct case + when gsr.id_verification_request is not null + then vr.id_verification_request + else null + end + ) as count_csat_score, + avg( + case + when gsr.id_verification_request is not null + then gsr.experience_rating + else null + end + ) as average_csat_score from {{ ref("int_core__verification_requests") }} as vr inner join {{ ref("int_core__bookings") }} as b @@ -88,4 +102,7 @@ left join {{ ref("stg_core__verification") }} as v on v.id_verification_request = vr.id_verification_request and v.verification = '{{ id_check }}' +left join + {{ ref("int_core__guest_satisfaction_responses") }} as gsr + on gsr.id_verification_request = vr.id_verification_request group by 1, 2, 3, 4, 5, 6 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 021092a..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 @@ -23,7 +23,9 @@ select ) as completed_guest_journeys_not_cancelled, sum(b.created_guest_journeys) as created_guest_journeys, sum(b.started_guest_journeys) as started_guest_journeys, - sum(b.completed_guest_journeys) as completed_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) / 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 4c7a5f2..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 @@ -23,7 +23,9 @@ select ) as completed_guest_journeys_not_cancelled, sum(b.created_guest_journeys) as created_guest_journeys, sum(b.started_guest_journeys) as started_guest_journeys, - sum(b.completed_guest_journeys) as completed_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) / 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 f768f6f..d3399d8 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -3190,6 +3190,17 @@ models: Count of daily guest journeys completed in a given date and per specified dimension. + - name: count_csat_score + data_type: bigint + description: | + Count of daily guest journeys with CSAT (customer satisfaction score) + in a given date and per specified dimension. + + - name: average_csat_score + data_type: bigint + description: | + Average daily CSAT score 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 @@ -3279,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. + Monthly 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. + Monthly 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. + Monthly 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 + Monthly accumulated count of daily guest journeys created in a given date and per specified dimension. tests: - not_null @@ -3311,7 +3322,7 @@ models: - name: started_guest_journeys data_type: numeric description: | - Count of daily guest journeys started in a given date and + Monthly accumulated count of daily guest journeys started in a given date and per specified dimension. tests: - not_null @@ -3319,11 +3330,27 @@ models: - name: completed_guest_journeys data_type: numeric description: | - Count of daily guest journeys completed in a given date and + Monthly accumulated count of daily guest journeys completed in a given date and per specified dimension. tests: - not_null + - name: count_csat_score + data_type: numeric + description: | + Monthly 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: | + Monthly accumulated average CSAT score in a given date, dimension, and value. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 5 + strictly: false + - name: int_kpis__agg_monthly_check_in_attributed_guest_journeys description: | This model computes the dimension aggregation for Monthly metrics associated @@ -3368,6 +3395,8 @@ models: metric_column_name: started_guest_journeys - assert_dimension_completeness: metric_column_name: completed_guest_journeys + - assert_dimension_completeness: + metric_column_name: count_csat_score - accepted_values: values: - global @@ -3432,6 +3461,23 @@ models: tests: - not_null + - name: count_csat_score + data_type: numeric + description: | + 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: | + Monthly aggregated average CSAT score in a given date, + dimension, and value. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 5 + strictly: false + - name: int_kpis__metric_mtd_check_in_attributed_guest_journeys description: | This model computes the Month-To-Date metrics associated with Guest Journeys @@ -3521,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. + Month-to-date 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. + Month-to-date 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. + Month-to-date 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 + Month-to-date accumulated count of daily guest journeys created in a given date and per specified dimension. tests: - not_null @@ -3553,7 +3599,7 @@ models: - name: started_guest_journeys data_type: numeric description: | - Count of daily guest journeys started in a given date and + Month-to-date accumulated count of daily guest journeys started in a given date and per specified dimension. tests: - not_null @@ -3561,11 +3607,27 @@ models: - name: completed_guest_journeys data_type: numeric description: | - Count of daily guest journeys completed in a given date and + Month-to-date accumulated count of daily guest journeys completed in a given date and per specified dimension. tests: - not_null + - name: count_csat_score + data_type: numeric + description: | + Month-to-date 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: | + Month-to-date accumulated average CSAT score in a given date, dimension, and value. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 5 + strictly: false + - name: int_kpis__agg_mtd_check_in_attributed_guest_journeys description: | This model computes the dimension aggregation for Month-To-Date metrics associated @@ -3610,6 +3672,8 @@ models: metric_column_name: started_guest_journeys - assert_dimension_completeness: metric_column_name: completed_guest_journeys + - assert_dimension_completeness: + metric_column_name: count_csat_score - accepted_values: values: - global @@ -3629,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 @@ -3637,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 @@ -3645,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 @@ -3653,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 @@ -3661,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 @@ -3669,10 +3733,27 @@ 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 + - not_null + + - name: count_csat_score + data_type: numeric + description: | + 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: | + 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 + max_value: 5 + strictly: false - name: int_kpis__metric_daily_host_resolutions description: |