Skip to content

feat(engagement): add post_engagement_daily materialized view + tests (#181)#233

Merged
Azfe merged 2 commits into
developfrom
task/n04-03-02-post-engagement-daily
Jul 11, 2026
Merged

feat(engagement): add post_engagement_daily materialized view + tests (#181)#233
Azfe merged 2 commits into
developfrom
task/n04-03-02-post-engagement-daily

Conversation

@Azfe

@Azfe Azfe commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Materialize per-(post_id, day) metrics with an hourly pg_cron refresh (0 * * * *, max 1h dashboard lag) and a unique (post_id, day) index for REFRESH ... CONCURRENTLY. The MV lives in the private schema — materialized views support neither RLS nor security_invoker — and reads go through public.post_engagement_daily, an owner-rights view guarded by is_manager().
Sources are pre-aggregated and joined over a spine to avoid fan-out and to keep click_rate NULL when a day has no readers. Add fixed-dataset pgTAP covering the aggregation, the zero case, the index, the cron job and RBAC.

Closes #181

@Azfe
Azfe merged commit 2ad3ef0 into develop Jul 11, 2026
6 checks passed
@Azfe
Azfe deleted the task/n04-03-02-post-engagement-daily branch July 11, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant