mirror of
https://github.com/R0m1k3/FlowReader.git
synced 2026-10-11 17:28:05 +02:00
feat: auto-cleanup articles > 30d and relocate AI summary to reader view
This commit is contained in:
1 parent
b3cbaf741d
commit
c4cc7eaf87
5 files changed
+136
-10
No files matched your search
@@ -521,6 +521,23 @@ func (r *ArticleRepository) UpdateAISummary(id uuid.UUID, summary string) error
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteOldArticles removes articles older than the specified duration, except for favorites.
|
||||
func (r *ArticleRepository) DeleteOldArticles(ctx context.Context, olderThan time.Duration) (int64, error) {
|
||||
threshold := time.Now().Add(-olderThan)
|
||||
|
||||
query := `
|
||||
DELETE FROM articles
|
||||
WHERE created_at < $1 AND is_favorite = false
|
||||
`
|
||||
|
||||
result, err := r.pool.Exec(ctx, query, threshold)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("deleting old articles: %w", err)
|
||||
}
|
||||
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
// nullString returns nil if string is empty.
|
||||
func nullString(s string) *string {
|
||||
if s == "" {
|
||||
|
||||
Reference in new issue
Block a user