From 07038e8c18b9d7646e539f9daee6c8247b51e322 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 28 Nov 2024 16:12:02 +0100 Subject: [PATCH 1/4] added service_business_type to new_dash_created_services models --- ...metric_daily_new_dash_created_services.sql | 7 ++- ...tric_monthly_new_dash_created_services.sql | 3 +- ...etric_weekly_new_dash_created_services.sql | 3 +- models/intermediate/kpis/schema.yml | 56 ++++++++++++++++++- 4 files changed, 64 insertions(+), 5 deletions(-) diff --git a/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_services.sql b/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_services.sql index 5bd16b5..7f3bf66 100644 --- a/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_services.sql +++ b/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_services.sql @@ -7,6 +7,11 @@ select -- Dimensions -- coalesce(icbs.id_deal, 'UNSET') as id_deal, case when icbsd.is_upgraded_service then 'YES' else 'NO' end as is_upgraded_service, + case + when icbsd.service_business_type = 'UNKNOWN' + then 'UNSET' + else coalesce(icbsd.service_business_type, 'UNSET') + end as service_business_type, coalesce(icbs.new_dash_version, 'UNSET') as new_dash_version, coalesce( icd.main_billing_country_iso_3_per_deal, 'UNSET' @@ -30,4 +35,4 @@ where and icbs.is_missing_id_deal = false and icbsd.service_detail_created_at_utc >= icbs.user_in_new_dash_since_timestamp_at_utc -group by 1, 2, 3, 4, 5, 6, 7, 8 +group by 1, 2, 3, 4, 5, 6, 7, 8, 9 diff --git a/models/intermediate/kpis/int_kpis__metric_monthly_new_dash_created_services.sql b/models/intermediate/kpis/int_kpis__metric_monthly_new_dash_created_services.sql index f896f6d..1b362c9 100644 --- a/models/intermediate/kpis/int_kpis__metric_monthly_new_dash_created_services.sql +++ b/models/intermediate/kpis/int_kpis__metric_monthly_new_dash_created_services.sql @@ -18,6 +18,7 @@ select cs.active_accommodations_per_deal_segmentation, cs.id_deal, -- Dimensions -- + cs.service_business_type, cs.new_dash_version, cs.is_upgraded_service, cs.main_billing_country_iso_3_per_deal, @@ -29,4 +30,4 @@ left join {{ ref("int_kpis__metric_daily_new_dash_created_services") }} cs on date_trunc('month', cs.date)::date = d.first_day_month where d.is_end_of_month = true and cs.id_deal is not null -group by 1, 2, 3, 4, 5, 6, 7, 8 +group by 1, 2, 3, 4, 5, 6, 7, 8, 9 diff --git a/models/intermediate/kpis/int_kpis__metric_weekly_new_dash_created_services.sql b/models/intermediate/kpis/int_kpis__metric_weekly_new_dash_created_services.sql index 5e660c8..3908a3d 100644 --- a/models/intermediate/kpis/int_kpis__metric_weekly_new_dash_created_services.sql +++ b/models/intermediate/kpis/int_kpis__metric_weekly_new_dash_created_services.sql @@ -18,6 +18,7 @@ select cs.active_accommodations_per_deal_segmentation, cs.id_deal, -- Dimensions -- + cs.service_business_type, cs.new_dash_version, cs.is_upgraded_service, cs.main_billing_country_iso_3_per_deal, @@ -29,4 +30,4 @@ left join {{ ref("int_kpis__metric_daily_new_dash_created_services") }} cs on date_trunc('week', cs.date)::date = d.first_day_week where d.is_end_of_week = true and cs.id_deal is not null -group by 1, 2, 3, 4, 5, 6, 7, 8 +group by 1, 2, 3, 4, 5, 6, 7, 8, 9 diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index 6a48911..8f8fd89 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -5438,6 +5438,21 @@ models: - "YES" - "NO" + - name: service_business_type + data_type: string + description: | + Identifies the service type (Screening, Deposit Management, Protection) + according to New Pricing documentation. + Cannot be null. + tests: + - not_null + - accepted_values: + values: + - "SCREENING" + - "PROTECTION" + - "DEPOSIT_MANAGEMENT" + - "UNSET" + - name: new_dash_version data_type: string description: | @@ -5488,7 +5503,8 @@ models: - end_date, - service_name, - id_deal, - - active_accommodations_per_deal_segmentation. + - active_accommodations_per_deal_segmentation, + - service_business_type. tests: - dbt_utils.unique_combination_of_columns: @@ -5497,6 +5513,7 @@ models: - service_name - id_deal - active_accommodations_per_deal_segmentation + - service_business_type columns: - name: start_date @@ -5525,6 +5542,21 @@ models: tests: - not_null + - name: service_business_type + data_type: string + description: | + Identifies the service type (Screening, Deposit Management, Protection) + according to New Pricing documentation. + Cannot be null. + tests: + - not_null + - accepted_values: + values: + - "SCREENING" + - "PROTECTION" + - "DEPOSIT_MANAGEMENT" + - "UNSET" + - name: is_upgraded_service data_type: string description: | @@ -5595,7 +5627,8 @@ models: - end_date, - service_name, - id_deal, - - active_accommodations_per_deal_segmentation. + - active_accommodations_per_deal_segmentation, + - service_business_type. tests: - dbt_utils.unique_combination_of_columns: @@ -5604,6 +5637,7 @@ models: - service_name - id_deal - active_accommodations_per_deal_segmentation + - service_business_type columns: - name: start_date @@ -5632,6 +5666,21 @@ models: tests: - not_null + - name: service_business_type + data_type: string + description: | + Identifies the service type (Screening, Deposit Management, Protection) + according to New Pricing documentation. + Cannot be null. + tests: + - not_null + - accepted_values: + values: + - "SCREENING" + - "PROTECTION" + - "DEPOSIT_MANAGEMENT" + - "UNSET" + - name: is_upgraded_service data_type: string description: | @@ -5733,6 +5782,7 @@ models: - by_new_dash_version - by_has_upgraded_service - by_service + - by_service_business_type - name: dimension_value data_type: string @@ -5797,6 +5847,7 @@ models: - by_new_dash_version - by_has_upgraded_service - by_service + - by_service_business_type - name: dimension_value data_type: string @@ -5854,6 +5905,7 @@ models: - by_new_dash_version - by_has_upgraded_service - by_service + - by_service_business_type - name: dimension_value data_type: string From 4e6690c013b429fcedff9c222e6cca5af3f4802d Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Fri, 29 Nov 2024 09:59:35 +0100 Subject: [PATCH 2/4] API verifications model --- .../cross/int_api_verifications.sql | 90 ++++++++ models/intermediate/cross/schema.yml | 205 ++++++++++++++++++ 2 files changed, 295 insertions(+) create mode 100644 models/intermediate/cross/int_api_verifications.sql diff --git a/models/intermediate/cross/int_api_verifications.sql b/models/intermediate/cross/int_api_verifications.sql new file mode 100644 index 0000000..399762d --- /dev/null +++ b/models/intermediate/cross/int_api_verifications.sql @@ -0,0 +1,90 @@ +with + int_athena__verifications as (select * from {{ ref("int_athena__verifications") }}), + int_edeposit__verifications as ( + select * from {{ ref("int_edeposit__verifications") }} + ) +select + av.id_verification, + av.id_booking, + av.id_user_partner, + av.id_accommodation, + av.version, + av.verification_source, + av.verification_status, + av.nightly_fee_local, + av.number_nights, + av.email_flag, + av.phone_flag, + av.watch_list, + av.channel, + av.checkin_at_utc, + av.checkin_date_utc, + av.checkout_at_utc, + av.checkout_date_utc, + av.is_cancelled, + av.cancelled_at_utc, + av.cancelled_date_utc, + av.user_email, + av.guest_email, + av.guest_last_name, + av.guest_first_name, + av.guest_telephone, + av.company_name, + av.property_manager_name, + av.property_manager_email, + av.listing_name, + av.listing_town, + av.listing_country, + av.listing_postcode, + av.pets_allowed, + av.status_updated_at_utc, + av.status_updated_date_utc, + av.updated_at_utc, + av.athena_creation_at_utc, + av.athena_creation_date_utc, + av.created_at_utc, + av.created_date_utc +from int_athena__verifications av +union all +select + ev.id_verification, + ev.id_booking, + ev.id_user_partner, + ev.id_accommodation, + ev.version, + ev.verification_source, + ev.verification_status, + ev.nightly_fee_local, + ev.number_nights, + ev.email_flag, + ev.phone_flag, + ev.watch_list, + ev.channel, + ev.checkin_at_utc, + ev.checkin_date_utc, + ev.checkout_at_utc, + ev.checkout_date_utc, + ev.is_cancelled, + ev.cancelled_at_utc, + ev.cancelled_date_utc, + ev.user_email, + ev.guest_email, + ev.guest_last_name, + ev.guest_first_name, + ev.guest_telephone, + ev.company_name, + ev.property_manager_name, + ev.property_manager_email, + ev.listing_name, + ev.listing_town, + ev.listing_country, + ev.listing_postcode, + ev.pets_allowed, + ev.status_updated_at_utc, + ev.status_updated_date_utc, + ev.updated_at_utc, + ev.athena_creation_at_utc, + ev.athena_creation_date_utc, + ev.created_at_utc, + ev.created_date_utc +from int_edeposit__verifications ev diff --git a/models/intermediate/cross/schema.yml b/models/intermediate/cross/schema.yml index d277467..854719d 100644 --- a/models/intermediate/cross/schema.yml +++ b/models/intermediate/cross/schema.yml @@ -1181,3 +1181,208 @@ models: - name: listings_booked_in_month_churn_average_contribution data_type: numeric description: Listings Booked in Month churn rate (average approach). + + - name: int_api_verifications + description: + "This table holds records on verifications for Guesty and Edeposit bookings. + It contains details on validations checked on the guests, guest information + and some booking details like checkin-checkout date or the status of the verification. + The id values found here are completely unrelated to the ones found in Core DWH. + + Note that id_verifications and booking_id should normally be 1 to 1. + Though there are exception, the API will accept a duplicate booking and the users + will be charged for it. A duplicate would return a unique id_verification." + columns: + - name: id_verification + data_type: text + description: "unique Superhog generated id for this verification" + tests: + - unique + - not_null + + - name: id_booking + data_type: text + description: "unique Superhog generated id for a booking. + note that this could be duplicated and both will be charged, + it's up to the user to no generate duplicate verifications" + + - name: id_user_partner + data_type: text + description: "unique Superhog generated id for partner" + tests: + - not_null + + - name: id_accommodation + data_type: text + description: "unique Superhog generated id for a listing" + + - name: version + data_type: text + description: "value to identify if it is Guesty (V1) or E-deposit (V2)" + tests: + - accepted_values: + values: + - V1 + - V2 + + - name: verification_source + data_type: text + description: "source of the verification for the booking" + tests: + - accepted_values: + values: + - Guesty + - Edeposit + + - name: verification_status + data_type: text + description: "status of the verification" + + - name: nightly_fee_local + data_type: double precision + description: "fee charged per night" + + - name: number_nights + data_type: integer + description: "number of nights for the booking" + + - name: email_flag + data_type: text + description: "screening result for email" + + - name: phone_flag + data_type: text + description: "screening result for phone" + + - name: watch_list + data_type: text + description: "screening result of the guest" + + - name: channel + data_type: text + description: "" + + - name: checkin_at_utc + data_type: timestamp without time zone + description: "Timestamp of checkin for the booking" + + - name: checkin_date_utc + data_type: date + description: "Date of checkin for the booking" + + - name: checkout_at_utc + data_type: timestamp without time zone + description: "Timestamp of checkout for the booking" + + - name: checkout_date_utc + data_type: date + description: "Date of checkout for the booking" + + - name: is_cancelled + data_type: boolean + description: "" + + - name: cancelled_at_utc + data_type: timestamp without time zone + description: "Timestamp of cancellation of the booking" + + - name: cancelled_date_utc + data_type: date + description: "Date of cancellation for the booking" + + - name: user_email + data_type: text + description: "" + + - name: guest_email + data_type: text + description: "" + + - name: guest_last_name + data_type: text + description: "" + + - name: guest_first_name + data_type: text + description: "" + + - name: guest_telephone + data_type: text + description: "" + + - name: company_name + data_type: text + description: "" + + - name: property_manager_name + data_type: text + description: "" + + - name: property_manager_email + data_type: text + description: "" + + - name: listing_name + data_type: text + description: "" + + - name: listing_town + data_type: text + description: "" + + - name: listing_country + data_type: text + description: "" + + - name: listing_postcode + data_type: text + description: "" + + - name: pets_allowed + data_type: boolean + description: "" + + - name: level_of_protection_amount + data_type: integer + description: "" + + - name: level_of_protection_currency + data_type: text + description: "" + + - name: status_updated_at_utc + data_type: timestamp without time zone + description: "Timestamp when status was last updated" + + - name: status_updated_date_utc + data_type: date + description: "Date of last status update of the verification" + + - name: updated_at_utc + data_type: timestamp without time zone + description: "Timestamp of last updated of the verification" + + - name: updated_date_utc + data_type: date + description: "Date of last update of the verification" + + - name: athena_creation_at_utc + data_type: timestamp without time zone + description: + "Athena timestamp referring to when the booking was created. + It's provided by Guesty, but is not mandatory. + In case of doubt use created_at_utc or created_date_utc fields" + + - name: athena_creation_date_utc + data_type: date + description: "Athena date referring to when the booking was created. + It's provided by Guesty, but is not mandatory. + In case of doubt use created_at_utc or created_date_utc fields" + + - name: created_at_utc + data_type: timestamp without time zone + description: "Timestamp of creation of the verification in the system" + + - name: created_date_utc + data_type: date + description: "Date of creation of the verification in the system" From c6a03d531aa9bf33b678bfcca5545f91fdbfe097 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Fri, 29 Nov 2024 10:06:15 +0100 Subject: [PATCH 3/4] Cleaned commit --- ...metric_daily_new_dash_created_services.sql | 7 +-- ...tric_monthly_new_dash_created_services.sql | 3 +- ...etric_weekly_new_dash_created_services.sql | 3 +- models/intermediate/kpis/schema.yml | 56 +------------------ 4 files changed, 5 insertions(+), 64 deletions(-) diff --git a/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_services.sql b/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_services.sql index 7f3bf66..5bd16b5 100644 --- a/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_services.sql +++ b/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_services.sql @@ -7,11 +7,6 @@ select -- Dimensions -- coalesce(icbs.id_deal, 'UNSET') as id_deal, case when icbsd.is_upgraded_service then 'YES' else 'NO' end as is_upgraded_service, - case - when icbsd.service_business_type = 'UNKNOWN' - then 'UNSET' - else coalesce(icbsd.service_business_type, 'UNSET') - end as service_business_type, coalesce(icbs.new_dash_version, 'UNSET') as new_dash_version, coalesce( icd.main_billing_country_iso_3_per_deal, 'UNSET' @@ -35,4 +30,4 @@ where and icbs.is_missing_id_deal = false and icbsd.service_detail_created_at_utc >= icbs.user_in_new_dash_since_timestamp_at_utc -group by 1, 2, 3, 4, 5, 6, 7, 8, 9 +group by 1, 2, 3, 4, 5, 6, 7, 8 diff --git a/models/intermediate/kpis/int_kpis__metric_monthly_new_dash_created_services.sql b/models/intermediate/kpis/int_kpis__metric_monthly_new_dash_created_services.sql index 1b362c9..f896f6d 100644 --- a/models/intermediate/kpis/int_kpis__metric_monthly_new_dash_created_services.sql +++ b/models/intermediate/kpis/int_kpis__metric_monthly_new_dash_created_services.sql @@ -18,7 +18,6 @@ select cs.active_accommodations_per_deal_segmentation, cs.id_deal, -- Dimensions -- - cs.service_business_type, cs.new_dash_version, cs.is_upgraded_service, cs.main_billing_country_iso_3_per_deal, @@ -30,4 +29,4 @@ left join {{ ref("int_kpis__metric_daily_new_dash_created_services") }} cs on date_trunc('month', cs.date)::date = d.first_day_month where d.is_end_of_month = true and cs.id_deal is not null -group by 1, 2, 3, 4, 5, 6, 7, 8, 9 +group by 1, 2, 3, 4, 5, 6, 7, 8 diff --git a/models/intermediate/kpis/int_kpis__metric_weekly_new_dash_created_services.sql b/models/intermediate/kpis/int_kpis__metric_weekly_new_dash_created_services.sql index 3908a3d..5e660c8 100644 --- a/models/intermediate/kpis/int_kpis__metric_weekly_new_dash_created_services.sql +++ b/models/intermediate/kpis/int_kpis__metric_weekly_new_dash_created_services.sql @@ -18,7 +18,6 @@ select cs.active_accommodations_per_deal_segmentation, cs.id_deal, -- Dimensions -- - cs.service_business_type, cs.new_dash_version, cs.is_upgraded_service, cs.main_billing_country_iso_3_per_deal, @@ -30,4 +29,4 @@ left join {{ ref("int_kpis__metric_daily_new_dash_created_services") }} cs on date_trunc('week', cs.date)::date = d.first_day_week where d.is_end_of_week = true and cs.id_deal is not null -group by 1, 2, 3, 4, 5, 6, 7, 8, 9 +group by 1, 2, 3, 4, 5, 6, 7, 8 diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index 8f8fd89..6a48911 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -5438,21 +5438,6 @@ models: - "YES" - "NO" - - name: service_business_type - data_type: string - description: | - Identifies the service type (Screening, Deposit Management, Protection) - according to New Pricing documentation. - Cannot be null. - tests: - - not_null - - accepted_values: - values: - - "SCREENING" - - "PROTECTION" - - "DEPOSIT_MANAGEMENT" - - "UNSET" - - name: new_dash_version data_type: string description: | @@ -5503,8 +5488,7 @@ models: - end_date, - service_name, - id_deal, - - active_accommodations_per_deal_segmentation, - - service_business_type. + - active_accommodations_per_deal_segmentation. tests: - dbt_utils.unique_combination_of_columns: @@ -5513,7 +5497,6 @@ models: - service_name - id_deal - active_accommodations_per_deal_segmentation - - service_business_type columns: - name: start_date @@ -5542,21 +5525,6 @@ models: tests: - not_null - - name: service_business_type - data_type: string - description: | - Identifies the service type (Screening, Deposit Management, Protection) - according to New Pricing documentation. - Cannot be null. - tests: - - not_null - - accepted_values: - values: - - "SCREENING" - - "PROTECTION" - - "DEPOSIT_MANAGEMENT" - - "UNSET" - - name: is_upgraded_service data_type: string description: | @@ -5627,8 +5595,7 @@ models: - end_date, - service_name, - id_deal, - - active_accommodations_per_deal_segmentation, - - service_business_type. + - active_accommodations_per_deal_segmentation. tests: - dbt_utils.unique_combination_of_columns: @@ -5637,7 +5604,6 @@ models: - service_name - id_deal - active_accommodations_per_deal_segmentation - - service_business_type columns: - name: start_date @@ -5666,21 +5632,6 @@ models: tests: - not_null - - name: service_business_type - data_type: string - description: | - Identifies the service type (Screening, Deposit Management, Protection) - according to New Pricing documentation. - Cannot be null. - tests: - - not_null - - accepted_values: - values: - - "SCREENING" - - "PROTECTION" - - "DEPOSIT_MANAGEMENT" - - "UNSET" - - name: is_upgraded_service data_type: string description: | @@ -5782,7 +5733,6 @@ models: - by_new_dash_version - by_has_upgraded_service - by_service - - by_service_business_type - name: dimension_value data_type: string @@ -5847,7 +5797,6 @@ models: - by_new_dash_version - by_has_upgraded_service - by_service - - by_service_business_type - name: dimension_value data_type: string @@ -5905,7 +5854,6 @@ models: - by_new_dash_version - by_has_upgraded_service - by_service - - by_service_business_type - name: dimension_value data_type: string From edbeac253c09a3d2d7a23e232be9c5f7830fc121 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Fri, 29 Nov 2024 11:03:59 +0100 Subject: [PATCH 4/4] Name change --- ...ifications.sql => int_edeposit_and_athena_verifications.sql} | 0 models/intermediate/cross/schema.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename models/intermediate/cross/{int_api_verifications.sql => int_edeposit_and_athena_verifications.sql} (100%) diff --git a/models/intermediate/cross/int_api_verifications.sql b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql similarity index 100% rename from models/intermediate/cross/int_api_verifications.sql rename to models/intermediate/cross/int_edeposit_and_athena_verifications.sql diff --git a/models/intermediate/cross/schema.yml b/models/intermediate/cross/schema.yml index 854719d..a4f4d03 100644 --- a/models/intermediate/cross/schema.yml +++ b/models/intermediate/cross/schema.yml @@ -1182,7 +1182,7 @@ models: data_type: numeric description: Listings Booked in Month churn rate (average approach). - - name: int_api_verifications + - name: int_edeposit_and_athena_verifications description: "This table holds records on verifications for Guesty and Edeposit bookings. It contains details on validations checked on the guests, guest information