aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/db/queries
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-13 22:01:12 +0900
committernsfisis <nsfisis@gmail.com>2026-02-13 22:01:12 +0900
commite216c3bc97994b4172d15d52b46d5f6b75f35ea4 (patch)
tree3ffbd74f4cb2d90846931c8dcbb97ec07f2b91f1 /backend/db/queries
parentc863e64c0521926e785f4aa7ecf4cf15bb9defa7 (diff)
downloadfeedaka-e216c3bc97994b4172d15d52b46d5f6b75f35ea4.tar.gz
feedaka-e216c3bc97994b4172d15d52b46d5f6b75f35ea4.tar.zst
feedaka-e216c3bc97994b4172d15d52b46d5f6b75f35ea4.zip
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=<id> query parameter for feed filtering Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'backend/db/queries')
-rw-r--r--backend/db/queries/articles.sql32
-rw-r--r--backend/db/queries/feeds.sql7
2 files changed, 33 insertions, 6 deletions
diff --git a/backend/db/queries/articles.sql b/backend/db/queries/articles.sql
index 2c00678..1554530 100644
--- a/backend/db/queries/articles.sql
+++ b/backend/db/queries/articles.sql
@@ -6,25 +6,45 @@ FROM articles AS a
INNER JOIN feeds AS f ON a.feed_id = f.id
WHERE a.id = ?;
--- name: GetUnreadArticles :many
+-- name: GetArticlesPaginated :many
SELECT
a.id, a.feed_id, a.guid, a.title, a.url, a.is_read,
f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed
FROM articles AS a
INNER JOIN feeds AS f ON a.feed_id = f.id
-WHERE a.is_read = 0 AND f.is_subscribed = 1 AND f.user_id = ?
+WHERE a.is_read = ? AND f.is_subscribed = 1 AND f.user_id = ?
ORDER BY a.id DESC
-LIMIT 100;
+LIMIT ?;
--- name: GetReadArticles :many
+-- name: GetArticlesPaginatedAfter :many
SELECT
a.id, a.feed_id, a.guid, a.title, a.url, a.is_read,
f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed
FROM articles AS a
INNER JOIN feeds AS f ON a.feed_id = f.id
-WHERE a.is_read = 1 AND f.is_subscribed = 1 AND f.user_id = ?
+WHERE a.is_read = ? AND f.is_subscribed = 1 AND f.user_id = ? AND a.id < ?
ORDER BY a.id DESC
-LIMIT 100;
+LIMIT ?;
+
+-- name: GetArticlesByFeedPaginated :many
+SELECT
+ a.id, a.feed_id, a.guid, a.title, a.url, a.is_read,
+ f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed
+FROM articles AS a
+INNER JOIN feeds AS f ON a.feed_id = f.id
+WHERE a.is_read = ? AND f.is_subscribed = 1 AND f.user_id = ? AND a.feed_id = ?
+ORDER BY a.id DESC
+LIMIT ?;
+
+-- name: GetArticlesByFeedPaginatedAfter :many
+SELECT
+ a.id, a.feed_id, a.guid, a.title, a.url, a.is_read,
+ f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed
+FROM articles AS a
+INNER JOIN feeds AS f ON a.feed_id = f.id
+WHERE a.is_read = ? AND f.is_subscribed = 1 AND f.user_id = ? AND a.feed_id = ? AND a.id < ?
+ORDER BY a.id DESC
+LIMIT ?;
-- name: GetArticlesByFeed :many
SELECT id, feed_id, guid, title, url, is_read
diff --git a/backend/db/queries/feeds.sql b/backend/db/queries/feeds.sql
index acf36d2..094a0f8 100644
--- a/backend/db/queries/feeds.sql
+++ b/backend/db/queries/feeds.sql
@@ -37,3 +37,10 @@ WHERE is_subscribed = 1;
UPDATE feeds
SET is_subscribed = 0
WHERE id = ?;
+
+-- 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;