Fix getting labels

Signed-off-by: kolaente <k@knt.li>
This commit is contained in:
kolaente 2020-02-15 19:17:02 +01:00
parent 19288fd3f9
commit 4f35e91d3b
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 3 additions and 1 deletions

View File

@ -154,8 +154,10 @@ func getLabelsByTaskIDs(opts *LabelByTaskIDsOptions) (ls []*labelWithTaskID, res
// Because of this whole thing, we need this extra switch here to only group by Task IDs if needed.
// Probably not the most ideal solution.
var groupBy = "labels.id,label_task.task_id"
var selectStmt = "labels.*, label_task.task_id"
if opts.GroupByLabelIDsOnly {
groupBy = "labels.id"
selectStmt = "labels.*"
}
// Get all labels associated with these tasks
@ -166,7 +168,7 @@ func getLabelsByTaskIDs(opts *LabelByTaskIDsOptions) (ls []*labelWithTaskID, res
}
err = x.Table("labels").
Select("labels.*, label_task.task_id").
Select(selectStmt).
Join("LEFT", "label_task", "label_task.label_id = labels.id").
Where(cond).
And("labels.title LIKE ?", "%"+opts.Search+"%").