diff options
author | Jebbs <qjebbs@gmail.com> | 2018-12-06 12:35:30 +0800 |
---|---|---|
committer | fguillot <fred@miniflux.net> | 2018-12-05 20:35:30 -0800 |
commit | 87648490fda1d765fb7b78544b2b01847550c82b (patch) | |
tree | fe57b9c00b0ec311d74af4a55a8db5ee4ce72913 /storage | |
parent | 3e392dc3ae7926266f18edbc2a6309cf195cb676 (diff) |
Make configurable the number of days to archive read items
Diffstat (limited to 'storage')
-rw-r--r-- | storage/entry.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/storage/entry.go b/storage/entry.go index 00ef615..7b80ca0 100644 --- a/storage/entry.go +++ b/storage/entry.go @@ -186,12 +186,12 @@ func (s *Storage) UpdateEntries(userID, feedID int64, entries model.Entries, upd return nil } -// ArchiveEntries changes the status of read items to "removed" after 60 days. -func (s *Storage) ArchiveEntries() error { - query := ` - UPDATE entries SET status='removed' - WHERE id=ANY(SELECT id FROM entries WHERE status='read' AND starred is false AND published_at < now () - '60 days'::interval LIMIT 5000) - ` +// ArchiveEntries changes the status of read items to "removed" after specified days. +func (s *Storage) ArchiveEntries(days int) error { + query := fmt.Sprintf(` + UPDATE entries SET status='removed' + WHERE id=ANY(SELECT id FROM entries WHERE status='read' AND starred is false AND published_at < now () - '%d days'::interval LIMIT 5000) + `, days) if _, err := s.db.Exec(query); err != nil { return fmt.Errorf("unable to archive read entries: %v", err) } |