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:
parent
b45c1cf327
commit
7c44238bae
6 changed files with 51 additions and 7 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue