1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

show #unread per category in category list, not #feeds

the number of feeds in the category is currently displayed twice, and a lot less
useful than the number of unread items in the category.
This commit is contained in:
pennae 2021-04-25 13:47:59 +02:00 committed by fguillot
parent de53d8762f
commit 1c9f000576
15 changed files with 34 additions and 17 deletions

View file

@ -116,7 +116,11 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error
c.id,
c.user_id,
c.title,
(SELECT count(*) FROM feeds WHERE feeds.category_id=c.id) AS count
(SELECT count(*) FROM feeds WHERE feeds.category_id=c.id) AS count,
(SELECT count(*)
FROM feeds
JOIN entries ON (feeds.id = entries.feed_id)
WHERE feeds.category_id = c.id AND entries.status = 'unread')
FROM categories c
WHERE
user_id=$1
@ -132,7 +136,7 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error
categories := make(model.Categories, 0)
for rows.Next() {
var category model.Category
if err := rows.Scan(&category.ID, &category.UserID, &category.Title, &category.FeedCount); err != nil {
if err := rows.Scan(&category.ID, &category.UserID, &category.Title, &category.FeedCount, &category.TotalUnread); err != nil {
return nil, fmt.Errorf(`store: unable to fetch category row: %v`, err)
}