4
0
Эх сурвалжийг харах

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.
pennae 5 жил өмнө
parent
commit
1c9f000576

+ 1 - 0
locale/translations/de_DE.json

@@ -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",

+ 2 - 1
locale/translations/en_US.json

@@ -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"
     ]
-}
+}

+ 2 - 1
locale/translations/es_ES.json

@@ -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"
     ]
-}
+}

+ 2 - 1
locale/translations/fr_FR.json

@@ -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"
-}
+}

+ 2 - 1
locale/translations/it_IT.json

@@ -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"
     ]
-}
+}

+ 2 - 1
locale/translations/ja_JP.json

@@ -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 年前"
     ]
-}
+}

+ 2 - 1
locale/translations/nl_NL.json

@@ -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"
-}
+}

+ 2 - 1
locale/translations/pl_PL.json

@@ -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"
-}
+}

+ 2 - 1
locale/translations/pt_BR.json

@@ -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"
     ]
-}
+}

+ 2 - 1
locale/translations/ru_RU.json

@@ -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 лет назад"
     ]
-}
+}

+ 1 - 0
locale/translations/tr_TR.json

@@ -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",

+ 2 - 1
locale/translations/zh_CN.json

@@ -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 秒后超时"
-}
+}

+ 5 - 4
model/category.go

@@ -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 {

+ 6 - 2
storage/category.go

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

+ 1 - 1
template/templates/views/categories.html

@@ -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">