mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-07-01 17:01:14 +03:00
feat: add archivation method for oldest threads
This commit is contained in:
parent
e9808b4fb3
commit
52e3f9ae90
@ -230,3 +230,17 @@ func (r *PostsRepository) GetOldestThreadUpdateAt() (time.Time, error) {
|
||||
return updatedAt, nil
|
||||
}
|
||||
|
||||
func (r *PostsRepository) ArchiveThreadsFrom(t time.Time) error {
|
||||
sql := `
|
||||
UPDATE posts
|
||||
SET is_archived = true
|
||||
WHERE
|
||||
is_parent = true
|
||||
AND is_deleted != true
|
||||
AND is_archived != true
|
||||
AND updated_at > $1
|
||||
`
|
||||
|
||||
_, err := Db.Pool.Exec(context.TODO(), sql, t)
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user