Skip to content

feat: add recent measurements API endpoint (#5) - #8

Open
reoshin wants to merge 6 commits into
mainfrom
feature/5-recent-measurements
Open

reoshin wants to merge 6 commits into
mainfrom
feature/5-recent-measurements

Conversation

@reoshin

@reoshin reoshin commented Nov 20, 2026 •

Copy link
Copy Markdown

Pull Request

Summary

  • Added GET /api/results to fetch the 100 most recent measurements from Supabase, ordered by received_at.
  • Return probe name, test name, revision number, start time, status, and metrics.
  • Use metric labels and units from the corresponding test revision.
  • Preserve null values and return an empty list when no results exist.
  • Dynamically combines measured values with their corresponding labels and units from the test revision that ran.
  • Handles missing configuration, failed database requests, and unexpected errors with HTTP 500 responses.
  • Added automated unit tests in tests/unit/results.spec.ts using mocked Supabase responses.
  • No schema changes or migrations required.

Related issue

Closes #5

Testing

  • Manually tested by accessing http://localhost:3000/api/results in the browser.
  • npm run test:unit: added 14 unit tests covering the results endpoint.
  • npm run build: passed
  • npm test: passed
  • npx supabase test db: 85 tests passed.

The added unit tests cover:

  • Single and multiple measurements.
  • Empty measurement lists.
  • Null and zero metric values.
  • Different metric definitions across test revisions.
  • Missing and unused metric definitions.
  • Missing Supabase configuration.
  • Failed Supabase responses and network errors.
  • Correct query parameters for ordering and limiting results to 100 measurements.

Checklist

  • I ran all tests and they passed, and I have recorded the results above.
  • I have updated all docs where necessary.
  • I have reviewed the code and can explain the changes.

@reoshin
reoshin marked this pull request as ready for review November 26, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make recent measurements available to the dashboard

1 participant