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 Abonnements."
],
"page.categories.unread_counter": "Anzahl der ungelesenen Artikel",
"page.new_category.title": "Neue Kategorie",
"page.new_user.title": "Neuer Benutzer",
"page.edit_category.title": "Kategorie bearbeiten: %s",

View File

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

View File

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

View File

@ -92,6 +92,7 @@
"Il y a %d abonnement.",
"Il y a %d abonnements."
],
"page.categories.unread_counter": "Nombre d'entrées non lues",
"page.new_category.title": "Nouvelle catégorie",
"page.new_user.title": "Nouvel Utilisateur",
"page.edit_category.title": "Modification de la catégorie : %s",
@ -372,4 +373,4 @@
"You are not authorized to access this resource (invalid username/password)": "Vous n'êtes pas autorisé à accéder à cette ressource (nom d'utilisateur / mot de passe incorrect)",
"Unable to fetch this resource (Status Code = %d)": "Impossible de récupérer cette ressource (code=%d)",
"Resource not found (404), this feed doesn't exists anymore, check the feed URL": "Page introuvable (404), cet abonnement n'existe plus, vérifiez l'adresse du flux"
}
}

View File

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

View File

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

View File

@ -92,6 +92,7 @@
"Er is %d feed.",
"Er zijn %d feeds."
],
"page.categories.unread_counter": "Aantal ongelezen vermeldingen",
"page.new_category.title": "Nieuwe categorie",
"page.new_user.title": "Nieuwe gebruiker",
"page.edit_category.title": "Bewerken van categorie: %s",
@ -370,4 +371,4 @@
"This website is temporarily unreachable (original error: %q)": "Deze website is tijdelijk onbereikbaar (originele error: %q)",
"This website is permanently unreachable (original error: %q)": "Deze website is permanent onbereikbaar (originele error: %q)",
"Website unreachable, the request timed out after %d seconds": "Website onbereikbaar, de request gaf een timeout na %d seconden"
}
}

View File

@ -93,6 +93,7 @@
"Są %d kanały.",
"Jest %d kanałów."
],
"page.categories.unread_counter": "Liczba nieprzeczytanych wpisów",
"page.new_category.title": "Nowa kategoria",
"page.new_user.title": "Nowy użytkownik",
"page.edit_category.title": "Edycja Kategorii: %s",
@ -378,4 +379,4 @@
"This website is temporarily unreachable (original error: %q)": "Ta strona jest tymczasowo niedostępna (błąd: %q)",
"This website is permanently unreachable (original error: %q)": "Ta strona jest niedostępna (błąd: %q)",
"Website unreachable, the request timed out after %d seconds": "Strona internetowa nieosiągalna, żądanie wygasło po %d sekundach"
}
}

View File

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

View File

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

View File

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

View File

@ -91,6 +91,7 @@
"page.categories.feed_count": [
"有 %d 个源"
],
"page.categories.unread_counter": "未读条目数",
"page.new_category.title": "新分类",
"page.new_user.title": "新用户",
"page.edit_category.title": "编辑分类 : %s",
@ -363,4 +364,4 @@
"This website is temporarily unreachable (original error: %q)": "该网站暂时不可达 (原始错误: %q)",
"This website is permanently unreachable (original error: %q)": "该网站永久不可达 (原始错误: %q)",
"Website unreachable, the request timed out after %d seconds": "网站不可达, 请求已在 %d 秒后超时"
}
}

View File

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

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)
}

View File

@ -20,7 +20,7 @@
<span class="item-title">
<a href="{{ route "categoryEntries" "categoryID" .ID }}">{{ .Title }}</a>
</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 class="item-meta">
<ul class="item-meta-info">