feat: expose new endpoints - #435
Merged
Merged
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.
Signed-off-by: Olivier Vernin <olivier@vernin.me>
* Set pagination limit * Use middleware for publicReadOnly endpoint * Zitadel requires a valid token and a configured role * Accept bare url for auth zero issuer URL * Validate timerange param * Allow to filter getscm query based date filter * Correctly close pg connection * fix report query qq Signed-off-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Olivier Vernin <olivier@vernin.me>
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
Copilot reviewed 27 out of 29 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- docs/docs.go: Generated file
Suppressed comments (2)
pkg/server/labeldb_handlers.go:160
- SearchLabels accepts start_time/end_time filters but does not validate that they are provided as a pair. A half-open range currently propagates a database parse error and is returned as a 500, even though it is a client input error. Align this endpoint with the other handlers by using validateTimeRangeParams and returning 400.
if err := c.ShouldBindJSON(&queryParams); err != nil {
logrus.Errorf("failed to read json body: %s", err)
c.JSON(http.StatusBadRequest, DefaultResponseModel{
Err: err.Error(),
})
pkg/server/labeldb_handlers.go:136
- SearchLabelsRequest documents start_time/end_time as RFC3339 with a 'T' separator, but the backend parses time ranges using the layout "2006-01-02 15:04:05Z07:00" (space separator). This mismatch will mislead API consumers and cause avoidable 400/500s.
// StartTime is the start time for the time range filter
// This is optional and can be used to filter labels by a specific start time
// Time format is RFC3339: 2006-01-02T15:04:05Z07:00
StartTime string `json:"start_time"`
// EndTime is the end time for the time range filter
// This is optional and can be used to filter labels by a specific end time
// Time format is RFC3339: 2006-01-02T15:04:05Z07:00
EndTime string `json:"end_time"`
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