Documentation
¶
Overview ¶
Package pgrepo is the bell's SQL adapter over the notification table.
Column contract: the adapter reads and writes the columns defined by framework migration 009 — user_id, workspace_id, type, title, body, link (legacy but referenced by every INSERT/SELECT here), dedup_key, once_per_month, read_at, created_at. Framework-table columns are framework-contract surface: product migrations must deprecate unused columns in product code but must NOT drop them — this SQL (and future framework migrations) references them (orkome field report #5: a product that retired link in its own code could not drop the column). Evolving the contract itself is a framework-side change.
Index ¶
- type Repo
- func (r *Repo) Allowed(ctx context.Context, userID, typ string) (bool, error)
- func (r *Repo) Archive(ctx context.Context, userID, notificationID string) error
- func (r *Repo) DeleteAged(ctx context.Context, archivedTTL, readTTL time.Duration, batch int) (int64, error)
- func (r *Repo) EmailAllowed(ctx context.Context, userID, typ string) (bool, error)
- func (r *Repo) Insert(ctx context.Context, n app.NotifyInput, now time.Time) (bool, error)
- func (r *Repo) List(ctx context.Context, userID string) ([]app.Preference, error)
- func (r *Repo) ListInbox(ctx context.Context, userID, workspaceID string, limit int) ([]app.Notification, error)
- func (r *Repo) MarkAllRead(ctx context.Context, userID string) error
- func (r *Repo) MarkRead(ctx context.Context, userID, notificationID string) error
- func (r *Repo) UnreadCount(ctx context.Context, userID, workspaceID string) (int, error)
- func (r *Repo) Upsert(ctx context.Context, userID, typ string, email, inApp *bool) (app.Preference, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func (*Repo) DeleteAged ¶ added in v0.4.1
func (r *Repo) DeleteAged(ctx context.Context, archivedTTL, readTTL time.Duration, batch int) (int64, error)
DeleteAged prunes expired notifications in batches (F8-4): archived rows older than archivedTTL and read-but-not-archived rows older than readTTL. Unread rows are never deleted — they are still the user's pending signal. Returns the number of rows deleted (batch-capped; run to a zero return or on the next tick to drain a large backlog).