From ca9188b1ab9961cf7741535d57069c192ef38b75 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Fri, 14 Feb 2025 08:35:51 +0100 Subject: [PATCH] Addressed comments --- dbt_project.yml | 21 ---- .../int_core__new_dash_services_offered.sql | 99 ++++++++++--------- models/intermediate/core/schema.yml | 26 ++--- .../core/core__new_dash_services_offered.sql | 39 +++++--- models/reporting/core/schema.yml | 26 ++--- 5 files changed, 105 insertions(+), 106 deletions(-) diff --git a/dbt_project.yml b/dbt_project.yml index 9666d19..e61362d 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -75,27 +75,6 @@ vars: # States should be strings in capital letters. Models need to force an upper() "cancelled_booking_state": "'CANCELLED'" "approved_booking_state": "'APPROVED'" - "flagged_booking_state": "'FLAGGED'" - "incomplete_information_booking_state": "'INCOMPLETEINFORMATION'" - "no_flags_booking_state": "'NOFLAGS'" - "not_approved_booking_state": "'NOTAPPROVED'" - "rejected_booking_state": "'REJECTED'" - - # New Dash services status variables - # Status should be strings in capital letters. Models need to force an upper() - "protected_service_status": "'PROTECTED'" - "rejected_service_status": "'REJECTED'" - "no_checks_service_status": "'NOCHECKS'" - "no_flags_service_status": "'NOFLAGS'" - "paid_service_status": "'PAID'" - "pending_service_status": "'PENDING'" - "unknown_service_status": "'-'" - "partially_protected_service_status": "'PARTIALLY PROTECTED'" - "not_protected_service_status": "'NOT PROTECTED'" - "not_paid_service_status": "'NOT PAID'" - "confirmed_service_status": "'CONFIRMED'" - "for_review_service_status": "'FORREVIEW'" - "flagged_service_status": "'FLAGGED'" # Payment state variables # States should be strings in capital letters. Models need to force an upper() diff --git a/models/intermediate/core/int_core__new_dash_services_offered.sql b/models/intermediate/core/int_core__new_dash_services_offered.sql index 77f8fe4..1fa96c6 100644 --- a/models/intermediate/core/int_core__new_dash_services_offered.sql +++ b/models/intermediate/core/int_core__new_dash_services_offered.sql @@ -1,3 +1,17 @@ +{% set protected_service_status = "'PROTECTED'" %} +{% set rejected_service_status = "'REJECTED'" %} +{% set no_checks_service_status = "'NOCHECKS'" %} +{% set no_flags_service_status = "'NOFLAGS'" %} +{% set paid_service_status = "'PAID'" %} +{% set pending_service_status = "'PENDING'" %} +{% set unknown_service_status = "'-'" %} +{% set partially_protected_service_status = "'PARTIALLY PROTECTED'" %} +{% set not_protected_service_status = "'NOT PROTECTED'" %} +{% set not_paid_service_status = "'NOT PAID'" %} +{% set confirmed_service_status = "'CONFIRMED'" %} +{% set for_review_service_status = "'FORREVIEW'" %} +{% set flagged_service_status = "'FLAGGED'" %} + with int_core__user_product_bundle_contains_services as ( select * from {{ ref("int_core__user_product_bundle_contains_services") }} @@ -95,104 +109,97 @@ with count(distinct sd.id_booking) as number_bookings, count( distinct case - when - upper(sd.service_status) = {{ var("protected_service_status") }} + when upper(sd.service_status) = {{ protected_service_status }} then sd.id_booking else null end - ) as number_protected_bookings, + ) as number_bookings_with_service_status_protected, count( distinct case - when upper(sd.service_status) = {{ var("rejected_service_status") }} + when upper(sd.service_status) = {{ rejected_service_status }} then sd.id_booking else null end - ) as number_rejected_bookings, + ) as number_bookings_with_service_status_rejected, count( distinct case - when - upper(sd.service_status) = {{ var("no_checks_service_status") }} + when upper(sd.service_status) = {{ no_checks_service_status }} then sd.id_booking else null end - ) as number_no_checks_bookings, + ) as number_bookings_with_service_status_no_checks, count( distinct case - when upper(sd.service_status) = {{ var("no_flags_service_status") }} + when upper(sd.service_status) = {{ no_flags_service_status }} then sd.id_booking else null end - ) as number_no_flags_bookings, + ) as number_bookings_with_service_status_no_flags, count( distinct case - when upper(sd.service_status) = {{ var("paid_service_status") }} + when upper(sd.service_status) = {{ paid_service_status }} then sd.id_booking else null end - ) as number_paid_bookings, + ) as number_bookings_with_service_status_paid, count( distinct case - when upper(sd.service_status) = {{ var("pending_service_status") }} + when upper(sd.service_status) = {{ paid_service_status }} then sd.id_booking else null end - ) as number_pending_bookings, + ) as number_bookings_with_service_status_pending, count( distinct case - when upper(sd.service_status) = {{ var("unknown_service_status") }} + when upper(sd.service_status) = {{ unknown_service_status }} then sd.id_booking else null end - ) as number_unknown_status_bookings, + ) as number_bookings_with_service_status_unknown_status, count( distinct case when upper(sd.service_status) - = {{ var("partially_protected_service_status") }} + = {{ partially_protected_service_status }} then sd.id_booking else null end - ) as number_partially_protected_bookings, + ) as number_bookings_with_service_status_partially_protected, count( distinct case - when - upper(sd.service_status) - = {{ var("not_protected_service_status") }} + when upper(sd.service_status) = {{ not_protected_service_status }} then sd.id_booking else null end - ) as number_not_protected_bookings, + ) as number_bookings_with_service_status_not_protected, count( distinct case - when upper(sd.service_status) = {{ var("not_paid_service_status") }} + when upper(sd.service_status) = {{ not_paid_service_status }} then sd.id_booking else null end - ) as number_not_paid_bookings, + ) as number_bookings_with_service_status_not_paid, count( distinct case - when - upper(sd.service_status) = {{ var("confirmed_service_status") }} + when upper(sd.service_status) = {{ confirmed_service_status }} then sd.id_booking else null end - ) as number_confirmed_bookings, + ) as number_bookings_with_service_status_confirmed, count( distinct case - when - upper(sd.service_status) - = {{ var("for_review_service_status") }} + when upper(sd.service_status) = {{ for_review_service_status }} then sd.id_booking else null end - ) as number_for_review_bookings, + ) as number_bookings_with_service_status_for_review, count( distinct case - when upper(sd.service_status) = {{ var("flagged_service_status") }} + when upper(sd.service_status) = {{ flagged_service_status }} then sd.id_booking else null end - ) as number_flagged_bookings + ) as number_bookings_with_service_status_flagged from int_core__booking_service_detail sd group by 1 ) @@ -207,19 +214,19 @@ select a.number_active_accommodations, a.number_inactive_accommodations, b.number_bookings, - b.number_protected_bookings, - b.number_rejected_bookings, - b.number_no_checks_bookings, - b.number_no_flags_bookings, - b.number_paid_bookings, - b.number_pending_bookings, - b.number_unknown_status_bookings, - b.number_partially_protected_bookings, - b.number_not_protected_bookings, - b.number_not_paid_bookings, - b.number_confirmed_bookings, - b.number_for_review_bookings, - b.number_flagged_bookings + b.number_bookings_with_service_status_protected, + b.number_bookings_with_service_status_rejected, + b.number_bookings_with_service_status_no_checks, + b.number_bookings_with_service_status_no_flags, + b.number_bookings_with_service_status_paid, + b.number_bookings_with_service_status_pending, + b.number_bookings_with_service_status_unknown_status, + b.number_bookings_with_service_status_partially_protected, + b.number_bookings_with_service_status_not_protected, + b.number_bookings_with_service_status_not_paid, + b.number_bookings_with_service_status_confirmed, + b.number_bookings_with_service_status_for_review, + b.number_bookings_with_service_status_flagged from users u left join accommodations a on u.service_display_name = a.service_display_name full outer join bookings b on u.service_display_name = b.service_display_name diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index ac0a1c9..1d481a9 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -5289,55 +5289,55 @@ models: data_type: bigint description: "Number of bookings that have a bundle that considers this service." - - name: number_protected_bookings + - name: number_bookings_with_service_status_protected data_type: bigint description: "Number of bookings with status PROTECTED for this service." - - name: number_rejected_bookings + - name: number_bookings_with_service_status_rejected data_type: bigint description: "Number of bookings with status REJECTED for this service." - - name: number_no_checks_bookings + - name: number_bookings_with_service_status_no_checks data_type: bigint description: "Number of bookings with status NO CHECKS for this service." - - name: number_no_flags_bookings + - name: number_bookings_with_service_status_no_flags data_type: bigint description: "Number of bookings with status NO FLAGS for this service." - - name: number_paid_bookings + - name: number_bookings_with_service_status_paid data_type: bigint description: "Number of bookings with status PAID for this service." - - name: number_pending_bookings + - name: number_bookings_with_service_status_pending data_type: bigint description: "Number of bookings with status PENDING for this service." - - name: number_unknown_status_bookings + - name: number_bookings_with_service_status_unknown data_type: bigint description: "Number of bookings with unknown status for this service." - - name: number_partially_protected_bookings + - name: number_bookings_with_service_status_partially_protected data_type: bigint description: "Number of bookings with status PARTIALLY PROTECTED for this service." - - name: number_not_protected_bookings + - name: number_bookings_with_service_status_not_protected data_type: bigint description: "Number of bookings with status NOT PROTECTED for this service." - - name: number_not_paid_bookings + - name: number_bookings_with_service_status_not_paid data_type: bigint description: "Number of bookings with status NOT PAID for this service." - - name: number_confirmed_bookings + - name: number_bookings_with_service_status_confirmed data_type: bigint description: "Number of bookings with status CONFIRMED for this service." - - name: number_for_review_bookings + - name: number_bookings_with_service_status_for_review data_type: bigint description: "Number of bookings with status FOR REVIEW for this service." - - name: number_flagged_bookings + - name: number_bookings_with_service_status_flagged data_type: bigint description: "Number of bookings with status FLAGGED for this service." diff --git a/models/reporting/core/core__new_dash_services_offered.sql b/models/reporting/core/core__new_dash_services_offered.sql index 9517e64..44573b4 100644 --- a/models/reporting/core/core__new_dash_services_offered.sql +++ b/models/reporting/core/core__new_dash_services_offered.sql @@ -13,17 +13,30 @@ select number_active_accommodations as number_active_accommodations, number_inactive_accommodations as number_inactive_accommodations, number_bookings as number_bookings, - number_protected_bookings as number_protected_bookings, - number_rejected_bookings as number_rejected_bookings, - number_no_checks_bookings as number_no_checks_bookings, - number_no_flags_bookings as number_no_flags_bookings, - number_paid_bookings as number_paid_bookings, - number_pending_bookings as number_pending_bookings, - number_unknown_status_bookings as number_unknown_status_bookings, - number_partially_protected_bookings as number_partially_protected_bookings, - number_not_protected_bookings as number_not_protected_bookings, - number_not_paid_bookings as number_not_paid_bookings, - number_confirmed_bookings as number_confirmed_bookings, - number_for_review_bookings as number_for_review_bookings, - number_flagged_bookings as number_flagged_bookings + number_bookings_with_service_status_protected + as number_bookings_with_service_status_protected, + number_bookings_with_service_status_rejected + as number_bookings_with_service_status_rejected, + number_bookings_with_service_status_no_checks + as number_bookings_with_service_status_no_checks, + number_bookings_with_service_status_no_flags + as number_bookings_with_service_status_no_flags, + number_bookings_with_service_status_paid + as number_bookings_with_service_status_paid, + number_bookings_with_service_status_pending + as number_bookings_with_service_status_pending, + number_bookings_with_service_status_unknown_status + as number_bookings_with_service_status_unknown_status, + number_bookings_with_service_status_partially_protected + as number_bookings_with_service_status_partially_protected, + number_bookings_with_service_status_not_protected + as number_bookings_with_service_status_not_protected, + number_bookings_with_service_status_not_paid + as number_bookings_with_service_status_not_paid, + number_bookings_with_service_status_confirmed + as number_bookings_with_service_status_confirmed, + number_bookings_with_service_status_for_review + as number_bookings_with_service_status_for_review, + number_bookings_with_service_status_flagged + as number_bookings_with_service_status_flagged from int_core__new_dash_services_offered diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index bfd9228..aabe81f 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1627,55 +1627,55 @@ models: data_type: bigint description: "Number of bookings that have a bundle that considers this service." - - name: number_protected_bookings + - name: number_bookings_with_service_status_protected data_type: bigint description: "Number of bookings with status PROTECTED for this service." - - name: number_rejected_bookings + - name: number_bookings_with_service_status_rejected data_type: bigint description: "Number of bookings with status REJECTED for this service." - - name: number_no_checks_bookings + - name: number_bookings_with_service_status_no_checks data_type: bigint description: "Number of bookings with status NO CHECKS for this service." - - name: number_no_flags_bookings + - name: number_bookings_with_service_status_no_flags data_type: bigint description: "Number of bookings with status NO FLAGS for this service." - - name: number_paid_bookings + - name: number_bookings_with_service_status_paid data_type: bigint description: "Number of bookings with status PAID for this service." - - name: number_pending_bookings + - name: number_bookings_with_service_status_pending data_type: bigint description: "Number of bookings with status PENDING for this service." - - name: number_unknown_status_bookings + - name: number_bookings_with_service_status_unknown data_type: bigint description: "Number of bookings with unknown status for this service." - - name: number_partially_protected_bookings + - name: number_bookings_with_service_status_partially_protected data_type: bigint description: "Number of bookings with status PARTIALLY PROTECTED for this service." - - name: number_not_protected_bookings + - name: number_bookings_with_service_status_not_protected data_type: bigint description: "Number of bookings with status NOT PROTECTED for this service." - - name: number_not_paid_bookings + - name: number_bookings_with_service_status_not_paid data_type: bigint description: "Number of bookings with status NOT PAID for this service." - - name: number_confirmed_bookings + - name: number_bookings_with_service_status_confirmed data_type: bigint description: "Number of bookings with status CONFIRMED for this service." - - name: number_for_review_bookings + - name: number_bookings_with_service_status_for_review data_type: bigint description: "Number of bookings with status FOR REVIEW for this service." - - name: number_flagged_bookings + - name: number_bookings_with_service_status_flagged data_type: bigint description: "Number of bookings with status FLAGGED for this service."