Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions db/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func InitDB() {
db.AutoMigrate(&BountyStakeProcess{})

DB.MigrateTablesWithOrgUuid()
DB.DropLegacyBountySummaryColumn()
DB.MigrateOrganizationToWorkspace()

people := DB.GetAllPeople()
Expand Down Expand Up @@ -272,6 +273,12 @@ func (db database) MigrateTablesWithOrgUuid() {
}
}

func (db database) DropLegacyBountySummaryColumn() {
if db.db.Migrator().HasTable(&Bounty{}) && db.db.Migrator().HasColumn(&Bounty{}, "one_sentence_summary") {
db.db.Migrator().DropColumn(&Bounty{}, "one_sentence_summary")
}
}

func (db database) MigrateOrganizationToWorkspace() {
if (db.db.Migrator().HasTable(&Organization{}) && !db.db.Migrator().HasTable("workspaces")) {
db.db.Migrator().RenameTable(&Organization{}, "workspaces")
Expand Down
4 changes: 2 additions & 2 deletions db/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ type Bounty struct {
WantedType string `json:"wanted_type"`
Deliverables string `json:"deliverables"`
GithubDescription bool `json:"github_description"`
OneSentenceSummary string `json:"one_sentence_summary"`
OneSentenceSummary string `gorm:"-" json:"one_sentence_summary"`
EstimatedSessionLength string `json:"estimated_session_length"`
EstimatedCompletionDate string `json:"estimated_completion_date"`
Created int64 `json:"created"`
Expand Down Expand Up @@ -446,7 +446,7 @@ type NewBounty struct {
WantedType string `json:"wanted_type"`
Deliverables string `json:"deliverables"`
GithubDescription bool `json:"github_description"`
OneSentenceSummary string `json:"one_sentence_summary"`
OneSentenceSummary string `gorm:"-" json:"one_sentence_summary"`
EstimatedSessionLength string `json:"estimated_session_length"`
EstimatedCompletionDate string `json:"estimated_completion_date"`
Created int64 `json:"created"`
Expand Down
34 changes: 34 additions & 0 deletions db/structs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package db

import (
"sync"
"testing"

"gorm.io/gorm/schema"
)

func TestBountySummaryIsNotPersisted(t *testing.T) {
models := []struct {
name string
value interface{}
}{
{name: "Bounty", value: &Bounty{}},
{name: "NewBounty", value: &NewBounty{}},
}

for _, model := range models {
t.Run(model.name, func(t *testing.T) {
parsed, err := schema.Parse(model.value, &sync.Map{}, schema.NamingStrategy{})
if err != nil {
t.Fatalf("parse schema: %v", err)
}

if field := parsed.LookUpField("OneSentenceSummary"); field == nil || field.DBName != "" {
t.Fatalf("OneSentenceSummary should not be mapped to a database column, got %#v", field)
}
if field := parsed.LookUpField("one_sentence_summary"); field != nil {
t.Fatalf("one_sentence_summary should not be mapped to database field %q", field.Name)
}
})
}
}
2 changes: 2 additions & 0 deletions db/test_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func InitTestDB() {
db.AutoMigrate(&ChatWorkflowStatus{})
db.AutoMigrate(&BountyStakeProcess{})

TestDB.DropLegacyBountySummaryColumn()

people := TestDB.GetAllPeople()
for _, p := range people {
if p.Uuid == "" {
Expand Down
62 changes: 31 additions & 31 deletions docker/dummy-data/paid-bounties.sql

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions handlers/bounties.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,6 @@ func MigrateBounties(w http.ResponseWriter, r *http.Request) {
migrateBountyFinal.GithubDescription = GithuDescription
}

OneSentenceSummary, ok15 := migrateBounty["one_sentence_summary"].(string)
if !ok15 {
migrateBountyFinal.OneSentenceSummary = ""
} else {
migrateBountyFinal.OneSentenceSummary = OneSentenceSummary
}

EstimatedSessionLength, ok16 := migrateBounty["estimated_session_length"].(string)
if !ok16 {
migrateBountyFinal.EstimatedSessionLength = ""
Expand Down
2 changes: 1 addition & 1 deletion handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ func (h *bountyHandler) GenerateBountyResponse(bounties []db.NewBounty) []db.Bou
WantedType: bounty.WantedType,
Deliverables: bounty.Deliverables,
GithubDescription: bounty.GithubDescription,
OneSentenceSummary: bounty.OneSentenceSummary,
OneSentenceSummary: bounty.Title,
EstimatedSessionLength: bounty.EstimatedSessionLength,
EstimatedCompletionDate: bounty.EstimatedCompletionDate,
OrgUuid: bounty.WorkspaceUuid,
Expand Down
2 changes: 1 addition & 1 deletion handlers/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,7 @@ func TestGetBountiesByFeatureAndPhaseUuid(t *testing.T) {
WantedType: "",
Deliverables: "",
GithubDescription: false,
OneSentenceSummary: "",
OneSentenceSummary: "test-bounty",
EstimatedSessionLength: "",
EstimatedCompletionDate: "",
Created: 0,
Expand Down
58 changes: 57 additions & 1 deletion mocks/Database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.