mirror of https://github.com/go-gitea/gitea.git
Fix bug
This commit is contained in:
parent
cd2350eca3
commit
0aa451b9ab
|
@ -31,6 +31,7 @@
|
|||
project_id: 4
|
||||
title: Done
|
||||
creator_id: 2
|
||||
sorting: 0
|
||||
created_unix: 1588117528
|
||||
updated_unix: 1588117528
|
||||
|
||||
|
@ -49,6 +50,7 @@
|
|||
title: Backlog
|
||||
creator_id: 2
|
||||
default: true
|
||||
sorting: 1
|
||||
created_unix: 1588117528
|
||||
updated_unix: 1588117528
|
||||
|
||||
|
@ -67,6 +69,7 @@
|
|||
title: Backlog
|
||||
creator_id: 2
|
||||
default: true
|
||||
sorting: 0
|
||||
created_unix: 1588117528
|
||||
updated_unix: 1588117528
|
||||
|
||||
|
@ -76,5 +79,6 @@
|
|||
title: Uncategorized
|
||||
creator_id: 2
|
||||
default: true
|
||||
sorting: 1
|
||||
created_unix: 1588117528
|
||||
updated_unix: 1588117528
|
||||
|
|
|
@ -132,13 +132,14 @@ func IssueAssignOrRemoveProject(ctx context.Context, issue *Issue, doer *user_mo
|
|||
}
|
||||
|
||||
var maxSorting int64
|
||||
if _, err := db.GetEngine(ctx).Select("Max(sorting)").Table("project_issue").
|
||||
has, err := db.GetEngine(ctx).Select("Max(sorting)").Table("project_issue").
|
||||
Where("project_id=?", newProjectID).
|
||||
And("project_board_id=?", newColumnID).
|
||||
Get(&maxSorting); err != nil {
|
||||
Get(&maxSorting)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if maxSorting > 0 {
|
||||
if has {
|
||||
maxSorting++
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ func (b *Board) GetIssues(ctx context.Context) ([]*ProjectIssue, error) {
|
|||
issues := make([]*ProjectIssue, 0, 5)
|
||||
if err := db.GetEngine(ctx).Where("project_id=?", b.ProjectID).
|
||||
And("project_board_id=?", b.ID).
|
||||
OrderBy("sorting").
|
||||
Find(&issues); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -184,11 +185,12 @@ func NewBoard(ctx context.Context, board *Board) error {
|
|||
|
||||
if totalColumns > 0 {
|
||||
var maxSorting int8
|
||||
if _, err := db.GetEngine(ctx).Select("Max(sorting)").Table("project_board").
|
||||
Where("project_id=?", board.ProjectID).Get(&maxSorting); err != nil {
|
||||
has, err := db.GetEngine(ctx).Select("Max(sorting)").Table("project_board").
|
||||
Where("project_id=?", board.ProjectID).Get(&maxSorting)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if maxSorting > 0 {
|
||||
if has {
|
||||
board.Sorting = maxSorting + 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,8 +71,10 @@ func Test_moveIssuesToAnotherColumn(t *testing.T) {
|
|||
issues, err = column2.GetIssues(db.DefaultContext)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, issues, 2)
|
||||
assert.EqualValues(t, 1, issues[0].ID)
|
||||
assert.EqualValues(t, 3, issues[1].ID)
|
||||
assert.EqualValues(t, 3, issues[0].ID)
|
||||
assert.EqualValues(t, 0, issues[0].Sorting)
|
||||
assert.EqualValues(t, 1, issues[1].ID)
|
||||
assert.EqualValues(t, 1, issues[1].Sorting)
|
||||
}
|
||||
|
||||
func Test_MoveColumnsOnProject(t *testing.T) {
|
||||
|
|
|
@ -110,13 +110,14 @@ func (b *Board) moveIssuesToAnotherColumn(ctx context.Context, newColumn *Board)
|
|||
}
|
||||
|
||||
var maxSorting int8
|
||||
if _, err := db.GetEngine(ctx).Select("Max(sorting)").Table("project_issue").
|
||||
has, err := db.GetEngine(ctx).Select("Max(sorting)").Table("project_issue").
|
||||
Where("project_id=?", newColumn.ProjectID).
|
||||
And("project_board_id=?", newColumn.ID).
|
||||
Get(&maxSorting); err != nil {
|
||||
Get(&maxSorting)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if maxSorting > 0 {
|
||||
if has {
|
||||
maxSorting++
|
||||
}
|
||||
|
||||
|
@ -124,6 +125,9 @@ func (b *Board) moveIssuesToAnotherColumn(ctx context.Context, newColumn *Board)
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(issues) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return db.WithTx(ctx, func(ctx context.Context) error {
|
||||
for i, issue := range issues {
|
||||
|
|
Loading…
Reference in New Issue