feat: expose new endpoints - #435
Open
olblak wants to merge 5 commits into
Open
Conversation
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the server’s API surface to support reporting result history and filtering by pipeline result, including a new summary endpoint and related database/query enhancements.
Changes:
- Added
resultsfiltering to report search and SCM summary queries. - Introduced
POST /api/pipeline/reports/summaryto bucket report counts by result over a configurable time window. - Added a migration to backfill denormalized report columns and create an index to support efficient summary aggregation; updated tests and Swagger artifacts.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/server/var.go | Adds constants and new error messages for summary parameter validation. |
| pkg/server/scmdb_handlers.go | Extends SCM search request to accept results and threads it into SCM summary retrieval. |
| pkg/server/report_handlers.go | Adds results filter to report search and introduces the new reports summary endpoint + request/response types. |
| pkg/server/labeldb_handlers.go | Extracts SearchLabels request struct to a named type for Swagger/schema stability. |
| pkg/server/endpoints.go | Registers the new /api/pipeline/reports/summary route. |
| pkg/server/endpoints_test.go | Adds comprehensive endpoint tests for reports summary and adjusts expected error response for unknown report ID. |
| pkg/database/time_utils.go | Introduces shared time-range parsing helper and refactors range filtering logic. |
| pkg/database/scm.go | Adds results filtering to SCM summary output (post-query). |
| pkg/database/report.go | Adds report results filtering, SCM filter helper, and implements time-bucketed report summary query logic. |
| pkg/database/migrations/000010_fix_pipelineReports_denormalized_columns.up.sql | Backfills pipeline_result/pipeline_name from correct JSON keys and adds composite index for summary scans. |
| pkg/database/migrations/000010_fix_pipelineReports_denormalized_columns.down.sql | Drops the added composite index (non-destructive rollback). |
| pkg/database/database_test.go | Adds regression tests for bucket truncation correctness and migration backfill behavior. |
| docs/swagger.yaml | Updates Swagger spec to include new endpoints/types (but currently incomplete for new results request fields). |
| docs/swagger.json | Updates generated Swagger JSON (but currently incomplete for new results request fields). |
| docs/docs.go | Updates embedded Swagger template (but currently incomplete for new results request fields). |
| CONTRIBUTING.md | Documents the new reports summary endpoint in the endpoint list. |
Files not reviewed (1)
- docs/docs.go: Generated file
Suppressed comments (1)
docs/swagger.yaml:748
- The API schema for server.SearchSCMsRequest is missing the
resultsfield, even though the server-side request struct includes it to filter SCM summaries by pipeline result. This makes the Swagger docs incomplete for the new filter.
labels:
additionalProperties:
type: string
description: Labels filters SCM summaries by report labels.
type: object
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+62
to
+64
| // applyRangeFilter applies a time range filter to the given query based on the provided | ||
| // startTime and endTime strings in RFC3339 format. If both are empty and dateRangeDays is greater than zero, | ||
| // it filters records updated within the last dateRangeDays days. |
Comment on lines
+695
to
+699
| labels: | ||
| additionalProperties: | ||
| type: string | ||
| description: Labels is a map of labels to filter reports by. | ||
| type: object |
Signed-off-by: Olivier Vernin <olivier@vernin.me>
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.
Description
Test
To test this pull request, you can run the following commands:
make testAdditional Information
Tradeoff
Potential improvement