feat(api): Olufemi - API validation, pagination, stats & audit logging#1
Merged
Conversation
- Validate bbox has exactly 4 values [west, south, east, north] - Enforce longitude bounds (-180 to 180) and latitude bounds (-90 to 90) - Ensure west < east and south < north - Validate date strings follow YYYY-MM-DD format - Ensure start_date is earlier than end_date
- Add offset query parameter for cursor-based pagination
- Return total record count alongside results for frontend page controls
- Restructure response to {total, limit, offset, runs} envelope
- Refactor WHERE clause building to avoid SQL injection via safe parameterisation
- Returns total run count, completed runs in last 7 days - Breakdown by status (pending, running, completed, failed) - Breakdown by analysis type (deforestation, ice_melting, flooding) - Alert summary: total alerts and unacknowledged count - Feeds directly into the frontend Dashboard KPI summary cards
- Log every request: method, path, status code, duration_ms, client IP - Attach X-Response-Time-Ms header to all responses for frontend monitoring - Uses Starlette BaseHTTPMiddleware for non-blocking request interception - Helps trace slow endpoints and detect unusual access patterns in production
Goldokpa
added a commit
that referenced
this pull request
Mar 23, 2026
…ments feat(api): Olufemi - API validation, pagination, stats & audit logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four API improvements by Olufemi Taiwo (femi23) - API & Data Quality Lead:
offsetparam and returns{total, limit, offset, runs}envelope for frontend page controls/api/runs/statsreturning run counts by status/analysis type + alert summary for dashboard KPIsX-Response-Time-Msresponse headerTest plan
/api/runs/stats— confirm response shape/api/predict/json— confirm 422 error/api/runs?limit=10&offset=0— confirm pagination envelope returned🤖 Generated with Claude Code