mirror of
https://github.com/miniflux/v2.git
synced 2025-08-26 18:21:01 +00:00
Revert "refactor(storage): simplify feed.go
by using min()
, inline errors, and use idiomatic conditions"
This reverts commit b1cbaae71c
.
This commit is contained in:
parent
4f252b33c9
commit
af149e46df
1 changed files with 16 additions and 8 deletions
|
@ -111,10 +111,14 @@ func (s *Storage) CountAllFeeds() map[string]int64 {
|
||||||
|
|
||||||
// CountUserFeedsWithErrors returns the number of feeds with parsing errors that belong to the given user.
|
// CountUserFeedsWithErrors returns the number of feeds with parsing errors that belong to the given user.
|
||||||
func (s *Storage) CountUserFeedsWithErrors(userID int64) int {
|
func (s *Storage) CountUserFeedsWithErrors(userID int64) int {
|
||||||
pollingParsingErrorLimit := min(config.Opts.PollingParsingErrorLimit(), 1)
|
pollingParsingErrorLimit := config.Opts.PollingParsingErrorLimit()
|
||||||
|
if pollingParsingErrorLimit <= 0 {
|
||||||
|
pollingParsingErrorLimit = 1
|
||||||
|
}
|
||||||
query := `SELECT count(*) FROM feeds WHERE user_id=$1 AND parsing_error_count >= $2`
|
query := `SELECT count(*) FROM feeds WHERE user_id=$1 AND parsing_error_count >= $2`
|
||||||
var result int
|
var result int
|
||||||
if s.db.QueryRow(query, userID, pollingParsingErrorLimit).Scan(&result) != nil {
|
err := s.db.QueryRow(query, userID, pollingParsingErrorLimit).Scan(&result)
|
||||||
|
if err != nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,10 +127,14 @@ func (s *Storage) CountUserFeedsWithErrors(userID int64) int {
|
||||||
|
|
||||||
// CountAllFeedsWithErrors returns the number of feeds with parsing errors.
|
// CountAllFeedsWithErrors returns the number of feeds with parsing errors.
|
||||||
func (s *Storage) CountAllFeedsWithErrors() int {
|
func (s *Storage) CountAllFeedsWithErrors() int {
|
||||||
pollingParsingErrorLimit := min(config.Opts.PollingParsingErrorLimit(), 1)
|
pollingParsingErrorLimit := config.Opts.PollingParsingErrorLimit()
|
||||||
|
if pollingParsingErrorLimit <= 0 {
|
||||||
|
pollingParsingErrorLimit = 1
|
||||||
|
}
|
||||||
query := `SELECT count(*) FROM feeds WHERE parsing_error_count >= $1`
|
query := `SELECT count(*) FROM feeds WHERE parsing_error_count >= $1`
|
||||||
var result int
|
var result int
|
||||||
if s.db.QueryRow(query, pollingParsingErrorLimit).Scan(&result) != nil {
|
err := s.db.QueryRow(query, pollingParsingErrorLimit).Scan(&result)
|
||||||
|
if err != nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,12 +150,12 @@ func (s *Storage) Feeds(userID int64) (model.Feeds, error) {
|
||||||
|
|
||||||
func getFeedsSorted(builder *FeedQueryBuilder) (model.Feeds, error) {
|
func getFeedsSorted(builder *FeedQueryBuilder) (model.Feeds, error) {
|
||||||
result, err := builder.GetFeeds()
|
result, err := builder.GetFeeds()
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
sort.Sort(byStateAndName{result})
|
sort.Sort(byStateAndName{result})
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
// FeedsWithCounters returns all feeds of the given user with counters of read and unread entries.
|
// FeedsWithCounters returns all feeds of the given user with counters of read and unread entries.
|
||||||
func (s *Storage) FeedsWithCounters(userID int64) (model.Feeds, error) {
|
func (s *Storage) FeedsWithCounters(userID int64) (model.Feeds, error) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue