From cbd1b4414fe336f739c4bd875c46b5d5f06b3dc4 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 25 Jun 2024 16:51:10 +0200 Subject: [PATCH 1/7] Created int model for host accommodations with check in hero --- .../core/int_core__check_in_cover_users | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 models/intermediate/core/int_core__check_in_cover_users diff --git a/models/intermediate/core/int_core__check_in_cover_users b/models/intermediate/core/int_core__check_in_cover_users new file mode 100644 index 0000000..a5e4613 --- /dev/null +++ b/models/intermediate/core/int_core__check_in_cover_users @@ -0,0 +1,62 @@ +with + stg_core__accommodation_to_user as ( + select * from {{ ref("stg_core__accommodation_to_user")}} + ), + stg_core__accommodation as ( + select * from {{ ref("stg_core__accommodation")}} + ), + stg_core__user as ( + select * from {{ ref("stg_core__user")}} + ), + stg_core__verification_set as ( + select + id_user_host, + id_verification_set + from {{ ref("stg_core__verification_set")}} + ), + stg_core__verification_set_to_verification_type as ( + select + id_verification_set, + id_verification_type + from {{ ref("stg_core__verification_set_to_verification_type")}} + ) +select + atu.id_user_owner as id_user_host, + atu.id_accommodation, + atu.accommodation_user_type, + atu.created_at_utc, + atu.updated_at_utc, + ac.friendly_name, + ac.id_country, + ac.is_active, + ac.town, + ac.address_line_1, + us.email, + us.joined_at_utc, + us.joined_date_utc, + us.last_name, + us.user_name, + us.first_name, + us.company_name, + us.phone_number +from + stg_core__accommodation_to_user atu +left join + stg_core__accommodation ac on atu.id_accommodation = ac.id_accommodation +left join + stg_core__user us on atu.id_user_owner = us.id_user +inner join ( + select + vs.id_user_host, + vs.id_verification_set, + vstvt.id_verification_set, + vstvt.id_verification_type + FROM + stg_core__verification_set vs + left join + stg_core__verification_set_to_verification_type vstvt on vs.id_verification_set = vstvt.id_verification_set + where + vs.is_active is true and + vstvt.id_verification_type = 15 +) as vsat on vsat.id_user_host = atu.id_user_owner +order by atu.id_user_owner, atu.id_accommodation From 2a897c6ead048d722e174d2cc7b7aa340ed41c15 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 26 Jun 2024 10:02:40 +0200 Subject: [PATCH 2/7] fixed model name and dump tables --- .../core/int_core__check_in_cover_users | 62 ------------------- ...e__check_in_cover_users_accommodations.sql | 51 +++++++++++++++ 2 files changed, 51 insertions(+), 62 deletions(-) delete mode 100644 models/intermediate/core/int_core__check_in_cover_users create mode 100644 models/intermediate/core/int_core__check_in_cover_users_accommodations.sql diff --git a/models/intermediate/core/int_core__check_in_cover_users b/models/intermediate/core/int_core__check_in_cover_users deleted file mode 100644 index a5e4613..0000000 --- a/models/intermediate/core/int_core__check_in_cover_users +++ /dev/null @@ -1,62 +0,0 @@ -with - stg_core__accommodation_to_user as ( - select * from {{ ref("stg_core__accommodation_to_user")}} - ), - stg_core__accommodation as ( - select * from {{ ref("stg_core__accommodation")}} - ), - stg_core__user as ( - select * from {{ ref("stg_core__user")}} - ), - stg_core__verification_set as ( - select - id_user_host, - id_verification_set - from {{ ref("stg_core__verification_set")}} - ), - stg_core__verification_set_to_verification_type as ( - select - id_verification_set, - id_verification_type - from {{ ref("stg_core__verification_set_to_verification_type")}} - ) -select - atu.id_user_owner as id_user_host, - atu.id_accommodation, - atu.accommodation_user_type, - atu.created_at_utc, - atu.updated_at_utc, - ac.friendly_name, - ac.id_country, - ac.is_active, - ac.town, - ac.address_line_1, - us.email, - us.joined_at_utc, - us.joined_date_utc, - us.last_name, - us.user_name, - us.first_name, - us.company_name, - us.phone_number -from - stg_core__accommodation_to_user atu -left join - stg_core__accommodation ac on atu.id_accommodation = ac.id_accommodation -left join - stg_core__user us on atu.id_user_owner = us.id_user -inner join ( - select - vs.id_user_host, - vs.id_verification_set, - vstvt.id_verification_set, - vstvt.id_verification_type - FROM - stg_core__verification_set vs - left join - stg_core__verification_set_to_verification_type vstvt on vs.id_verification_set = vstvt.id_verification_set - where - vs.is_active is true and - vstvt.id_verification_type = 15 -) as vsat on vsat.id_user_host = atu.id_user_owner -order by atu.id_user_owner, atu.id_accommodation diff --git a/models/intermediate/core/int_core__check_in_cover_users_accommodations.sql b/models/intermediate/core/int_core__check_in_cover_users_accommodations.sql new file mode 100644 index 0000000..ae964de --- /dev/null +++ b/models/intermediate/core/int_core__check_in_cover_users_accommodations.sql @@ -0,0 +1,51 @@ +with + stg_core__accommodation_to_user as ( + select * from {{ ref("stg_core__accommodation_to_user") }} + ), + stg_core__accommodation as (select * from {{ ref("stg_core__accommodation") }}), + stg_core__user as (select * from {{ ref("stg_core__user") }}), + stg_core__verification_set as ( + select id_user_host, id_verification_set, is_active + from {{ ref("stg_core__verification_set") }} + ), + stg_core__verification_set_to_verification_type as ( + select id_verification_set, id_verification_type + from {{ ref("stg_core__verification_set_to_verification_type") }} + ) +select + atu.id_user_owner as id_user_host, + atu.id_accommodation, + atu.accommodation_user_type, + atu.created_at_utc, + atu.updated_at_utc, + ac.friendly_name, + ac.id_country, + ac.is_active, + ac.town, + ac.address_line_1, + us.email, + us.joined_at_utc, + us.joined_date_utc, + us.last_name, + us.user_name, + us.first_name, + us.company_name, + us.phone_number +from stg_core__accommodation_to_user atu +left join stg_core__accommodation ac on atu.id_accommodation = ac.id_accommodation +left join stg_core__user us on atu.id_user_owner = us.id_user +inner join + ( + select + vs.id_user_host, + vs.id_verification_set, + vstvt.id_verification_set, + vstvt.id_verification_type + from stg_core__verification_set vs + left join + stg_core__verification_set_to_verification_type vstvt + on vs.id_verification_set = vstvt.id_verification_set + where vs.is_active is true and vstvt.id_verification_type = 15 + ) as vsat + on vsat.id_user_host = atu.id_user_owner +order by atu.id_user_owner, atu.id_accommodation From 431182a098d4a34d7dfcd0a5fc46a4d39368ff61 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 27 Jun 2024 08:40:25 +0200 Subject: [PATCH 3/7] Removed accommodations from the model --- ...e__check_in_cover_users_accommodations.sql | 54 ++++--------- models/intermediate/core/schema.yaml | 77 ++++++++++++++++++- 2 files changed, 93 insertions(+), 38 deletions(-) diff --git a/models/intermediate/core/int_core__check_in_cover_users_accommodations.sql b/models/intermediate/core/int_core__check_in_cover_users_accommodations.sql index ae964de..c8d6e36 100644 --- a/models/intermediate/core/int_core__check_in_cover_users_accommodations.sql +++ b/models/intermediate/core/int_core__check_in_cover_users_accommodations.sql @@ -1,8 +1,4 @@ with - stg_core__accommodation_to_user as ( - select * from {{ ref("stg_core__accommodation_to_user") }} - ), - stg_core__accommodation as (select * from {{ ref("stg_core__accommodation") }}), stg_core__user as (select * from {{ ref("stg_core__user") }}), stg_core__verification_set as ( select id_user_host, id_verification_set, is_active @@ -11,41 +7,25 @@ with stg_core__verification_set_to_verification_type as ( select id_verification_set, id_verification_type from {{ ref("stg_core__verification_set_to_verification_type") }} - ) -select - atu.id_user_owner as id_user_host, - atu.id_accommodation, - atu.accommodation_user_type, - atu.created_at_utc, - atu.updated_at_utc, - ac.friendly_name, - ac.id_country, - ac.is_active, - ac.town, - ac.address_line_1, - us.email, - us.joined_at_utc, - us.joined_date_utc, - us.last_name, - us.user_name, - us.first_name, - us.company_name, - us.phone_number -from stg_core__accommodation_to_user atu -left join stg_core__accommodation ac on atu.id_accommodation = ac.id_accommodation -left join stg_core__user us on atu.id_user_owner = us.id_user -inner join - ( - select - vs.id_user_host, - vs.id_verification_set, - vstvt.id_verification_set, - vstvt.id_verification_type + ), + hosts_with_check_in_cover as ( + select vs.id_user_host from stg_core__verification_set vs left join stg_core__verification_set_to_verification_type vstvt on vs.id_verification_set = vstvt.id_verification_set where vs.is_active is true and vstvt.id_verification_type = 15 - ) as vsat - on vsat.id_user_host = atu.id_user_owner -order by atu.id_user_owner, atu.id_accommodation + ) +select + u.id_user, + u.last_name, + u.user_name, + u.first_name, + u.email, + u.phone_number, + u.joined_at_utc, + u.joined_date_utc, + u.billing_town, + u.company_name +from stg_core__user u +inner join hosts_with_check_in_cover hcih on hcih.id_user_host = u.id_user diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index 543aec4..2d74584 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -813,4 +813,79 @@ models: - name: has_been_booked_within_last_12_months data_type: boolean - description: If the deal has had a booking created in the past 12 months. \ No newline at end of file + description: If the deal has had a booking created in the past 12 months. + - name: int_core__check_in_cover_users_accommodations + description: + columns: + - name: id_user_host + data_type: character varying + description: Unique id for Superhog host + + - name: id_accommodation + data_type: bigint + description: Unique id for accommodation + + - name: accommodation_user_type + data_type: bigint + description: "" + + - name: created_at_utc + data_type: timestamp without time zone + description: Date and time of creation of the accommodation + + - name: updated_at_utc + data_type: timestamp without time zone + description: Date and time of last update of the accommodation + + - name: friendly_name + data_type: character varying + description: Name of the accommodation + + - name: id_country + data_type: bigint + description: Country Id of the accommodation + + - name: is_active + data_type: boolean + description: Boolean value if the accommodation is active + + - name: town + data_type: character varying + description: Town where accommodation is located + + - name: address_line_1 + data_type: character varying + description: Address of the accommodation + + - name: email + data_type: character varying + description: email of host + + - name: joined_at_utc + data_type: timestamp without time zone + description: date and time when host joined Superhog + + - name: joined_date_utc + data_type: date + description: date when host joined Superhog + + - name: last_name + data_type: character varying + description: Last name of host + + - name: user_name + data_type: character varying + description: User name of host + + - name: first_name + data_type: character varying + description: First name of host + + - name: company_name + data_type: character varying + description: "" + + - name: phone_number + data_type: character varying + description: Phone number of host + From 04de0c822771ed6db44aeefbdd4bb63d4e5db003 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 27 Jun 2024 10:00:47 +0200 Subject: [PATCH 4/7] Changed name of model --- ...sers_accommodations.sql => int_core__check_in_cover_users.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename models/intermediate/core/{int_core__check_in_cover_users_accommodations.sql => int_core__check_in_cover_users.sql} (100%) diff --git a/models/intermediate/core/int_core__check_in_cover_users_accommodations.sql b/models/intermediate/core/int_core__check_in_cover_users.sql similarity index 100% rename from models/intermediate/core/int_core__check_in_cover_users_accommodations.sql rename to models/intermediate/core/int_core__check_in_cover_users.sql From 9950c4d9ae58e698a6ba21bb7153b7237b928651 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 27 Jun 2024 10:18:29 +0200 Subject: [PATCH 5/7] Fixed merge error --- models/intermediate/core/schema.yaml | 80 +++++++++------------------- 1 file changed, 24 insertions(+), 56 deletions(-) diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index 2d74584..8638548 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -814,78 +814,46 @@ models: - name: has_been_booked_within_last_12_months data_type: boolean description: If the deal has had a booking created in the past 12 months. - - name: int_core__check_in_cover_users_accommodations - description: + + - name: int_core__check_in_cover_users + description: "" columns: - - name: id_user_host + - name: id_user data_type: character varying - description: Unique id for Superhog host - - - name: id_accommodation - data_type: bigint - description: Unique id for accommodation - - - name: accommodation_user_type - data_type: bigint description: "" - - name: created_at_utc - data_type: timestamp without time zone - description: Date and time of creation of the accommodation - - - name: updated_at_utc - data_type: timestamp without time zone - description: Date and time of last update of the accommodation - - - name: friendly_name - data_type: character varying - description: Name of the accommodation - - - name: id_country - data_type: bigint - description: Country Id of the accommodation - - - name: is_active - data_type: boolean - description: Boolean value if the accommodation is active - - - name: town - data_type: character varying - description: Town where accommodation is located - - - name: address_line_1 - data_type: character varying - description: Address of the accommodation - - - name: email - data_type: character varying - description: email of host - - - name: joined_at_utc - data_type: timestamp without time zone - description: date and time when host joined Superhog - - - name: joined_date_utc - data_type: date - description: date when host joined Superhog - - name: last_name data_type: character varying - description: Last name of host + description: "" - name: user_name data_type: character varying - description: User name of host + description: "" - name: first_name data_type: character varying - description: First name of host + description: "" - - name: company_name + - name: email data_type: character varying description: "" - name: phone_number data_type: character varying - description: Phone number of host + description: "" + - name: joined_at_utc + data_type: timestamp without time zone + description: "" + + - name: joined_date_utc + data_type: date + description: "" + + - name: billing_town + data_type: character varying + description: "" + + - name: company_name + data_type: character varying + description: "" \ No newline at end of file From a4b16e74103ef3da7ff88cc4bd803729e51432af Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 27 Jun 2024 10:40:44 +0200 Subject: [PATCH 6/7] Completed the schema for the model --- models/intermediate/core/schema.yaml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index 8638548..96d1f1d 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -816,39 +816,44 @@ models: description: If the deal has had a booking created in the past 12 months. - name: int_core__check_in_cover_users - description: "" + description: + This model contains information about hosts that offer check in cover. + It has basic information on the users like name, phone, email or joined date. columns: - name: id_user data_type: character varying - description: "" + description: Unique id value for the user + tests: + - not_null + - unique - name: last_name data_type: character varying - description: "" + description: Last name of the user - name: user_name data_type: character varying - description: "" + description: User name of the user - name: first_name data_type: character varying - description: "" + description: First name of the user - name: email data_type: character varying - description: "" + description: Email of the user - name: phone_number data_type: character varying - description: "" + description: Phone number of the user - name: joined_at_utc data_type: timestamp without time zone - description: "" + description: Date and time the user joined - name: joined_date_utc data_type: date - description: "" + description: Date the user joined - name: billing_town data_type: character varying From cab300f7ddd8b76ac430fa530ebd7715d5a15861 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Thu, 27 Jun 2024 12:13:27 +0200 Subject: [PATCH 7/7] Addressed comments --- .../intermediate/core/int_core__check_in_cover_users.sql | 8 ++++---- models/intermediate/core/schema.yaml | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/models/intermediate/core/int_core__check_in_cover_users.sql b/models/intermediate/core/int_core__check_in_cover_users.sql index c8d6e36..e548761 100644 --- a/models/intermediate/core/int_core__check_in_cover_users.sql +++ b/models/intermediate/core/int_core__check_in_cover_users.sql @@ -1,12 +1,10 @@ with stg_core__user as (select * from {{ ref("stg_core__user") }}), stg_core__verification_set as ( - select id_user_host, id_verification_set, is_active - from {{ ref("stg_core__verification_set") }} + select * from {{ ref("stg_core__verification_set") }} ), stg_core__verification_set_to_verification_type as ( - select id_verification_set, id_verification_type - from {{ ref("stg_core__verification_set_to_verification_type") }} + select * from {{ ref("stg_core__verification_set_to_verification_type") }} ), hosts_with_check_in_cover as ( select vs.id_user_host @@ -15,6 +13,8 @@ with stg_core__verification_set_to_verification_type vstvt on vs.id_verification_set = vstvt.id_verification_set where vs.is_active is true and vstvt.id_verification_type = 15 + -- vs.isactive is to consider the current verification set used by the host + -- vstvt.id_verification_type = 15 is the value for check_in_cover verification ) select u.id_user, diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index 96d1f1d..f944a76 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -819,6 +819,9 @@ models: description: This model contains information about hosts that offer check in cover. It has basic information on the users like name, phone, email or joined date. + + This model is restricted to active user so it doesn't include historical data + like users that had check-in cover but are currently inactive. columns: - name: id_user data_type: character varying