Added PMS info

This commit is contained in:
Joaquin Ossa 2025-01-20 14:26:37 +01:00
parent e28ea25e47
commit 5c71791f10
4 changed files with 56 additions and 21 deletions

View file

@ -31,24 +31,9 @@ with
main_billing_country_iso_3_per_deal
from {{ ref("int_core__deal") }}
),
integrations_per_user as (
select
icuh.id_deal,
sci.id_superhog_user as id_user,
scit.display_name as active_pms
from {{ ref("stg_core__integration") }} sci
left join
{{ ref("stg_core__integration_type") }} scit
on sci.id_integration_type = scit.id_integration_type
left join
{{ ref("int_core__user_host") }} icuh
on sci.id_superhog_user = icuh.id_user_host
where sci.is_active = true and icuh.is_missing_id_deal = false
),
integrations_per_deal as (
select id_deal, string_agg(distinct active_pms, ', ') as distinct_active_pms
from integrations_per_user
group by id_deal
select distinct id_deal, has_active_pms, active_pms_list
from {{ ref("int_core__user_host") }}
),
combined_deals as (
select
@ -71,10 +56,8 @@ with
select
cd.id_deal,
cd.main_deal_name,
case
when ipd.distinct_active_pms is null then false else true
end as has_active_pms,
ipd.distinct_active_pms as active_pms_list,
coalesce(ipd.has_active_pms, false) as has_active_pms,
ipd.active_pms_list,
cd.main_billing_country_iso_3_per_deal,
cd.effective_deal_start_date_utc,
cd.effective_deal_start_month,