Fixed labels not being queried correctly on tasks

This commit is contained in:
konrad 2019-03-22 22:03:41 +01:00
parent c42e22f352
commit 1dc14d5ddf
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -153,7 +153,7 @@ func getLabelsByTaskIDs(opts *LabelByTaskIDsOptions) (ls []*labelWithTaskID, err
requestOrNil = "label_task.label_id != null OR labels.created_by_id = ?" requestOrNil = "label_task.label_id != null OR labels.created_by_id = ?"
} }
// Get all labels associated with these labels // Get all labels associated with these tasks
var labels []*labelWithTaskID var labels []*labelWithTaskID
err = x.Table("labels"). err = x.Table("labels").
Select("labels.*, label_task.task_id"). Select("labels.*, label_task.task_id").
@ -161,7 +161,7 @@ func getLabelsByTaskIDs(opts *LabelByTaskIDsOptions) (ls []*labelWithTaskID, err
Where(requestOrNil, uidOrNil). Where(requestOrNil, uidOrNil).
Or(builder.In("label_task.task_id", opts.TaskIDs)). Or(builder.In("label_task.task_id", opts.TaskIDs)).
And("labels.title LIKE ?", "%"+opts.Search+"%"). And("labels.title LIKE ?", "%"+opts.Search+"%").
GroupBy("labels.id"). GroupBy("labels.id,label_task.task_id"). // This filters out doubles
Limit(getLimitFromPageIndex(opts.Page)). Limit(getLimitFromPageIndex(opts.Page)).
Find(&labels) Find(&labels)
if err != nil { if err != nil {