1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +00:00

Add global option POLLING_PARSING_ERROR_LIMIT

This commit is contained in:
Shizun Ge 2021-01-25 23:41:36 -06:00 committed by GitHub
parent b45c1cf327
commit 7c44238bae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 7 deletions

View file

@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"miniflux.app/config"
"miniflux.app/model"
)
@ -80,9 +81,13 @@ func (s *Storage) CountFeeds(userID int64) int {
// CountUserFeedsWithErrors returns the number of feeds with parsing errors that belong to the given user.
func (s *Storage) CountUserFeedsWithErrors(userID int64) int {
pollingParsingErrorLimit := config.Opts.PollingParsingErrorLimit()
if pollingParsingErrorLimit <= 0 {
pollingParsingErrorLimit = 1
}
query := `SELECT count(*) FROM feeds WHERE user_id=$1 AND parsing_error_count >= $2`
var result int
err := s.db.QueryRow(query, userID, maxParsingError).Scan(&result)
err := s.db.QueryRow(query, userID, pollingParsingErrorLimit).Scan(&result)
if err != nil {
return 0
}
@ -92,9 +97,13 @@ func (s *Storage) CountUserFeedsWithErrors(userID int64) int {
// CountAllFeedsWithErrors returns the number of feeds with parsing errors.
func (s *Storage) CountAllFeedsWithErrors() int {
pollingParsingErrorLimit := config.Opts.PollingParsingErrorLimit()
if pollingParsingErrorLimit <= 0 {
pollingParsingErrorLimit = 1
}
query := `SELECT count(*) FROM feeds WHERE parsing_error_count >= $1`
var result int
err := s.db.QueryRow(query, maxParsingError).Scan(&result)
err := s.db.QueryRow(query, pollingParsingErrorLimit).Scan(&result)
if err != nil {
return 0
}

View file

@ -7,13 +7,13 @@ package storage // import "miniflux.app/storage"
import (
"fmt"
"miniflux.app/config"
"miniflux.app/model"
)
const maxParsingError = 3
// NewBatch returns a serie of jobs.
func (s *Storage) NewBatch(batchSize int) (jobs model.JobList, err error) {
pollingParsingErrorLimit := config.Opts.PollingParsingErrorLimit()
query := `
SELECT
id,
@ -21,10 +21,11 @@ func (s *Storage) NewBatch(batchSize int) (jobs model.JobList, err error) {
FROM
feeds
WHERE
parsing_error_count < $1 AND disabled is false AND next_check_at < now()
ORDER BY next_check_at ASC LIMIT %d
disabled is false AND next_check_at < now() AND
CASE WHEN $1 > 0 THEN parsing_error_count < $1 ELSE parsing_error_count >= 0 END
ORDER BY next_check_at ASC LIMIT $2
`
return s.fetchBatchRows(fmt.Sprintf(query, batchSize), maxParsingError)
return s.fetchBatchRows(query, pollingParsingErrorLimit, batchSize)
}
// NewUserBatch returns a serie of jobs but only for a given user.