mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-21 01:19:25 +02:00
Address remaining review feedback
- Use ParseIssueFilterStateIsClosed for ListProjects state parsing - Add SortTypeProjectColumnSorting const, replace magic string - Use GetIssueByRepoID and dedupe Add/Remove issue handlers - Migrate Column.Sorting from int8 to int (drops 127-column limit, allows the API to expose a normal int without truncation) - Introduce project_service.UpdateProject with optional.Option fields, use it from the API EditProject handler Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,7 @@ type Column struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
Title string
|
||||
Default bool `xorm:"NOT NULL DEFAULT false"` // issues not assigned to a specific column will be assigned to this column
|
||||
Sorting int8 `xorm:"NOT NULL DEFAULT 0"`
|
||||
Sorting int `xorm:"NOT NULL DEFAULT 0"`
|
||||
Color string `xorm:"VARCHAR(7)"`
|
||||
|
||||
ProjectID int64 `xorm:"INDEX NOT NULL"`
|
||||
@@ -128,8 +128,7 @@ func createDefaultColumnsForProject(ctx context.Context, project *Project) error
|
||||
})
|
||||
}
|
||||
|
||||
// maxProjectColumns max columns allowed in a project, this should not bigger than 127
|
||||
// because sorting is int8 in database
|
||||
// maxProjectColumns is the maximum number of columns allowed in a project.
|
||||
const maxProjectColumns = 20
|
||||
|
||||
// NewColumn adds a new project column to a given project
|
||||
@@ -149,7 +148,7 @@ func NewColumn(ctx context.Context, column *Column) error {
|
||||
if res.ColumnCount >= maxProjectColumns {
|
||||
return errors.New("NewBoard: maximum number of columns reached")
|
||||
}
|
||||
column.Sorting = int8(util.Iif(res.ColumnCount > 0, res.MaxSorting+1, 0))
|
||||
column.Sorting = int(util.Iif(res.ColumnCount > 0, res.MaxSorting+1, 0))
|
||||
_, err := db.GetEngine(ctx).Insert(column)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -83,9 +83,9 @@ func Test_MoveColumnsOnProject(t *testing.T) {
|
||||
columns, err := GetProjectColumns(t.Context(), project1.ID, db.ListOptionsAll)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, columns, 3)
|
||||
assert.EqualValues(t, 0, columns[0].Sorting) // even if there is no default sorting, the code should also work
|
||||
assert.EqualValues(t, 0, columns[1].Sorting)
|
||||
assert.EqualValues(t, 0, columns[2].Sorting)
|
||||
assert.Equal(t, 0, columns[0].Sorting) // even if there is no default sorting, the code should also work
|
||||
assert.Equal(t, 0, columns[1].Sorting)
|
||||
assert.Equal(t, 0, columns[2].Sorting)
|
||||
|
||||
err = MoveColumnsOnProject(t.Context(), project1, map[int64]int64{
|
||||
0: columns[1].ID,
|
||||
|
||||
Reference in New Issue
Block a user