feat(store): add status pages and their components
Composite foreign keys keep pages from listing monitors of other organizations, independent of row-level security. Refs #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
b831478143
commit
d820547e8c
9 files changed
+570
No files matched your search
@@ -137,6 +137,45 @@ func (q *Queries) GetChannel(ctx context.Context, id uuid.UUID) (NotificationCha
|
||||
return i, err
|
||||
}
|
||||
|
||||
const incidentsForMonitors = `-- name: IncidentsForMonitors :many
|
||||
SELECT id, org_id, monitor_id, started_at, resolved_at, cause FROM incidents
|
||||
WHERE monitor_id = ANY ($1::uuid[]) AND (resolved_at IS NULL OR resolved_at > $2)
|
||||
ORDER BY started_at DESC
|
||||
LIMIT 50
|
||||
`
|
||||
|
||||
type IncidentsForMonitorsParams struct {
|
||||
Ids []uuid.UUID
|
||||
Since *time.Time
|
||||
}
|
||||
|
||||
func (q *Queries) IncidentsForMonitors(ctx context.Context, arg IncidentsForMonitorsParams) ([]Incident, error) {
|
||||
rows, err := q.db.Query(ctx, incidentsForMonitors, arg.Ids, arg.Since)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []Incident{}
|
||||
for rows.Next() {
|
||||
var i Incident
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.OrgID,
|
||||
&i.MonitorID,
|
||||
&i.StartedAt,
|
||||
&i.ResolvedAt,
|
||||
&i.Cause,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listChannels = `-- name: ListChannels :many
|
||||
SELECT id, org_id, name, type, config, enabled, created_at, updated_at FROM notification_channels ORDER BY name
|
||||
`
|
||||
|
||||
Reference in new issue
Block a user