From bca84bac8b1906021b93d29265e2535d67cc7a25 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 25 Feb 2024 19:17:58 +0100 Subject: [PATCH] Use an update-where for MarkCategoryAsRead instead of a subquery --- internal/storage/entry.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/storage/entry.go b/internal/storage/entry.go index 6964746f..0c583ded 100644 --- a/internal/storage/entry.go +++ b/internal/storage/entry.go @@ -545,14 +545,18 @@ func (s *Storage) MarkCategoryAsRead(userID, categoryID int64, before time.Time) SET status=$1, changed_at=now() + FROM + feeds WHERE - user_id=$2 + feed_id=feeds.id + AND + feeds.user_id=$2 AND status=$3 AND published_at < $4 AND - feed_id IN (SELECT id FROM feeds WHERE user_id=$2 AND category_id=$5) + feeds.category_id=$5 ` result, err := s.db.Exec(query, model.EntryStatusRead, userID, model.EntryStatusUnread, before, categoryID) if err != nil {