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
|
// Check if we have any favorites or favorited lists and remove the favorites namespace from the list if not
|
||||||
var favoriteCount int64
|
cond := builder.
|
||||||
favoriteCount, err = s.
|
Select("tasks.id").
|
||||||
|
From("tasks").
|
||||||
Join("INNER", "lists", "tasks.list_id = lists.id").
|
Join("INNER", "lists", "tasks.list_id = lists.id").
|
||||||
Join("INNER", "namespaces", "lists.namespace_id = namespaces.id").
|
Join("INNER", "namespaces", "lists.namespace_id = namespaces.id").
|
||||||
Where(builder.And(builder.Eq{"tasks.is_favorite": true}, builder.In("namespaces.id", namespaceIDs))).
|
Where(builder.In("namespaces.id", namespaceIDs))
|
||||||
Count(&Task{})
|
|
||||||
|
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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -553,7 +562,7 @@ func (n *Namespace) ReadAll(s *xorm.Session, a web.Auth, search string, page int
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// Put it all together
|
// Put it all together
|
||||||
|
|
||||||
err = addListDetails(s, lists)
|
err = addListDetails(s, lists, a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue