| Actor | Fragment | Worker | State |
|---|---|---|---|
| 736750 | 51864 | 51 | running |
| 736751 | 51864 | 51 | running |
| 736752 | 51865 | 51 | running |
| 736753 | 51865 | 51 | running |
| 736846 | 51859 | 51 | running |
| 736847 | 51859 | 51 | running |
| 736852 | 51860 | 51 | running |
| 736853 | 51860 | 51 | running |
| 736854 | 51861 | 51 | running |
| 736855 | 51861 | 51 | running |
| 736856 | 51862 | 51 | running |
| 736857 | 51862 | 51 | running |
CREATE MATERIALIZED VIEW opportunity.portfolio_last_transaction_mv AS
WITH account_last_transaction AS (
SELECT
account_id,
MAX(transaction_valuation_date) AS last_transaction_date
FROM olap.transactions_dm
WHERE
disabled_at IS NULL
GROUP BY
account_id
)
SELECT
atp.portfolio_id,
MAX(t.last_transaction_date) AS last_transaction_date,
'GET_PORTFOLIO_DAYS_SINCE_LAST_TRANSACTION' AS activity_name
FROM account_last_transaction AS t
JOIN insights.open_accounts_mv AS oa
ON oa.account_id = t.account_id
JOIN olap.account_to_portfolios_dm AS atp
ON atp.account_id = t.account_id
AND atp.disabled_at IS NULL
AND atp.effective_end_date IS NULL
JOIN olap.portfolios_dm AS p
ON p.portfolio_id = atp.portfolio_id
AND p.disabled_at IS NULL
AND NOT p.m_is_stub IS TRUE
GROUP BY
atp.portfolio_id