Files
Sebastian UnterschützandClaude Opus 5.5 d7c5cd711e
ci / image (pull_request) Successful in 3m18s
ci / build (pull_request) Successful in 8m38s
ci / test (pull_request) Successful in 12m6s
ci / lint (pull_request) Successful in 15m0s
feat: page long and truncated lists
Lists that were cut off by a fixed LIMIT, or could grow without bound,
are paged by keyset: the cursor holds the sort key and an ID, so pages
neither skip nor repeat items as others are added. The audit logs had a
timestamp-only cursor that could skip entries with equal times.

The API returns at most 100 items per list (limit takes up to 500) with
next_cursor and prev_cursor, passed back as after and before. The
console shows Newer/Older (or Previous/Next) links and To the start,
without JavaScript.

Paged: incidents (optionally of one monitor), a monitor's results and
evidence, a checker's results, the audit logs, members, maintenance
windows, firing Alertmanager alerts, the monitors API and the admin
lists of status pages and organizations, which move to their own admin
pages. A monitor's page shows its latest incidents and results and links
to all of them. The dashboard caps every group at 50 of its own monitors
with a link to a paged view of the group, and gains a search by name or
target. Lists filtered by permission after reading may show fewer items
on a page.

Closes #116

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

32 lines
840 B
Go

package store
import (
"os"
"regexp"
"strings"
"testing"
)
// TestResultQueriesFilterByOrg guards the tables that cannot use row-level
// security: every read of check results must be restricted to one org.
func TestResultQueriesFilterByOrg(t *testing.T) {
src, err := os.ReadFile("queries/check_results.sql")
if err != nil {
t.Fatal(err)
}
blocks := regexp.MustCompile(`(?m)^-- name: `).Split(string(src), -1)[1:]
if len(blocks) == 0 {
t.Fatal("no queries found")
}
for _, b := range blocks {
name, _, _ := strings.Cut(b, " ")
if strings.Contains(b, ":copyfrom") {
continue
}
// The organization is the first parameter, positional or named.
if !regexp.MustCompile(`(?i)WHERE[^;]*\borg_id\s*=\s*(\$1|sqlc\.arg\(org_id\))`).MatchString(b) {
t.Errorf("query %s does not filter by org_id = $1", name)
}
}
}