From e216c3bc97994b4172d15d52b46d5f6b75f35ea4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 13 Feb 2026 22:01:12 +0900 Subject: feat: add feed sidebar and cursor-based pagination Add a feed sidebar to /unread and /read pages for filtering articles by feed, and replace the fixed 100-article limit with cursor-based pagination using a "Load more" button. Backend: - Add PageInfo, ArticleConnection types and pagination args to GraphQL - Replace GetUnreadArticles/GetReadArticles with parameterized queries - Add GetFeedUnreadCounts query and composite index - Add shared pagination helper in resolver Frontend: - Add FeedSidebar component with unread count badges - Add usePaginatedArticles hook for cursor-based fetching - Update ArticleList with Load more button and single-feed mode - Use ?feed= query parameter for feed filtering Co-Authored-By: Claude Opus 4.6 --- backend/db/feeds.sql.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'backend/db/feeds.sql.go') diff --git a/backend/db/feeds.sql.go b/backend/db/feeds.sql.go index cec228a..0226a7d 100644 --- a/backend/db/feeds.sql.go +++ b/backend/db/feeds.sql.go @@ -96,6 +96,42 @@ func (q *Queries) GetFeedByURL(ctx context.Context, arg GetFeedByURLParams) (Fee return i, err } +const getFeedUnreadCounts = `-- name: GetFeedUnreadCounts :many +SELECT f.id as feed_id, COUNT(a.id) as unread_count +FROM feeds AS f +LEFT JOIN articles AS a ON f.id = a.feed_id AND a.is_read = 0 +WHERE f.is_subscribed = 1 AND f.user_id = ? +GROUP BY f.id +` + +type GetFeedUnreadCountsRow struct { + FeedID int64 + UnreadCount int64 +} + +func (q *Queries) GetFeedUnreadCounts(ctx context.Context, userID int64) ([]GetFeedUnreadCountsRow, error) { + rows, err := q.db.QueryContext(ctx, getFeedUnreadCounts, userID) + if err != nil { + return nil, err + } + defer rows.Close() + items := []GetFeedUnreadCountsRow{} + for rows.Next() { + var i GetFeedUnreadCountsRow + if err := rows.Scan(&i.FeedID, &i.UnreadCount); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const getFeeds = `-- name: GetFeeds :many SELECT id, url, title, fetched_at, is_subscribed, user_id FROM feeds -- cgit v1.3-1-g0d28