| Actor | Fragment | Worker | State |
|---|---|---|---|
| 104824 | 23664 | 26 | running |
| 104825 | 23664 | 26 | running |
| 104826 | 23657 | 26 | running |
| 104827 | 23657 | 26 | running |
| 104895 | 23653 | 26 | running |
| 104896 | 23653 | 26 | running |
| 104897 | 23654 | 26 | running |
| 104898 | 23654 | 26 | running |
| 104899 | 23655 | 26 | running |
| 104900 | 23655 | 26 | running |
| 104901 | 23656 | 26 | running |
| 104902 | 23656 | 26 | running |
CREATE MATERIALIZED VIEW adib_rm.client_cash_tiles_mv
WITH (
backfill_order=FIXED(asset_service.currencies_dm -> olap.clients_dm)
) AS
SELECT
c.id AS client_id,
JSONB_AGG(
JSONB_BUILD_OBJECT(
'accountId',
a.account_id,
'name',
a.name,
'number',
a.number,
'value',
JSONB_BUILD_OBJECT(
'amount',
CAST(iabs.available_balance AS VARCHAR),
'currency',
JSONB_BUILD_OBJECT('code', a.base_currency_code, 'symbol', cur.symbol)
),
'baseCurrency',
JSONB_BUILD_OBJECT('code', a.base_currency_code, 'symbol', cur.symbol)
)
) AS cash_tiles
FROM olap.clients_dm AS c
JOIN olap.accounts_to_clients_dm AS ac
ON ac.client_id = c.id
AND ac.disabled_at IS NULL
AND ac.effective_start_date <= CURRENT_TIMESTAMP
AND ac.effective_end_date IS NULL
JOIN adib_rm.accounts_plain_mv AS a
ON a.account_id = ac.account_id
LEFT JOIN asset_service.currencies_dm FOR SYSTEM_TIME AS OF PROCTIME() AS cur
ON cur.code = a.base_currency_code
LEFT JOIN adib_rm.investment_account_balance_snapshot_journal_mv AS iabs
ON iabs.account_id = a.account_id
WHERE
c.disabled_at IS NULL
AND a.product_type_id IN (
SELECT
product_type_id
FROM adib_rm.cash_product_type_ids_mv
)
GROUP BY
c.id