trends.stumason.dev
TypeScript
Pull Request Opened
PR #34 opened: fix: handle unpopulated materialized view gracefully
Problem
After PR #33 changed the view to WITH NO DATA, two things break:
-
Scheduled refresh fails every 10 min —
REFRESH MATERIALIZED VIEW CONCURRENTLYrequires the view to be populated first. Every run throwsSQLSTATE[0A000]: CONCURRENTLY cannot be used when the materialized view is not populated. -
Homepage 500s —
GetVelocity::getCrossPlatform()queries the unpopulated view and crashes. The dashboard is completely down.
Fix
- RefreshCommand: Check
pg_matviews.ispopulated— if false, use regular (non-concurrent) refresh for initial population. Subsequent refreshes use CONCURRENTLY as before. - GetVelocity: Wrap the cross-platform query in try/catch. If the view is broken/empty, return
[]so the dashboard loads without that panel.
Impact
Dashboard will load immediately after deploy. Cross-platform data appears once the first scheduled refresh completes (~10 min).
+25
additions
-7
deletions
2
files changed