You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add server-side pagination to /api/alerts endpoints
- Add _parse_pagination() helper: page/per_page query params with validation
(page >= 1, 1 <= per_page <= 500, 400 on invalid or non-integer input)
- _list_alerts() now returns paginated envelope: {alerts, page, per_page,
total, total_pages}; COUNT(*) shares the same WHERE clause so total
reflects the filtered set
- schema.sql: add idx_alerts_created_at index on alerts(created_at DESC)
- dashboard.js: always passes per_page=500 so the full queue is visible;
unwraps data.alerts from the envelope in all three loadAlerts() branches
- Update existing tests (test_app.py, test_rbac.py) to unwrap ["alerts"]
from the paginated response
- Add 26 new tests in test_pagination.py covering response shape, mechanics,
filter interaction, empty table, and validation for both endpoints
- README: update test counts to 142 pytest + 87 Go = 229 total
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ Security sits on a few specific choices. The ingest endpoint checks its API key
46
46
-**pgvector semantic similarity** — `POST /api/alerts` stores a fastembed embedding; `GET /api/alerts/<id>/similar` returns the top 5 by cosine distance
47
47
-**Kubernetes manifests** — `deploy/k8s/` covers Deployment, HPA, Ingress, and Namespace with a separate `Dockerfile.ingest-service` for the Go binary
48
48
-**GCP deployment** — `deploy/gcp/` (Cloud Run service YAML + Cloud Build pipeline) and `terraform/gcp/` provision the full stack
49
-
-116 pytest + 87 Go = **203 tests** covering the ingest API, auth/CSRF, RBAC, KPI math, encryption, audit trail, Kafka consumer, Redis SSE, pgvector similarity, and the full Go ingest handler and gRPC interceptor surface
49
+
-142 pytest + 87 Go = **229 tests** covering the ingest API, auth/CSRF, RBAC, KPI math, encryption, audit trail, Kafka consumer, Redis SSE, pgvector similarity, pagination, and the full Go ingest handler and gRPC interceptor surface
50
50
51
51
## Running the Project
52
52
@@ -168,7 +168,7 @@ flowchart LR
168
168
169
169
## Tests
170
170
171
-
**116 pytest + 87 Go = 203 tests.** The Python suite covers the ingest API, auth/CSRF, RBAC roles, the classify/escalate flow, KPI math (MTTR, SLA, escalation), filter query params, Fernet encryption at rest, audit trail, SSE live updates, Kafka consumer, Redis pub/sub, pgvector semantic similarity, and the seed and user-management CLIs. The Go suite tests the REST and gRPC ingest handlers, `apiKeyInterceptor` boundary conditions (empty key, no metadata, constant-time comparison, whitespace trimming), W3C traceparent parsing edge cases (Python OTel ≥ 1.44 `flags=03`, zero IDs, extra segments, invalid hex), and proto field mapping (`SourceIp→SourceIP`, `WorkflowRunId→WorkflowRunID`). Both suites run against a real PostgreSQL database (Docker on port 5433 for CI). Point `DATABASE_URL` at a throwaway database and run:
171
+
**142 pytest + 87 Go = 229 tests.** The Python suite covers the ingest API, auth/CSRF, RBAC roles, the classify/escalate flow, KPI math (MTTR, SLA, escalation), filter query params, server-side pagination, Fernet encryption at rest, audit trail, SSE live updates, Kafka consumer, Redis pub/sub, pgvector semantic similarity, and the seed and user-management CLIs. The Go suite tests the REST and gRPC ingest handlers, `apiKeyInterceptor` boundary conditions (empty key, no metadata, constant-time comparison, whitespace trimming), W3C traceparent parsing edge cases (Python OTel ≥ 1.44 `flags=03`, zero IDs, extra segments, invalid hex), and proto field mapping (`SourceIp→SourceIP`, `WorkflowRunId→WorkflowRunID`). Both suites run against a real PostgreSQL database (Docker on port 5433 for CI). Point `DATABASE_URL` at a throwaway database and run:
172
172
173
173
```bash
174
174
python -m pytest tests/ -v
@@ -184,7 +184,7 @@ python -m pytest tests/ -v
184
184
| Semantic search | fastembed embeddings stored in pgvector; `GET /api/alerts/<id>/similar` returns top-5 by cosine distance |
185
185
| Horizontal scaling | Redis pub/sub for multi-worker SSE; K8s HPA manifest scales ingest replicas on CPU/RPS |
186
186
| Cloud deployment | Cloud Run + Cloud Build (`deploy/gcp/`); Terraform provisions GCP infra (`terraform/gcp/`) |
187
-
| Test engineering |203 tests (116 Python + 87 Go) exercising boundary conditions, constant-time comparisons, W3C traceparent edge cases, and proto field mapping without a live database |
187
+
| Test engineering |229 tests (142 Python + 87 Go) exercising boundary conditions, constant-time comparisons, W3C traceparent edge cases, and proto field mapping without a live database |
0 commit comments