diff options
Diffstat (limited to 'storage/feed.go')
-rw-r--r-- | storage/feed.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/storage/feed.go b/storage/feed.go index ec08580..0fab481 100644 --- a/storage/feed.go +++ b/storage/feed.go @@ -8,9 +8,10 @@ import ( "database/sql" "errors" "fmt" + "time" + "github.com/miniflux/miniflux2/helper" "github.com/miniflux/miniflux2/model" - "time" ) func (s *Storage) FeedExists(userID, feedID int64) bool { @@ -31,6 +32,17 @@ func (s *Storage) FeedURLExists(userID int64, feedURL string) bool { return result >= 1 } +// CountFeeds returns the number of feeds that belongs to the given user. +func (s *Storage) CountFeeds(userID int64) int { + var result int + err := s.db.QueryRow(`SELECT count(*) FROM feeds WHERE user_id=$1`, userID).Scan(&result) + if err != nil { + return 0 + } + + return result +} + func (s *Storage) GetFeeds(userID int64) (model.Feeds, error) { defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:GetFeeds] userID=%d", userID)) |