aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2017-12-22 18:13:14 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2017-12-22 18:13:14 -0800
commitf546552a1d7212e426cd6000da87e5aaa391bdc0 (patch)
treeeba0df4f77ab8154e65069d0a721516f091b5733 /storage
parente7afec7ecaadd90711f2453e9b6b249ef1672864 (diff)
Clicking on refresh feeds should refresh only user feeds
Diffstat (limited to 'storage')
-rw-r--r--storage/job.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/storage/job.go b/storage/job.go
index b66ae3b..f8b11d8 100644
--- a/storage/job.go
+++ b/storage/job.go
@@ -24,7 +24,24 @@ func (s *Storage) NewBatch(batchSize int) (jobs model.JobList, err error) {
WHERE parsing_error_count < $1
ORDER BY checked_at ASC LIMIT %d`
- rows, err := s.db.Query(fmt.Sprintf(query, batchSize), maxParsingError)
+ return s.fetchBatchRows(fmt.Sprintf(query, batchSize), maxParsingError)
+}
+
+// NewUserBatch returns a serie of jobs but only for a given user.
+func (s *Storage) NewUserBatch(userID int64, batchSize int) (jobs model.JobList, err error) {
+ defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:GetUserJobs] batchSize=%d, userID=%d", batchSize, userID))
+ query := `
+ SELECT
+ id, user_id
+ FROM feeds
+ WHERE user_id=$1 AND parsing_error_count < $2
+ ORDER BY checked_at ASC LIMIT %d`
+
+ return s.fetchBatchRows(fmt.Sprintf(query, batchSize), userID, maxParsingError)
+}
+
+func (s *Storage) fetchBatchRows(query string, args ...interface{}) (jobs model.JobList, err error) {
+ rows, err := s.db.Query(query, args...)
if err != nil {
return nil, fmt.Errorf("unable to fetch batch of jobs: %v", err)
}