Follow delvh's suggestion

This commit is contained in:
Lunny Xiao 2024-04-30 09:58:25 +08:00
parent f280c9bd98
commit b6fccc0581
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 3 additions and 17 deletions

View File

@ -9,8 +9,8 @@ import (
"fmt"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/util"
)
// ProjectIssue saves relation from issue to a project
@ -115,11 +115,11 @@ func (b *Board) moveIssuesToAnotherColumn(ctx context.Context, newColumn *Board)
return err
}
// MoveColumnsOnProject moves or keeps column in a project and sorts them inside that column
// MoveColumnsOnProject sorts columns in a project
func MoveColumnsOnProject(ctx context.Context, project *Project, sortedColumnIDs map[int64]int64) error {
return db.WithTx(ctx, func(ctx context.Context) error {
sess := db.GetEngine(ctx)
columnIDs := container.MapValues(sortedColumnIDs)
columnIDs := util.ValuesOfMap(sortedColumnIDs)
movedColumns, err := GetColumnsByIDs(ctx, project.ID, columnIDs)
if err != nil {
return err

View File

@ -1,14 +0,0 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package container
// MapValues returns a slice of all values in a map.
// TODO: remove this after Golang std lib has similar function but not golang.org/x/exp
func MapValues[K comparable, V any](m map[K]V) []V {
values := make([]V, 0, len(m))
for _, v := range m {
values = append(values, v)
}
return values
}