Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

1.1 KB
Raw Blame
drop view if exists v_alerts;

create or replace view v_alerts as
-- TODO: debug why this subquery doesn't work when run from Liquibase
--with agg_recipients as (
--    select
--        pulse_channel_id,
--        listagg(core_user.email,',') as recipients
--    from pulse_channel_recipient
--        left join core_user on pulse_channel_recipient.user_id = core_user.id
--    group by pulse_channel_id
--)
select
    pulse.id as entity_id,
    concat('pulse_', pulse.id) as entity_qualified_id,
    pulse.created_at,
    pulse.updated_at,
    creator_id,
    card_id,
    concat('card_', card_id) as card_qualified_id,
    alert_condition,
    pulse_channel.schedule_type,
    pulse_channel.schedule_day,
    pulse_channel.schedule_hour,
    archived,
    channel_type as recipient_type,
    NULL as recipients, -- recipients is constantly NULL for H2
    details as recipient_external
    from pulse
        left join pulse_card on pulse.id = pulse_card.pulse_id
        left join pulse_channel on pulse.id = pulse_channel.pulse_id
--        left join agg_recipients on pulse_channel.id = agg_recipients.pulse_channel_id
    where alert_condition is not null;