feat(background): mark the payload-type backfill done at once when no observation is untyped (#244)

This commit is contained in:
MrAlders0n authored and GitHub committed 2026-10-19 19:44:22 -04:00
1 parent ded8708fec
commit d4e85cbf90
9 files changed
+420 -2

No files matched your search

+16
View File
@@ -2694,6 +2694,22 @@ func (q *Queries) GetTransportScopes(ctx context.Context) ([]GetTransportScopesR
return items, nil
}
const hasUntypedObservations = `-- name: HasUntypedObservations :one
SELECT EXISTS (
SELECT 1 FROM packet_observations
WHERE payload_type IS NULL AND id <= $1::bigint
) AS untyped
`
// Whether any observation up to @max_id lacks a payload type. A full scan, run at most once per
// process by the payload-type backfill.
func (q *Queries) HasUntypedObservations(ctx context.Context, maxID int64) (bool, error) {
row := q.db.QueryRow(ctx, hasUntypedObservations, maxID)
var untyped bool
err := row.Scan(&untyped)
return untyped, err
}
const insertChannelMessage = `-- name: InsertChannelMessage :one
WITH inserted AS (