Archive older entries first

This commit is contained in:
Frédéric Guillot 2020-09-14 20:15:08 -07:00
parent acd318b640
commit ad66250734

View file

@ -221,7 +221,7 @@ 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 published_at < now () - '%d days'::interval LIMIT 5000)
id=ANY(SELECT id FROM entries WHERE status=$1 AND starred is false AND share_code='' AND published_at < now () - '%d days'::interval ORDER BY published_at ASC LIMIT 5000)
`
result, err := s.db.Exec(fmt.Sprintf(query, days), status)