Refs #63 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: housekeeping.sql
|
|
|
|
package store
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const purgeExpiredTokens = `-- name: PurgeExpiredTokens :execrows
|
|
DELETE FROM api_tokens WHERE expires_at < $1
|
|
`
|
|
|
|
func (q *Queries) PurgeExpiredTokens(ctx context.Context, expiresAt *time.Time) (int64, error) {
|
|
result, err := q.db.Exec(ctx, purgeExpiredTokens, expiresAt)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const purgeIncidents = `-- name: PurgeIncidents :execrows
|
|
DELETE FROM incidents WHERE resolved_at < $1
|
|
`
|
|
|
|
// Incidents resolved before the oldest data still charted.
|
|
func (q *Queries) PurgeIncidents(ctx context.Context, resolvedAt *time.Time) (int64, error) {
|
|
result, err := q.db.Exec(ctx, purgeIncidents, resolvedAt)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const purgeInvitations = `-- name: PurgeInvitations :execrows
|
|
DELETE FROM invitations WHERE expires_at < $1 OR accepted_at < $1
|
|
`
|
|
|
|
func (q *Queries) PurgeInvitations(ctx context.Context, expiresAt time.Time) (int64, error) {
|
|
result, err := q.db.Exec(ctx, purgeInvitations, expiresAt)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const purgeNotifications = `-- name: PurgeNotifications :execrows
|
|
DELETE FROM notifications WHERE status IN ('sent', 'failed') AND created_at < $1
|
|
`
|
|
|
|
// Delivered and given-up notifications; pending ones are still being worked.
|
|
func (q *Queries) PurgeNotifications(ctx context.Context, createdAt time.Time) (int64, error) {
|
|
result, err := q.db.Exec(ctx, purgeNotifications, createdAt)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|