fix(tasks): make sure tasks are sorted by position before recalculating them

This commit is contained in:
kolaente 2023-02-23 17:43:23 +01:00
parent 8b745ad599
commit ca6d1946da
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 8 additions and 2 deletions

View File

@ -1248,7 +1248,10 @@ func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) {
func recalculateTaskKanbanPositions(s *xorm.Session, bucketID int64) (err error) {
allTasks := []*Task{}
err = s.Where("bucket_id = ?", bucketID).Find(&allTasks)
err = s.
Where("bucket_id = ?", bucketID).
OrderBy("kanban_position asc").
Find(&allTasks)
if err != nil {
return
}
@ -1273,7 +1276,10 @@ func recalculateTaskKanbanPositions(s *xorm.Session, bucketID int64) (err error)
func recalculateTaskPositions(s *xorm.Session, listID int64) (err error) {
allTasks := []*Task{}
err = s.Where("list_id = ?", listID).Find(&allTasks)
err = s.
Where("list_id = ?", listID).
OrderBy("position asc").
Find(&allTasks)
if err != nil {
return
}