aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-05-19 16:40:24 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-05-19 16:45:27 -0700
commitf19ab21b7d7dcddb3de0536c272cb22d581eb8d7 (patch)
tree73eb4ad19fd69aee158be85be60ea6cd9f53135e /storage
parentff8e0c6b3dca3bf46b0abda284b486467a23dd07 (diff)
Archive read entries automatically after 60 days
Diffstat (limited to 'storage')
-rw-r--r--storage/entry.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/storage/entry.go b/storage/entry.go
index fb1fb59..65c0220 100644
--- a/storage/entry.go
+++ b/storage/entry.go
@@ -176,6 +176,19 @@ func (s *Storage) cleanupEntries(feedID int64, entryHashes []string) error {
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 500)
+ `
+ if _, err := s.db.Exec(query); err != nil {
+ return fmt.Errorf("unable to archive read entries: %v", err)
+ }
+
+ return nil
+}
+
// SetEntriesStatus update the status of the given list of entries.
func (s *Storage) SetEntriesStatus(userID int64, entryIDs []int64, status string) error {
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:SetEntriesStatus] userID=%d, entryIDs=%v, status=%s", userID, entryIDs, status))