Files
uptimesebi/internal/store/copyfrom.go
T
Sebastian UnterschützandClaude Opus 5.5 00658d49a2 feat(store): add monitors, regions, agents and check result hypertable
check_results has no row-level security because TimescaleDB refuses
compression and continuous aggregates on such tables. Every results
query takes org_id as a parameter, which a test enforces.

Refs #10, #13

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 01:12:53 +01:00

86 lines
2.2 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: copyfrom.go
package store
import (
"context"
)
// iteratorForInsertCheckResults implements pgx.CopyFromSource.
type iteratorForInsertCheckResults struct {
rows []InsertCheckResultsParams
skippedFirstNextCall bool
}
func (r *iteratorForInsertCheckResults) Next() bool {
if len(r.rows) == 0 {
return false
}
if !r.skippedFirstNextCall {
r.skippedFirstNextCall = true
return true
}
r.rows = r.rows[1:]
return len(r.rows) > 0
}
func (r iteratorForInsertCheckResults) Values() ([]interface{}, error) {
return []interface{}{
r.rows[0].Time,
r.rows[0].OrgID,
r.rows[0].MonitorID,
r.rows[0].Region,
r.rows[0].CheckerID,
r.rows[0].Ok,
r.rows[0].LatencyMs,
r.rows[0].StatusCode,
r.rows[0].Error,
}, nil
}
func (r iteratorForInsertCheckResults) Err() error {
return nil
}
// check_results and its aggregates have no row-level security (see
// migration 00013). Every query here must filter by org_id.
func (q *Queries) InsertCheckResults(ctx context.Context, arg []InsertCheckResultsParams) (int64, error) {
return q.db.CopyFrom(ctx, []string{"check_results"}, []string{"time", "org_id", "monitor_id", "region", "checker_id", "ok", "latency_ms", "status_code", "error"}, &iteratorForInsertCheckResults{rows: arg})
}
// iteratorForInsertRecoveryCodes implements pgx.CopyFromSource.
type iteratorForInsertRecoveryCodes struct {
rows []InsertRecoveryCodesParams
skippedFirstNextCall bool
}
func (r *iteratorForInsertRecoveryCodes) Next() bool {
if len(r.rows) == 0 {
return false
}
if !r.skippedFirstNextCall {
r.skippedFirstNextCall = true
return true
}
r.rows = r.rows[1:]
return len(r.rows) > 0
}
func (r iteratorForInsertRecoveryCodes) Values() ([]interface{}, error) {
return []interface{}{
r.rows[0].UserID,
r.rows[0].CodeHash,
}, nil
}
func (r iteratorForInsertRecoveryCodes) Err() error {
return nil
}
func (q *Queries) InsertRecoveryCodes(ctx context.Context, arg []InsertRecoveryCodesParams) (int64, error) {
return q.db.CopyFrom(ctx, []string{"recovery_codes"}, []string{"user_id", "code_hash"}, &iteratorForInsertRecoveryCodes{rows: arg})
}