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

Add category feeds refresh

This commit is contained in:
Davide Masserut 2022-12-11 18:07:01 +01:00 committed by Frédéric Guillot
parent e12c263fc9
commit ce35b46fee
8 changed files with 89 additions and 0 deletions

View file

@ -45,6 +45,23 @@ func (s *Storage) NewUserBatch(userID int64, batchSize int) (jobs model.JobList,
return s.fetchBatchRows(fmt.Sprintf(query, batchSize), userID)
}
// NewCategoryBatch returns a series of jobs but only for a given category.
func (s *Storage) NewCategoryBatch(userID int64, categoryID int64, batchSize int) (jobs model.JobList, err error) {
// We do not take the error counter into consideration when the given
// user refresh manually all his feeds to force a refresh.
query := `
SELECT
id,
user_id
FROM
feeds
WHERE
user_id=$1 AND category_id=$2 AND disabled is false
ORDER BY next_check_at ASC LIMIT %d
`
return s.fetchBatchRows(fmt.Sprintf(query, batchSize), userID, categoryID)
}
func (s *Storage) fetchBatchRows(query string, args ...interface{}) (jobs model.JobList, err error) {
rows, err := s.db.Query(query, args...)
if err != nil {