diff --git a/models/intermediate/core/int_core__unified_user.sql b/models/intermediate/core/int_core__unified_user.sql index 4277f27..ef9c46d 100644 --- a/models/intermediate/core/int_core__unified_user.sql +++ b/models/intermediate/core/int_core__unified_user.sql @@ -1,11 +1,20 @@ -{% set test_account_type_name = "('TEST')" %} +{% set test_account_claim_type = "('TESTACCOUNT')" %} +{% set test_account_claim_value = "('1')" %} with stg_core__user as (select * from {{ ref("stg_core__user") }}), stg_core__superhog_user as (select * from {{ ref("stg_core__superhog_user") }}), stg_core__currency as (select * from {{ ref("stg_core__currency") }}), stg_core__country as (select * from {{ ref("stg_core__country") }}), - stg_core__account_type as (select * from {{ ref("stg_core__account_type") }}) + stg_core__account_type as (select * from {{ ref("stg_core__account_type") }}), + stg_core__claim as (select * from {{ ref("stg_core__claim") }}), + test_accounts as ( + select distinct id_user + from stg_core__claim + where + upper(claim_type) in {{ test_account_claim_type }} + and claim_value in {{ test_account_claim_value }} + ) select u.id_user, u.id_account_type, @@ -45,19 +54,10 @@ select su.number_of_properties, su.id_superhog_verified_set, su.id_user_verification_status, - case - when act.account_type_name in {{ test_account_type_name }} - then true - when u.email like '%@guardhog.com' - then true - when u.email like '%@superhog.com' - then true - when u.email like '%@truvi.com' - then true - else false - end as is_test_account + case when ta.id_user is not null then true else false end as is_test_account from stg_core__user as u inner join stg_core__superhog_user as su on u.id_user = su.id_superhoguser left join stg_core__currency cu on u.id_account_currency = cu.id_currency left join stg_core__country co on u.id_billing_country = co.id_country left join stg_core__account_type act on u.id_account_type = act.id_account_type +left join test_accounts ta on u.id_user = ta.id_user