From 7837bcfaae5c8238eefda649cb24b2387cb0dd15 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 6 May 2024 20:06:56 +0200 Subject: [PATCH] fix(task): only count unique tasks in a bucket when checking bucket limit This fixes a bug where the current number of tasks in a bucket was computed wrong when moving tasks into a bucket with a limit. Sometimes the bug would prevent adding a task to a bucket which seemed to have space left but ultimately failed when moving the task. --- pkg/models/tasks.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index f08b71123..8729cead2 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -640,6 +640,7 @@ func checkBucketLimit(s *xorm.Session, t *Task, bucket *Bucket) (err error) { if bucket.Limit > 0 { taskCount, err := s. Where("bucket_id = ?", bucket.ID). + GroupBy("task_id"). Count(&TaskBucket{}) if err != nil { return err