aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage
diff options
context:
space:
mode:
authorGravatar Dave Z <dzaikos@users.noreply.github.com>2018-08-26 19:18:07 -0400
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-08-26 16:18:07 -0700
commit9169fbafb2e07b33b2ca175c7ac4a9558280912c (patch)
treedec99d5077d7db0c7fa742e606e5cf5368e7dd2b /storage
parentaae62aae08c7581822db0318dba21782d613b4bb (diff)
Show count of feeds with permanent errors in header menu
Only for feeds that reach `maxParsingError` are counted (so transient errors do not trigger counter).
Diffstat (limited to 'storage')
-rw-r--r--storage/feed.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/storage/feed.go b/storage/feed.go
index 283b095..be312ac 100644
--- a/storage/feed.go
+++ b/storage/feed.go
@@ -46,6 +46,17 @@ func (s *Storage) CountFeeds(userID int64) int {
return result
}
+// CountErrorFeeds returns the number of feeds with parse errors that belong to the given user.
+func (s *Storage) CountErrorFeeds(userID int64) int {
+ var result int
+ err := s.db.QueryRow(`SELECT count(*) FROM feeds WHERE user_id=$1 AND parsing_error_count>=$2`, userID, maxParsingError).Scan(&result)
+ if err != nil {
+ return 0
+ }
+
+ return result
+}
+
// Feeds returns all feeds of the given user.
func (s *Storage) Feeds(userID int64) (model.Feeds, error) {
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:Feeds] userID=%d", userID))