Fix getting favorite tasks
This commit is contained in:
parent
84184b16a5
commit
e13aa067ef
|
@ -392,12 +392,21 @@ func getFavoriteLists(s *xorm.Session, lists []*List, namespaceIDs []int64, doer
|
|||
}
|
||||
|
||||
// Check if we have any favorites or favorited lists and remove the favorites namespace from the list if not
|
||||
var favoriteCount int64
|
||||
favoriteCount, err = s.
|
||||
cond := builder.
|
||||
Select("tasks.id").
|
||||
From("tasks").
|
||||
Join("INNER", "lists", "tasks.list_id = lists.id").
|
||||
Join("INNER", "namespaces", "lists.namespace_id = namespaces.id").
|
||||
Where(builder.And(builder.Eq{"tasks.is_favorite": true}, builder.In("namespaces.id", namespaceIDs))).
|
||||
Count(&Task{})
|
||||
Where(builder.In("namespaces.id", namespaceIDs))
|
||||
|
||||
var favoriteCount int64
|
||||
favoriteCount, err = s.
|
||||
Where(builder.And(
|
||||
builder.Eq{"user_id": doer.ID},
|
||||
builder.Eq{"kind": FavoriteKindTask},
|
||||
builder.In("entity_id", cond),
|
||||
)).
|
||||
Count(&Favorite{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -553,7 +562,7 @@ func (n *Namespace) ReadAll(s *xorm.Session, a web.Auth, search string, page int
|
|||
//////////////////////
|
||||
// Put it all together
|
||||
|
||||
err = addListDetails(s, lists)
|
||||
err = addListDetails(s, lists, a)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue