Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@olblak
Copy link
Member

@olblak olblak commented Mar 26, 2025

Refactor the database to store specific pipeline reports information such as name, result, or target scm ids directly in postgresql table column instead of querying them from jsonb column.

The goal is to improve performance.

Description

Test

Right now tested manually, including upgrade from Udash 0.7.0

Additional Information

Tradeoff

Potential improvement

@olblak olblak added the enhancement New feature or request label Mar 26, 2025
@olblak olblak changed the title refactor: db model refactor: database model to avoid postgres jsonb queries Mar 26, 2025
@olblak olblak merged commit eee1c55 into updatecli:main Mar 26, 2025
2 of 3 checks passed
@olblak olblak requested a review from Copilot March 26, 2025 20:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the database model to avoid querying jsonb columns by storing specific pipeline report information directly in PostgreSQL table columns, thereby improving performance. Key changes include removing old model definitions in favor of new ones in the pkg/model package, updating query functions and handlers to work with the new schema, and revising SQL queries to accommodate these structural changes.

Reviewed Changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/server/scmDBSpec.go Removed old DatabaseSCMRow definitions in favor of the new model.SCM struct.
pkg/server/scmDBQuery.go Updated dbGetScm to return model.SCM and adjusted usage accordingly.
pkg/server/scmDBHandler.go Updated function signatures and queries to use model.SCM instead of the old type.
pkg/server/reportHandler.go Revised report creation and query functions to work with the new schema.
pkg/server/reportDBSpec.go Removed outdated PipelineReportRow definitions.
pkg/server/reportDBQuery.go Refactored report insertion and search queries to use model.PipelineReport and new query logic.
pkg/model/scm.go Introduced new SCM model with appropriate fields.
pkg/model/pipelinereport.go Introduced new PipelineReport model with necessary pipeline fields.
.golangci.yml Updated linting configuration; added rules for package restrictions.
Files not reviewed (3)
  • go.mod: Language not supported
  • pkg/database/migrations/000004_alter_pipelineReports.down.sql: Language not supported
  • pkg/database/migrations/000004_alter_pipelineReports.up.sql: Language not supported

switch len(ids) {
// If no scm is found, we insert it
case 0:
id, err := dbInsertSCM(target.Scm.URL, target.Scm.Branch.Source)
Copy link

Copilot AI Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch value used in dbInsertSCM is taken from target.Scm.Branch.Source even though the condition checks target.Scm.Branch.Target; consider using the same branch field consistently.

Suggested change
id, err := dbInsertSCM(target.Scm.URL, target.Scm.Branch.Source)
id, err := dbInsertSCM(target.Scm.URL, target.Scm.Branch.Target)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant