feat: data lifecycle with compression, retention, housekeeping and storage overview #64
No files matched your search
@@ -0,0 +1,61 @@
|
||||
// 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
|
||||
}
|
||||
@@ -151,6 +151,12 @@ type Querier interface {
|
||||
OpenIncident(ctx context.Context, arg OpenIncidentParams) (Incident, error)
|
||||
OpenIncidents(ctx context.Context) ([]Incident, error)
|
||||
OrgIDBySlug(ctx context.Context, slug string) (uuid.UUID, error)
|
||||
PurgeExpiredTokens(ctx context.Context, expiresAt *time.Time) (int64, error)
|
||||
// Incidents resolved before the oldest data still charted.
|
||||
PurgeIncidents(ctx context.Context, resolvedAt *time.Time) (int64, error)
|
||||
PurgeInvitations(ctx context.Context, expiresAt time.Time) (int64, error)
|
||||
// Delivered and given-up notifications; pending ones are still being worked.
|
||||
PurgeNotifications(ctx context.Context, createdAt time.Time) (int64, error)
|
||||
// Raw results bucketed by width since a point in time, for short ranges.
|
||||
RangeBuckets(ctx context.Context, arg RangeBucketsParams) ([]RangeBucketsRow, error)
|
||||
// The daily aggregate rebucketed by width, for ranges of months.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
-- name: PurgeNotifications :execrows
|
||||
-- Delivered and given-up notifications; pending ones are still being worked.
|
||||
DELETE FROM notifications WHERE status IN ('sent', 'failed') AND created_at < $1;
|
||||
|
||||
-- name: PurgeInvitations :execrows
|
||||
DELETE FROM invitations WHERE expires_at < $1 OR accepted_at < $1;
|
||||
|
||||
-- name: PurgeExpiredTokens :execrows
|
||||
DELETE FROM api_tokens WHERE expires_at < $1;
|
||||
|
||||
-- name: PurgeIncidents :execrows
|
||||
-- Incidents resolved before the oldest data still charted.
|
||||
DELETE FROM incidents WHERE resolved_at < $1;
|
||||
Reference in new issue
Block a user