From 34a5b0d86e18634d5630d7592ddde24463b54fc2 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 11 Dec 2024 16:35:40 +0100 Subject: [PATCH] Adding missing field in S&P models --- .../int_screen_and_protect__verification_requests.sql | 9 ++++++--- models/intermediate/screen_and_protect/schema.yml | 4 +--- models/reporting/screen_and_protect/schema.yml | 7 +++++++ .../screen_and_protect__verification_requests.sql | 1 + models/staging/core/schema.yml | 2 +- models/staging/core/stg_core__apim_user.sql | 2 +- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/models/intermediate/screen_and_protect/int_screen_and_protect__verification_requests.sql b/models/intermediate/screen_and_protect/int_screen_and_protect__verification_requests.sql index fbe0863..05374e7 100644 --- a/models/intermediate/screen_and_protect/int_screen_and_protect__verification_requests.sql +++ b/models/intermediate/screen_and_protect/int_screen_and_protect__verification_requests.sql @@ -1,4 +1,4 @@ -{% set api_name = "CHECKINHEROAPI" %} +{% set api_name = "SCREENANDPROTECTAPI" %} with stg_screen_and_protect__verification_requests as ( @@ -13,8 +13,11 @@ select vr.id_booking, vr.id_user_partner, vr.id_accommodation, - ({{ adapter.quote("json_document_user_data") }} ->> 'FlaggedNotProtected')::boolean - as not_protected, + case + when (au.json_document_user_data ->> 'FlaggedNotProtected') = 'false' + then true + else false + end as is_protected, vr.protection_type, vr.protection_starting_level, vr.protection_basic_amount, diff --git a/models/intermediate/screen_and_protect/schema.yml b/models/intermediate/screen_and_protect/schema.yml index f947e52..6806202 100644 --- a/models/intermediate/screen_and_protect/schema.yml +++ b/models/intermediate/screen_and_protect/schema.yml @@ -30,12 +30,10 @@ models: data_type: text description: Identifier for the accommodation related to the booking. - - name: not_protected + - name: is_protected data_type: boolean description: | Indicates if the booking is protected or not. - It is kind of weird for being a negative statement, - so when false it means the booking is protected. tests: - not_null diff --git a/models/reporting/screen_and_protect/schema.yml b/models/reporting/screen_and_protect/schema.yml index a3c2857..2d52292 100644 --- a/models/reporting/screen_and_protect/schema.yml +++ b/models/reporting/screen_and_protect/schema.yml @@ -30,6 +30,13 @@ models: data_type: text description: Identifier for the accommodation related to the booking. + - name: is_protected + data_type: boolean + description: | + Indicates if the booking is protected or not. + tests: + - not_null + - name: protection_type data_type: text description: Specific protection type for the request. diff --git a/models/reporting/screen_and_protect/screen_and_protect__verification_requests.sql b/models/reporting/screen_and_protect/screen_and_protect__verification_requests.sql index 39ecb73..8161c43 100644 --- a/models/reporting/screen_and_protect/screen_and_protect__verification_requests.sql +++ b/models/reporting/screen_and_protect/screen_and_protect__verification_requests.sql @@ -9,6 +9,7 @@ select id_booking as id_booking, id_user_partner as id_user_partner, id_accommodation as id_accommodation, + is_protected as is_protected, protection_type as protection_type, protection_starting_level as protection_starting_level, protection_basic_amount as protection_basic_amount, diff --git a/models/staging/core/schema.yml b/models/staging/core/schema.yml index 5845ae9..a320691 100644 --- a/models/staging/core/schema.yml +++ b/models/staging/core/schema.yml @@ -1381,7 +1381,7 @@ models: - not_null - name: json_document_user_data - data_type: character varying + data_type: jsonb description: | "The json document that contains the user information" diff --git a/models/staging/core/stg_core__apim_user.sql b/models/staging/core/stg_core__apim_user.sql index d05df36..af724d2 100644 --- a/models/staging/core/stg_core__apim_user.sql +++ b/models/staging/core/stg_core__apim_user.sql @@ -4,7 +4,7 @@ with select {{ adapter.quote("UserId") }} as id_apim_user, {{ adapter.quote("ApimUserTypeId") }} as id_apim_user_type, - {{ adapter.quote("Json") }} as json_document_user_data, + {{ adapter.quote("Json") }}::jsonb as json_document_user_data, {{ adapter.quote("CreatedDate") }} as created_at_utc, cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc, {{ adapter.quote("UpdatedDate") }} as updated_at_utc,