MySQL · 1424 bytes Raw Blame History
1 -- ─── domain_events ─────────────────────────────────────────────────
2
3 -- name: InsertDomainEvent :one
4 -- Returns the inserted row so callers that want to fire a follow-on
5 -- (e.g. NOTIFY for the worker pool) have the id without a re-read.
6 INSERT INTO domain_events (
7 actor_user_id, kind, repo_id, source_kind, source_id, public, payload
8 ) VALUES (
9 $1, $2, $3, $4, $5, $6, $7
10 )
11 RETURNING id, actor_user_id, kind, repo_id, source_kind, source_id, public, payload, created_at;
12
13 -- name: ListPublicEventsForActor :many
14 -- Public activity-feed slice for a user's profile. Returns only
15 -- public rows, recency-sorted. The handler additionally filters by
16 -- repo visibility against the viewer (a public event row on a repo
17 -- whose visibility flipped to private must not leak).
18 SELECT id, actor_user_id, kind, repo_id, source_kind, source_id, public, payload, created_at
19 FROM domain_events
20 WHERE actor_user_id = $1
21 AND public = true
22 ORDER BY created_at DESC
23 LIMIT $2 OFFSET $3;
24
25 -- name: ListEventsForRepo :many
26 -- Repo-scoped events, recency-sorted. No visibility filter — the
27 -- caller has already established read access to the repo.
28 SELECT id, actor_user_id, kind, repo_id, source_kind, source_id, public, payload, created_at
29 FROM domain_events
30 WHERE repo_id = $1
31 ORDER BY created_at DESC
32 LIMIT $2 OFFSET $3;
33