feat(positions): add more debug logs

This commit is contained in:
kolaente 2024-10-31 18:46:09 +01:00
parent f1f1f669b3
commit d7eff8e43b
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 10 additions and 3 deletions

View File

@ -19,9 +19,11 @@ package models
import (
"math"
"code.vikunja.io/api/pkg/events"
"code.vikunja.io/api/pkg/web"
"xorm.io/xorm"
"code.vikunja.io/api/pkg/events"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/web"
)
type TaskPosition struct {
@ -113,6 +115,8 @@ func (tp *TaskPosition) Update(s *xorm.Session, a web.Auth) (err error) {
func RecalculateTaskPositions(s *xorm.Session, view *ProjectView, a web.Auth) (err error) {
log.Debugf("Recalculating task positions for view %d", view.ID)
// Using the collection so that we get all tasks, even in cases where we're dealing with a saved filter underneath
tc := &TaskCollection{
ProjectID: view.ProjectID,
@ -165,10 +169,13 @@ func RecalculateTaskPositions(s *xorm.Session, view *ProjectView, a web.Auth) (e
return
}
_, err = s.Insert(newPositions)
count, err := s.Insert(newPositions)
if err != nil {
return
}
log.Debugf("Inserted %d new positions for %d total tasks in view %d", count, len(allTasks), view.ID)
return events.Dispatch(&TaskPositionsRecalculatedEvent{
NewTaskPositions: newPositions,
})