| Actor | Fragment | Worker | State |
|---|---|---|---|
| 741733 | 64387 | 51 | running |
| 741734 | 64387 | 51 | running |
| 747483 | 64384 | 51 | running |
| 747484 | 64384 | 51 | running |
| 747485 | 64385 | 51 | running |
| 747486 | 64385 | 51 | running |
| 747487 | 64386 | 51 | running |
| 747488 | 64386 | 51 | running |
| 747593 | 64391 | 51 | running |
| 747594 | 64391 | 51 | running |
| 747595 | 64388 | 51 | running |
| 747596 | 64388 | 51 | running |
CREATE MATERIALIZED VIEW opportunity.signal_account_balance_increase_mv AS
WITH signal_metrics AS (
SELECT
account_id,
dim_balance_date,
'GET_INVESTMENT_ACCOUNT_BALANCE_PERCENT_INCREASE_1D' AS activity_name,
(
market_value - prev_market_value
) / prev_market_value AS metric
FROM opportunity.account_balance_delta_mv AS account_balance_delta_mv_next
WHERE
market_value > prev_market_value
UNION ALL
SELECT
account_id,
dim_balance_date,
'GET_INVESTMENT_ACCOUNT_BALANCE_ABSOLUTE_INCREASE_1D' AS activity_name,
market_value - prev_market_value AS metric
FROM opportunity.account_balance_delta_mv AS account_balance_delta_mv_next
WHERE
market_value > prev_market_value
)
SELECT
c.opportunity_id,
c.activity_name,
s.account_id AS resource_id,
s.dim_balance_date AS fact_date
FROM signal_metrics AS s
JOIN opportunity.opportunity_conditions_mv AS c
ON c.activity_name = s.activity_name
WHERE
CASE c.op
WHEN 'GTE'
THEN s.metric >= c.threshold
WHEN 'GT'
THEN s.metric > c.threshold
WHEN 'LTE'
THEN s.metric <= c.threshold
WHEN 'LT'
THEN s.metric < c.threshold
WHEN 'EQ'
THEN s.metric = c.threshold
ELSE FALSE
END