From 9169fbafb2e07b33b2ca175c7ac4a9558280912c Mon Sep 17 00:00:00 2001 From: Dave Z Date: Sun, 26 Aug 2018 19:18:07 -0400 Subject: 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). --- storage/feed.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'storage') 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)) -- cgit v1.2.3