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

Add new config option CLEANUP_ARCHIVE_BATCH_SIZE

This commit is contained in:
Frédéric Guillot 2021-05-23 20:45:37 -07:00 committed by fguillot
parent c119a2c011
commit 36868e648c
5 changed files with 24 additions and 7 deletions

View file

@ -299,8 +299,8 @@ func (s *Storage) RefreshFeedEntries(userID, feedID int64, entries model.Entries
}
// ArchiveEntries changes the status of entries to "removed" after the given number of days.
func (s *Storage) ArchiveEntries(status string, days int) (int64, error) {
if days < 0 {
func (s *Storage) ArchiveEntries(status string, days, limit int) (int64, error) {
if days < 0 || limit <= 0 {
return 0, nil
}
@ -310,10 +310,10 @@ func (s *Storage) ArchiveEntries(status string, days int) (int64, error) {
SET
status='removed'
WHERE
id=ANY(SELECT id FROM entries WHERE status=$1 AND starred is false AND share_code='' AND created_at < now () - '%d days'::interval ORDER BY created_at ASC LIMIT 5000)
id=ANY(SELECT id FROM entries WHERE status=$1 AND starred is false AND share_code='' AND created_at < now () - '%d days'::interval ORDER BY created_at ASC LIMIT %d)
`
result, err := s.db.Exec(fmt.Sprintf(query, days), status)
result, err := s.db.Exec(fmt.Sprintf(query, days, limit), status)
if err != nil {
return 0, fmt.Errorf(`store: unable to archive %s entries: %v`, status, err)
}