From 5efd91dfbb4c09c24a44bb892f2ac0a563ea16c6 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 11 Jul 2024 15:36:32 +0200 Subject: [PATCH 1/7] Created model int_core__verification_request_booking_source to have easier access to host category type in different models --- ...e__verification_request_booking_source.sql | 32 +++++++++++++ models/intermediate/core/schema.yaml | 46 ++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 models/intermediate/core/int_core__verification_request_booking_source.sql diff --git a/models/intermediate/core/int_core__verification_request_booking_source.sql b/models/intermediate/core/int_core__verification_request_booking_source.sql new file mode 100644 index 0000000..917e67a --- /dev/null +++ b/models/intermediate/core/int_core__verification_request_booking_source.sql @@ -0,0 +1,32 @@ +with + stg_core__booking as (select * from {{ ref("stg_core__booking") }}), + stg_core__verification_request as ( + select * from {{ ref("stg_core__verification_request") }} + ), + booking_source as ( + select + vr.id_verification_request, + vr.id_user_guest, + vr.created_at_utc, + vr.created_date_utc, + b.id_booking, + case + when b.id_integration is not null + then 'PMS' + when vr.id_one_step_link is not null + then 'OSL' + else 'API or Manual' + end as source + from stg_core__verification_request vr + left join + stg_core__booking b + on b.id_verification_request = vr.id_verification_request + ) +select + bs.id_verification_request as id_verification_request, + bs.id_user_guest as id_user_guest, + bs.created_at_utc as created_at_utc, + bs.created_date_utc as created_date_utc, + bs.id_booking as id_booking, + bs.source as source +from booking_source bs diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index ad4c36d..27ac5ee 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -942,4 +942,48 @@ models: - name: has_fee_payment data_type: boolean description: | - True if guest payed the fee \ No newline at end of file + True if guest payed the fee + + + - name: int_core__verification_request_booking_source + description: + This model contains information on verification requests + and the category type of host that manages the associated + booking. + + columns: + - name: id_verification_request + data_type: bigint + description: + Id value for the verification request, there can be more + than 1 record for each verification request since they can + be associated to more than 1 booking + tests: + - not_null + + - name: id_user_guest + data_type: character varying + description: Id value for the guest + + - name: created_at_utc + data_type: timestamp without time zone + description: + Date and time of creation of the verification request + + - name: created_date_utc + data_type: date + description: + Date of creation of the verification request + + - name: id_booking + data_type: bigint + description: + Id value for the booking + + - name: source + data_type: text + description: + Source type of host of the booking, this could be either; + - PMS + - OSL + - API or Manual \ No newline at end of file From db04615039c9ca4f1b1da22bfb0cc4bfee19f6d0 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 11 Jul 2024 16:19:33 +0200 Subject: [PATCH 2/7] Removed bookings_id so we have unique values for id_verification_request, added details as to how we classify the hosts --- ...e__verification_request_booking_source.sql | 8 +++---- models/intermediate/core/schema.yaml | 22 ++++++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/models/intermediate/core/int_core__verification_request_booking_source.sql b/models/intermediate/core/int_core__verification_request_booking_source.sql index 917e67a..83ebec3 100644 --- a/models/intermediate/core/int_core__verification_request_booking_source.sql +++ b/models/intermediate/core/int_core__verification_request_booking_source.sql @@ -4,18 +4,19 @@ with select * from {{ ref("stg_core__verification_request") }} ), booking_source as ( - select + select distinct vr.id_verification_request, vr.id_user_guest, vr.created_at_utc, vr.created_date_utc, - b.id_booking, case when b.id_integration is not null then 'PMS' when vr.id_one_step_link is not null then 'OSL' - else 'API or Manual' + else 'API/MANUAL' + -- At this point we can't differentiate between these 2 categories so for + -- now we keep them together end as source from stg_core__verification_request vr left join @@ -27,6 +28,5 @@ select bs.id_user_guest as id_user_guest, bs.created_at_utc as created_at_utc, bs.created_date_utc as created_date_utc, - bs.id_booking as id_booking, bs.source as source from booking_source bs diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index 27ac5ee..30e479d 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -950,6 +950,14 @@ models: This model contains information on verification requests and the category type of host that manages the associated booking. + For PMS we use the id_integration from stg_core__booking, + if it isn't Null then the host is PMS type. + For OSL we use the id_one_step_link from stg_core__verification_request, + similarly if it isn't Null then the host is OSL type. + Finally if both id_integration and id_one_step_link are Null, + then we classify them as API/MANUAL. (At this point we can't + differentiate between these 2 categories so for now we keep + them together) columns: - name: id_verification_request @@ -960,6 +968,7 @@ models: be associated to more than 1 booking tests: - not_null + - unique - name: id_user_guest data_type: character varying @@ -975,15 +984,16 @@ models: description: Date of creation of the verification request - - name: id_booking - data_type: bigint - description: - Id value for the booking - - name: source data_type: text description: Source type of host of the booking, this could be either; - PMS - OSL - - API or Manual \ No newline at end of file + - API/MANUAL + tests: + - accepted_values: + values: + - 'PMS' + - 'OSL' + - 'API/MANUAL' \ No newline at end of file From 00502b15973e3264e5f4827f9b118e096ec7c64d Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 11 Jul 2024 16:26:41 +0200 Subject: [PATCH 3/7] Removed bookings_id so we have unique values for id_verification_request, added details as to how we classify the hosts --- models/intermediate/core/schema.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index 30e479d..762bf92 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -950,10 +950,11 @@ models: This model contains information on verification requests and the category type of host that manages the associated booking. - For PMS we use the id_integration from stg_core__booking, - if it isn't Null then the host is PMS type. - For OSL we use the id_one_step_link from stg_core__verification_request, - similarly if it isn't Null then the host is OSL type. + For PMS (Property Manager System) we use the id_integration + from stg_core__booking, if it isn't Null then the host is PMS type. + For OSL (One Step Link) we use the id_one_step_link from + stg_core__verification_request, similarly if it isn't Null then + the host is OSL type. Finally if both id_integration and id_one_step_link are Null, then we classify them as API/MANUAL. (At this point we can't differentiate between these 2 categories so for now we keep From 70c2c5f6bf1ebbc7f72f0a5cfb185a1f9ea152f0 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 11 Jul 2024 16:49:24 +0200 Subject: [PATCH 4/7] Removed guests_id and modified query structure --- ...e__verification_request_booking_source.sql | 42 +++++++------------ models/intermediate/core/schema.yaml | 7 +--- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/models/intermediate/core/int_core__verification_request_booking_source.sql b/models/intermediate/core/int_core__verification_request_booking_source.sql index 83ebec3..a1d942c 100644 --- a/models/intermediate/core/int_core__verification_request_booking_source.sql +++ b/models/intermediate/core/int_core__verification_request_booking_source.sql @@ -2,31 +2,19 @@ with stg_core__booking as (select * from {{ ref("stg_core__booking") }}), stg_core__verification_request as ( select * from {{ ref("stg_core__verification_request") }} - ), - booking_source as ( - select distinct - vr.id_verification_request, - vr.id_user_guest, - vr.created_at_utc, - vr.created_date_utc, - case - when b.id_integration is not null - then 'PMS' - when vr.id_one_step_link is not null - then 'OSL' - else 'API/MANUAL' - -- At this point we can't differentiate between these 2 categories so for - -- now we keep them together - end as source - from stg_core__verification_request vr - left join - stg_core__booking b - on b.id_verification_request = vr.id_verification_request ) -select - bs.id_verification_request as id_verification_request, - bs.id_user_guest as id_user_guest, - bs.created_at_utc as created_at_utc, - bs.created_date_utc as created_date_utc, - bs.source as source -from booking_source bs +select distinct + vr.id_verification_request, + vr.created_at_utc, + vr.created_date_utc, + case + when b.id_integration is not null + then 'PMS' + when vr.id_one_step_link is not null + then 'OSL' + else 'API/MANUAL' + -- At this point we can't differentiate between these 2 categories so for + -- now we keep them together + end as verification_request_booking_source +from stg_core__verification_request vr +left join stg_core__booking b on b.id_verification_request = vr.id_verification_request diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index 762bf92..ddbcac7 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -971,10 +971,6 @@ models: - not_null - unique - - name: id_user_guest - data_type: character varying - description: Id value for the guest - - name: created_at_utc data_type: timestamp without time zone description: @@ -985,7 +981,7 @@ models: description: Date of creation of the verification request - - name: source + - name: verification_request_booking_source data_type: text description: Source type of host of the booking, this could be either; @@ -993,6 +989,7 @@ models: - OSL - API/MANUAL tests: + - not_null - accepted_values: values: - 'PMS' From 2bfe3ccf3cc4fdf229c3b4b54a4e25b55f28d71d Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 11 Jul 2024 17:16:51 +0200 Subject: [PATCH 5/7] Added the new field to int_core__bookings and to int_core__verification_requests --- models/intermediate/core/int_core__bookings.sql | 7 +++++++ .../intermediate/core/int_core__verification_requests.sql | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/models/intermediate/core/int_core__bookings.sql b/models/intermediate/core/int_core__bookings.sql index e5e2323..79685b0 100644 --- a/models/intermediate/core/int_core__bookings.sql +++ b/models/intermediate/core/int_core__bookings.sql @@ -12,6 +12,9 @@ with ), int_core__booking_charge_events as ( select * from {{ ref("int_core__booking_charge_events") }} + ), + int_core__verification_request_booking_source as ( + select * from {{ ref("int_core__verification_request_booking_source") }} ) select b.id_booking, @@ -21,6 +24,7 @@ select b.id_accommodation, b.id_booking_source, b.id_verification_request, + vrbs.verification_request_booking_source, b.id_staging_host_booking, db.is_duplicate_booking, db.is_duplicating_booking_with_id, @@ -50,3 +54,6 @@ from stg_core__booking b left join stg_core__booking_state bs on b.id_booking_state = bs.id_booking_state left join int_core__duplicate_bookings db on b.id_booking = db.id_booking left join int_core__booking_charge_events bce on b.id_booking = bce.id_booking +left join + int_core__verification_request_booking_source vrbs + on vrbs.id_verification_request = b.id_verification_request diff --git a/models/intermediate/core/int_core__verification_requests.sql b/models/intermediate/core/int_core__verification_requests.sql index fbe13da..67fabbe 100644 --- a/models/intermediate/core/int_core__verification_requests.sql +++ b/models/intermediate/core/int_core__verification_requests.sql @@ -8,6 +8,9 @@ with ), int_core__verification_request_completed_date as ( select * from {{ ref("int_core__verification_request_completed_date") }} + ), + int_core__verification_request_booking_source as ( + select * from {{ ref("int_core__verification_request_booking_source") }} ) select vr.id_verification_request, @@ -39,6 +42,7 @@ select vr.is_deleted, vr.redirect_name, vr.id_one_step_link, + vrbs.verification_request_booking_source, vr.success_message, vr.summary, vr.rejection_reason, @@ -58,3 +62,6 @@ left join left join int_core__verification_request_completed_date vrcd on vr.id_verification_request = vrcd.id_verification_request +left join + int_core__verification_request_booking_source vrbs + on vrbs.id_verification_request = vr.id_verification_request From 3001db919acd0863d76f762ebf2e7e88675f87e5 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Fri, 12 Jul 2024 10:11:51 +0200 Subject: [PATCH 6/7] Added models in schema for intermediate --- models/intermediate/core/schema.yaml | 372 ++++++++++++++++++++++++++- 1 file changed, 371 insertions(+), 1 deletion(-) diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index ddbcac7..afcca42 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -994,4 +994,374 @@ models: values: - 'PMS' - 'OSL' - - 'API/MANUAL' \ No newline at end of file + - 'API/MANUAL' + + - name: int_core__verification_requests + description: + This is a table that shows all guest journey from our guests users with + each record matching each guest journey. + + It holds information about the guests like name, email, phone, etc.., as + well as dates regarding the process of the guest journey like when it + was started or finished. + columns: + - name: id_verification_request + data_type: bigint + description: + Unique, incremental, internal ID for the related verification + request. + + - name: uuid_verification_request + data_type: text + description: uuid for the related verification request. + + - name: id_verification_set + data_type: bigint + description: "" + + - name: id_superhog_verified_set + data_type: bigint + description: "" + + - name: id_payment_validation_set + data_type: bigint + description: "" + + - name: id_user_guest + data_type: character varying + description: Unique, incremental, internal ID for the guest user. + + - name: id_user_host + data_type: character varying + description: Unique, incremental, internal ID for the host user. + + - name: is_verification_request_complete + data_type: boolean + description: True if the verification request is considered + complete, AKA the guest has finished the full guest journey. + + - name: verification_url + data_type: character varying + description: "" + + - name: callback_url + data_type: character varying + description: "" + + - name: redirect_url + data_type: character varying + description: "" + + - name: logo + data_type: character varying + description: "" + + - name: guest_email + data_type: character varying + description: The email of the guest. + + - name: last_name + data_type: character varying + description: The last name of the guest. + + - name: first_name + data_type: character varying + description: The first name of the guest. + + - name: guest_phone_number + data_type: character varying + description: The phone number of the guest. + + - name: telephone_code + data_type: character varying + description: The telephone code of the guest. + + - name: guest_phone_number_2 + data_type: character varying + description: "" + + - name: verification_start_at_utc + data_type: timestamp without time zone + description: + The date and time at which the guest started the guest journey. + + - name: verification_start_date_utc + data_type: date + description: + The date on which the guest started the guest journey. + + - name: verification_end_at_utc + data_type: timestamp without time zone + description: + The date and time at which the guest finished the guest journey. + + - name: verification_end_date_utc + data_type: date + description: + The date on which the guest finished the guest journey. + + - name: link_used_at_utc + data_type: timestamp without time zone + description: + The date and time at which the guest used the link for the verification. + + - name: link_used_date_utc + data_type: date + description: + The date on which the guest used the link for the verification. + + - name: expire_at_utc + data_type: timestamp without time zone + description: + The date and time at which the link for the verification expires. + + - name: expire_date_utc + data_type: date + description: + The date on which the link for the verification expires. + + - name: is_deleted + data_type: boolean + description: | + True if the link for verification expired before finishing the + verification. + + - name: redirect_name + data_type: character varying + description: "" + + - name: id_one_step_link + data_type: bigint + description: "" + + - name: verification_request_booking_source + data_type: text + description: + Source type of host of the booking, this could be either; + - PMS + - OSL + - API/MANUAL + tests: + - not_null + - accepted_values: + values: + - 'PMS' + - 'OSL' + - 'API/MANUAL' + + - name: success_message + data_type: character varying + description: "" + + - name: summary + data_type: character varying + description: "" + + - name: rejection_reason + data_type: character varying + description: + Reason as to why the guest was rejected. + + - name: has_switched_to_mobile + data_type: boolean + description: | + True if the guest changed has switched to mobile + during the verification process. + + - name: is_verifier_rejected + data_type: boolean + description: "" + + - name: config + data_type: character varying + description: "" + + - name: metadata + data_type: character varying + description: "" + + - name: created_at_utc + data_type: timestamp without time zone + description: + The date and time at which the verification process was created. + + - name: created_date_utc + data_type: date + description: + The date on which the verification process was created. + + - name: updated_at_utc + data_type: timestamp without time zone + description: + The date and time at which the last update on the entry happened. + + - name: updated_date_utc + data_type: date + description: + The date on which the last update on the entry happened. + + - name: dwh_extracted_at_utc + data_type: timestamp with time zone + description: "" + + - name: int_core__bookings + description: "" + columns: + - name: id_booking + data_type: bigint + description: "The unique, Superhog generated id for this booking." + tests: + - unique + - not_null + + - name: id_user_guest + data_type: character varying + description: "The unique, Superhog generated id for the guest" + + - name: id_user_host + data_type: character varying + description: "The unique, Superhog generated id for the host" + + - name: id_integration + data_type: character varying + description: "" + + - name: id_accommodation + data_type: bigint + description: "The ID of the booked listing." + + - name: id_booking_source + data_type: bigint + description: "" + + - name: id_verification_request + data_type: bigint + description: "Id value for the verification request, there can be more than 1 record for each verification request since they can be associated to more than 1 booking" + + - name: verification_request_booking_source + data_type: text + description: + Source type of host of the booking, this could be either; + - PMS + - OSL + - API/MANUAL + tests: + - not_null + - accepted_values: + values: + - 'PMS' + - 'OSL' + - 'API/MANUAL' + + - name: id_staging_host_booking + data_type: bigint + description: "" + + - name: is_duplicate_booking + data_type: boolean + description: + A flag that identifies whether the booking is a duplicate. + + A booking is considered a duplicate if there's an older booking with the same user, + accomodation and check-in date. If there are two or more bookings with the same user, + accomodation and check-in date, the oldest one will have False as a value in this field, + and the other ones will have True as a value in this Failed." + + Put simply, if you don't want to receive duplicates, filter this field to True. + + - name: is_duplicating_booking_with_id + data_type: bigint + description: + "If is_duplicate_booking is True then gives id_booking" + + - name: booking_state + data_type: character varying + description: "" + + - name: check_in_at_utc + data_type: timestamp without time zone + description: "" + + - name: check_in_date_utc + data_type: date + description: "" + + - name: check_out_at_utc + data_type: timestamp without time zone + description: "" + + - name: check_out_date_utc + data_type: date + description: "" + + - name: check_in_sits_in_future + data_type: boolean + description: "" + + - name: check_out_sits_in_future + data_type: boolean + description: "" + + - name: booking_fee_local + data_type: numeric + description: "The fee to apply to the booking, in host currency." + + - name: booking_fee_charge_at_utc + data_type: timestamp without time zone + description: The point in time in which the booking should be invoiced. + This could be the check-in date of the booking or the date in which the guest verification + started, depending on the billing settings of the host. + + - name: booking_fee_charge_date_utc + data_type: date + description: The date in which the booking should be invoiced. + This could be the check-in date of the booking or the date in which the guest verification + started, depending on the billing settings of the host. + + - name: summary + data_type: character varying + description: "" + + - name: guest_email + data_type: character varying + description: "" + + - name: guest_last_name + data_type: character varying + description: "" + + - name: guest_first_name + data_type: character varying + description: "" + + - name: guest_telephone + data_type: character varying + description: "" + + - name: additional_guests + data_type: character varying + description: "" + + - name: unsubscribe_verification_reminder + data_type: boolean + description: "" + + - name: created_at_utc + data_type: timestamp without time zone + description: "Date and time of creation of the verification request" + + - name: created_date_utc + data_type: date + description: "Date of creation of the verification request" + + - name: updated_at_utc + data_type: timestamp without time zone + description: "" + + - name: updated_date_utc + data_type: date + description: "" + + - name: dwh_extracted_at_utc + data_type: timestamp with time zone + description: "" \ No newline at end of file From cf467145d024bc33601fe488a3d30b7841608d8d Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Fri, 12 Jul 2024 11:06:09 +0200 Subject: [PATCH 7/7] Fixed schema names --- models/intermediate/core/schema.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index afcca42..70efabd 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -1080,25 +1080,25 @@ models: data_type: character varying description: "" - - name: verification_start_at_utc + - name: verification_estimated_started_at_utc data_type: timestamp without time zone description: - The date and time at which the guest started the guest journey. + The estimated date and time at which the guest started the guest journey. - - name: verification_start_date_utc + - name: verification_estimated_started_date_utc data_type: date description: - The date on which the guest started the guest journey. + The estimated date on which the guest started the guest journey. - - name: verification_end_at_utc + - name: verification_estimated_completed_at_utc data_type: timestamp without time zone description: - The date and time at which the guest finished the guest journey. + The estimated date and time at which the guest finished the guest journey. - - name: verification_end_date_utc + - name: verification_estimated_completed_date_utc data_type: date description: - The date on which the guest finished the guest journey. + The estimated date on which the guest finished the guest journey. - name: link_used_at_utc data_type: timestamp without time zone