@@ -111,10 +111,14 @@ func (s *Storage) CountAllFeeds() map[string]int64 {
111111
112112// CountUserFeedsWithErrors returns the number of feeds with parsing errors that belong to the given user.
113113func (s * Storage ) CountUserFeedsWithErrors (userID int64 ) int {
114- pollingParsingErrorLimit := min (config .Opts .PollingParsingErrorLimit (), 1 )
114+ pollingParsingErrorLimit := config .Opts .PollingParsingErrorLimit ()
115+ if pollingParsingErrorLimit <= 0 {
116+ pollingParsingErrorLimit = 1
117+ }
115118 query := `SELECT count(*) FROM feeds WHERE user_id=$1 AND parsing_error_count >= $2`
116119 var result int
117- if s .db .QueryRow (query , userID , pollingParsingErrorLimit ).Scan (& result ) != nil {
120+ err := s .db .QueryRow (query , userID , pollingParsingErrorLimit ).Scan (& result )
121+ if err != nil {
118122 return 0
119123 }
120124
@@ -123,10 +127,14 @@ func (s *Storage) CountUserFeedsWithErrors(userID int64) int {
123127
124128// CountAllFeedsWithErrors returns the number of feeds with parsing errors.
125129func (s * Storage ) CountAllFeedsWithErrors () int {
126- pollingParsingErrorLimit := min (config .Opts .PollingParsingErrorLimit (), 1 )
130+ pollingParsingErrorLimit := config .Opts .PollingParsingErrorLimit ()
131+ if pollingParsingErrorLimit <= 0 {
132+ pollingParsingErrorLimit = 1
133+ }
127134 query := `SELECT count(*) FROM feeds WHERE parsing_error_count >= $1`
128135 var result int
129- if s .db .QueryRow (query , pollingParsingErrorLimit ).Scan (& result ) != nil {
136+ err := s .db .QueryRow (query , pollingParsingErrorLimit ).Scan (& result )
137+ if err != nil {
130138 return 0
131139 }
132140
@@ -142,11 +150,11 @@ func (s *Storage) Feeds(userID int64) (model.Feeds, error) {
142150
143151func getFeedsSorted (builder * FeedQueryBuilder ) (model.Feeds , error ) {
144152 result , err := builder .GetFeeds ()
145- if err != nil {
146- return nil , err
153+ if err == nil {
154+ sort .Sort (byStateAndName {result })
155+ return result , nil
147156 }
148- sort .Sort (byStateAndName {result })
149- return result , nil
157+ return result , err
150158}
151159
152160// FeedsWithCounters returns all feeds of the given user with counters of read and unread entries.
0 commit comments