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

@ -92,6 +92,7 @@
"Es gibt %d Abonnement.", "Es gibt %d Abonnement.",
"Es gibt %d Abonnements." "Es gibt %d Abonnements."
], ],
"page.categories.unread_counter": "Anzahl der ungelesenen Artikel",
"page.new_category.title": "Neue Kategorie", "page.new_category.title": "Neue Kategorie",
"page.new_user.title": "Neuer Benutzer", "page.new_user.title": "Neuer Benutzer",
"page.edit_category.title": "Kategorie bearbeiten: %s", "page.edit_category.title": "Kategorie bearbeiten: %s",

View file

@ -92,6 +92,7 @@
"There is %d feed.", "There is %d feed.",
"There are %d feeds." "There are %d feeds."
], ],
"page.categories.unread_counter": "Number of unread entries",
"page.new_category.title": "New Category", "page.new_category.title": "New Category",
"page.new_user.title": "New User", "page.new_user.title": "New User",
"page.edit_category.title": "Edit Category: %s", "page.edit_category.title": "Edit Category: %s",

View file

@ -92,6 +92,7 @@
"Hay %d fuente.", "Hay %d fuente.",
"Hay %d fuentes." "Hay %d fuentes."
], ],
"page.categories.unread_counter": "Número de entradas no leídas",
"page.new_category.title": "Nueva categoría", "page.new_category.title": "Nueva categoría",
"page.new_user.title": "Nuevo usario", "page.new_user.title": "Nuevo usario",
"page.edit_category.title": "Editar categoría: %s", "page.edit_category.title": "Editar categoría: %s",

View file

@ -92,6 +92,7 @@
"Il y a %d abonnement.", "Il y a %d abonnement.",
"Il y a %d abonnements." "Il y a %d abonnements."
], ],
"page.categories.unread_counter": "Nombre d'entrées non lues",
"page.new_category.title": "Nouvelle catégorie", "page.new_category.title": "Nouvelle catégorie",
"page.new_user.title": "Nouvel Utilisateur", "page.new_user.title": "Nouvel Utilisateur",
"page.edit_category.title": "Modification de la catégorie : %s", "page.edit_category.title": "Modification de la catégorie : %s",

View file

@ -92,6 +92,7 @@
"C'è %d feed.", "C'è %d feed.",
"Ci sono %d feed." "Ci sono %d feed."
], ],
"page.categories.unread_counter": "Numero di voci non lette",
"page.new_category.title": "Nuova categoria", "page.new_category.title": "Nuova categoria",
"page.new_user.title": "Nuovo utente", "page.new_user.title": "Nuovo utente",
"page.edit_category.title": "Modifica categoria: %s", "page.edit_category.title": "Modifica categoria: %s",

View file

@ -92,6 +92,7 @@
"%d 個の記事があります。", "%d 個の記事があります。",
"%d 個の記事があります。" "%d 個の記事があります。"
], ],
"page.categories.unread_counter": "未読記事の数",
"page.new_category.title": "新規カテゴリ", "page.new_category.title": "新規カテゴリ",
"page.new_user.title": "新規ユーザー", "page.new_user.title": "新規ユーザー",
"page.edit_category.title": "カテゴリーを編集: %s", "page.edit_category.title": "カテゴリーを編集: %s",

View file

@ -92,6 +92,7 @@
"Er is %d feed.", "Er is %d feed.",
"Er zijn %d feeds." "Er zijn %d feeds."
], ],
"page.categories.unread_counter": "Aantal ongelezen vermeldingen",
"page.new_category.title": "Nieuwe categorie", "page.new_category.title": "Nieuwe categorie",
"page.new_user.title": "Nieuwe gebruiker", "page.new_user.title": "Nieuwe gebruiker",
"page.edit_category.title": "Bewerken van categorie: %s", "page.edit_category.title": "Bewerken van categorie: %s",

View file

@ -93,6 +93,7 @@
"Są %d kanały.", "Są %d kanały.",
"Jest %d kanałów." "Jest %d kanałów."
], ],
"page.categories.unread_counter": "Liczba nieprzeczytanych wpisów",
"page.new_category.title": "Nowa kategoria", "page.new_category.title": "Nowa kategoria",
"page.new_user.title": "Nowy użytkownik", "page.new_user.title": "Nowy użytkownik",
"page.edit_category.title": "Edycja Kategorii: %s", "page.edit_category.title": "Edycja Kategorii: %s",

View file

@ -92,6 +92,7 @@
"Existe %d fonte.", "Existe %d fonte.",
"Existem %d fontes." "Existem %d fontes."
], ],
"page.categories.unread_counter": "Numero de itens não lidos",
"page.new_category.title": "Nova categoria", "page.new_category.title": "Nova categoria",
"page.new_user.title": "Novo usuário", "page.new_user.title": "Novo usuário",
"page.edit_category.title": "Editar categoria: %s", "page.edit_category.title": "Editar categoria: %s",

View file

@ -93,6 +93,7 @@
"Есть %d подписки.", "Есть %d подписки.",
"Есть %d подписок." "Есть %d подписок."
], ],
"page.categories.unread_counter": "Количество непрочитанных записей",
"page.new_category.title": "Новая категория", "page.new_category.title": "Новая категория",
"page.new_user.title": "Новый пользователь", "page.new_user.title": "Новый пользователь",
"page.edit_category.title": "Изменить категорию: %s", "page.edit_category.title": "Изменить категорию: %s",

View file

@ -92,6 +92,7 @@
"%d besleme var.", "%d besleme var.",
"%d besleme var." "%d besleme var."
], ],
"page.categories.unread_counter": "Okunmamış iletilerin sayısı",
"page.new_category.title": "Yeni Kategori", "page.new_category.title": "Yeni Kategori",
"page.new_user.title": "Yeni Kullanıcı", "page.new_user.title": "Yeni Kullanıcı",
"page.edit_category.title": "Kategoriyi Düzenle: %s", "page.edit_category.title": "Kategoriyi Düzenle: %s",

View file

@ -91,6 +91,7 @@
"page.categories.feed_count": [ "page.categories.feed_count": [
"有 %d 个源" "有 %d 个源"
], ],
"page.categories.unread_counter": "未读条目数",
"page.new_category.title": "新分类", "page.new_category.title": "新分类",
"page.new_user.title": "新用户", "page.new_user.title": "新用户",
"page.edit_category.title": "编辑分类 : %s", "page.edit_category.title": "编辑分类 : %s",

View file

@ -8,10 +8,11 @@ import "fmt"
// Category represents a feed category. // Category represents a feed category.
type Category struct { type Category struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Title string `json:"title"` Title string `json:"title"`
UserID int64 `json:"user_id"` UserID int64 `json:"user_id"`
FeedCount int `json:"-"` FeedCount int `json:"-"`
TotalUnread int `json:"-"`
} }
func (c *Category) String() string { func (c *Category) String() string {

View file

@ -116,7 +116,11 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error
c.id, c.id,
c.user_id, c.user_id,
c.title, 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 FROM categories c
WHERE WHERE
user_id=$1 user_id=$1
@ -132,7 +136,7 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error
categories := make(model.Categories, 0) categories := make(model.Categories, 0)
for rows.Next() { for rows.Next() {
var category model.Category 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) return nil, fmt.Errorf(`store: unable to fetch category row: %v`, err)
} }

View file

@ -20,7 +20,7 @@
<span class="item-title"> <span class="item-title">
<a href="{{ route "categoryEntries" "categoryID" .ID }}">{{ .Title }}</a> <a href="{{ route "categoryEntries" "categoryID" .ID }}">{{ .Title }}</a>
</span> </span>
(<span title="{{ if eq .FeedCount 0 }}{{ t "page.categories.no_feed" }}{{ else }}{{ plural "page.categories.feed_count" .FeedCount .FeedCount }}{{ end }}">{{ .FeedCount }}</span>) (<span title="{{ t "page.categories.unread_counter" }}">{{ .TotalUnread }}</span>)
</div> </div>
<div class="item-meta"> <div class="item-meta">
<ul class="item-meta-info"> <ul class="item-meta-info">