Conversation
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Olivier Vernin <olivier@vernin.me>
There was a problem hiding this comment.
Pull request overview
This PR introduces first-class support for storing and querying Updatecli report labels by adding a new labels table, wiring label IDs into pipelineReports, and exposing a new read/search API under the pipeline routes.
Changes:
- Add
labelstable + migration, and addlabel_ids UUID[]topipelineReportswith a trigger to maintainlabels.last_pipeline_report_at. - Add
/api/pipeline/labels(GET) and/api/pipeline/labels/search(POST) handlers and route registrations. - Update report insertion to initialize labels and persist
label_ids; add endpoint tests for the new labels endpoint.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/server/labeldb_handlers.go | Adds list/search HTTP handlers for labels with optional filtering and “key-only” mode. |
| pkg/server/endpoints.go | Registers the new labels routes under /api/pipeline. |
| pkg/server/endpoints_test.go | Adds integration tests for GET /api/pipeline/labels and cleanup helper. |
| pkg/model/label.go | Introduces the Label model used by DB queries and API responses. |
| pkg/model/pipelinereport.go | Adds LabelIDs field to represent label relationships on reports. |
| pkg/database/label.go | Adds label CRUD/query helpers + label initialization logic. |
| pkg/database/report.go | Persists label_ids when inserting reports. |
| pkg/database/time_utils.go | Generalizes the date-range helper to accept a column name. |
| pkg/database/migrations/000007_create_labels_tables.*.sql | Creates/drops the labels table and indexes. |
| pkg/database/migrations/000008_alter_pipelineReports_tables.up.sql | Adds label_ids + trigger to sync last_pipeline_report_at. |
| pkg/database/migrations/000008_alter_pipelineReports_labels.down.sql | Drops the trigger/function and removes label_ids. |
| go.mod / go.sum | Bumps Go version and updates dependencies; adds a replace for yaml-jsonpath. |
| docker-compose.yaml | Removes deprecated compose version field. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Olivier Vernin <olivier@vernin.me>
There was a problem hiding this comment.
Pull request overview
This PR introduces first-class “labels” support for pipeline reports by adding a labels table + label_ids linkage on pipelineReports, and exposes new API endpoints to list/search labels and to filter reports/SCM summaries by labels.
Changes:
- Add label persistence (new
labelstable,pipelineReports.label_ids, trigger to maintainlabels.last_pipeline_report_at). - Add
/api/pipeline/labelsand/api/pipeline/labels/searchendpoints + tests. - Extend report/SCM search & summary queries to support label filtering; refactor some DB APIs to param structs.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/server/scmdb_handlers.go | Adds POST /api/pipeline/scms/search and refactors SCM listing/summary wiring |
| pkg/server/report_handlers.go | Improves handler error responses and adds label filters to report search |
| pkg/server/labeldb_handlers.go | Implements label list/search endpoints (needs swagger route fixes) |
| pkg/server/endpoints.go | Registers new labels + scms search endpoints (public/private routing) |
| pkg/server/endpoints_test.go | Adds tests for label endpoints and utilities for POST + deep field removal |
| pkg/database/label.go | Adds label CRUD/query helpers and label initialization routine |
| pkg/database/label_utils.go | Adds applyLabelFilter used by report/SCM queries (has correctness issues) |
| pkg/database/report.go | Adds label handling on insert, label filtering for searches, refactors params |
| pkg/database/scm.go | Adds params struct and label-aware SCM summary query |
| pkg/database/time_utils.go | Refactors date range filtering helper (has RFC3339 parsing mismatch) |
| pkg/database/migrations/000007_create_labels_tables.*.sql | Creates/drops labels table + indexes/constraints |
| pkg/database/migrations/000008_alter_pipelineReports_* | Adds/drops label_ids + trigger to sync label timestamps |
| pkg/model/label.go | Adds Label model (comment mismatch on Value) |
| pkg/model/pipelinereport.go | Adds LabelIDs field to report model |
| go.mod / go.sum | Dependency updates + replace directive for yaml-jsonpath fork |
| docker-compose.yaml | Removes compose version: key |
Comments suppressed due to low confidence (1)
pkg/database/time_utils.go:50
applyRangeFilterdocuments RFC3339 inputs but parses times using the layout2006-01-02 15:04:05Z07:00(space instead ofT). This will reject valid RFC3339 timestamps like2026-03-19T12:34:56Zand break start/end range filtering. Usetime.RFC3339(or accept both layouts) to match the API contract.
// 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.
func applyRangeFilter(columnName string, r dateRangeFilterParams) error {
if r.StartTime == "" && r.EndTime == "" && r.DateRangeDays > 0 {
start := time.Now().UTC().Add(-time.Duration(r.DateRangeDays) * 24 * time.Hour)
r.Query.Apply(
sm.Where(
psql.Raw(columnName+" > ?", start),
),
)
return nil
}
if r.StartTime == "" && r.EndTime == "" {
return nil
}
if r.StartTime == "" || r.EndTime == "" {
return fmt.Errorf("both startTime %q and endTime %q must be provided for time range filtering", r.StartTime, r.EndTime)
}
startT, err := time.Parse("2006-01-02 15:04:05Z07:00", r.StartTime)
if err != nil {
return fmt.Errorf("parsing startTime: %w", err)
}
endT, err := time.Parse("2006-01-02 15:04:05Z07:00", r.EndTime)
if err != nil {
return fmt.Errorf("parsing endTime: %w", err)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Olivier Vernin <olivier@vernin.me>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
pkg/database/time_utils.go:49
applyRangeFilterclaims RFC3339 input in the comment, but it parses timestamps using the layout"2006-01-02 15:04:05Z07:00"(missing theT). This will reject standard RFC3339 values like2006-01-02T15:04:05Z07:00that the API docs request. Usetime.RFC3339(or accept both layouts) for parsing start/end times.
// 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.
func applyRangeFilter(columnName string, r dateRangeFilterParams) error {
if r.StartTime == "" && r.EndTime == "" && r.DateRangeDays > 0 {
start := time.Now().UTC().Add(-time.Duration(r.DateRangeDays) * 24 * time.Hour)
r.Query.Apply(
sm.Where(
psql.Raw(columnName+" > ?", start),
),
)
return nil
}
if r.StartTime == "" && r.EndTime == "" {
return nil
}
if r.StartTime == "" || r.EndTime == "" {
return fmt.Errorf("both startTime %q and endTime %q must be provided for time range filtering", r.StartTime, r.EndTime)
}
startT, err := time.Parse("2006-01-02 15:04:05Z07:00", r.StartTime)
if err != nil {
return fmt.Errorf("parsing startTime: %w", err)
}
endT, err := time.Parse("2006-01-02 15:04:05Z07:00", r.EndTime)
if err != nil {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* Use variable of type uuid over string * Fix swagger doc * Check againt pgx error instead of sql Signed-off-by: Olivier Vernin <olivier@vernin.me>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (1)
pkg/database/time_utils.go:49
applyRangeFiltersays inputs are RFC3339 (with a 'T'), but it parses using the layout "2006-01-02 15:04:05Z07:00" (with a space). This will reject valid RFC3339 timestamps like "2026-03-20T12:34:56Z". Usetime.RFC3339(or the correct layout with 'T') for both start and end parsing to match the API docs.
startT, err := time.Parse("2006-01-02 15:04:05Z07:00", r.StartTime)
if err != nil {
return fmt.Errorf("parsing startTime: %w", err)
}
endT, err := time.Parse("2006-01-02 15:04:05Z07:00", r.EndTime)
if err != nil {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Add a new "label" table to store Updatecli report labels
Add a new endpoint
/api/pipeline/labelsto retrieve labelsDescription
Test
To test this pull request, you can run the following commands:
make testAdditional Information
Tradeoff
Potential improvement