diff --git a/models/intermediate/core/int_core__check_in_cover_users_v2.sql b/models/intermediate/core/int_core__check_in_cover_users_v2.sql new file mode 100644 index 0000000..b9b7519 --- /dev/null +++ b/models/intermediate/core/int_core__check_in_cover_users_v2.sql @@ -0,0 +1,35 @@ +with + -- We could probably use int_core__user_host instead, but we need to add a + -- few fields to that model first if we want to do so. + stg_core__user as (select * from {{ ref("stg_core__user") }}), + int_core__vr_check_in_cover as ( + select * from {{ ref("int_core__vr_check_in_cover") }} + ), + hosts_with_check_in_cover as ( + select distinct vrcih.id_user_host + from int_core__vr_check_in_cover vrcih + where vrcih.created_at_utc >= current_date - interval '180 days' + ), + check_in_cover_added_date_utc as ( + select + vrcih.id_user_host, + min(vrcih.created_at_utc) as check_in_cover_added_date_utc + from int_core__vr_check_in_cover vrcih + group by 1 + ) +select + u.id_user as id_user_host, + u.id_deal, + u.last_name, + u.user_name, + u.first_name, + u.email as host_email, + u.phone_number, + u.joined_at_utc, + u.joined_date_utc, + ad.check_in_cover_added_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 +left join check_in_cover_added_date_utc ad on ad.id_user_host = u.id_user diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index f7e283b..85cc447 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -827,12 +827,30 @@ models: description: Timestamp of when the accommodation record was extracted from the backend into the DWH. - name: int_core__check_in_cover_users + latest_version: 1 + 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. + + The new candidate version for this model, v2, changes the strategy to + define which hosts are offering check in cover. v1 used to look at + the verification set configurations and added hosts which had the cover in + it. v2 instead simply assumes that hosts that have had Guest Journeys + which offer the cover in the last 30 natural days are relevant. This is + simpler, but considered good enough. This decision was made as part of the + migration to the Guest Products data model, which would have made sticking + to the old way extremely complex and error prone. + + versions: + - v: 1 + - v: 2 + columns: + - include: all + columns: - name: id_user_host data_type: character varying