From 1b8a37ad8282cbca54d47e4a95386bcef3c8ee95 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Fri, 24 Oct 2025 00:28:31 +0900 Subject: [PATCH] appview/db: ignore pagination for non-paginated methods Change-Id: ztsunkmpnsrypuoovllslssxpzqwkprr Each methods will check if `page.limit` is higher than 0, and only applies pagination when limit is higher than 0 Signed-off-by: Seongmin Lee --- appview/db/issues.go | 13 ++++++++----- appview/db/notifications.go | 11 +++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/appview/db/issues.go b/appview/db/issues.go index e21ffb0a..f781de8b 100644 --- a/appview/db/issues.go +++ b/appview/db/issues.go @@ -101,9 +101,12 @@ func GetIssuesPaginated(e Execer, page pagination.Page, filters ...filter) ([]mo pLower := FilterGte("row_num", page.Offset+1) pUpper := FilterLte("row_num", page.Offset+page.Limit) - args = append(args, pLower.Arg()...) - args = append(args, pUpper.Arg()...) - pagination := " where " + pLower.Condition() + " and " + pUpper.Condition() + pageClause := "" + if page.Limit > 0 { + args = append(args, pLower.Arg()...) + args = append(args, pUpper.Arg()...) + pageClause = " where " + pLower.Condition() + " and " + pUpper.Condition() + } query := fmt.Sprintf( ` @@ -128,7 +131,7 @@ func GetIssuesPaginated(e Execer, page pagination.Page, filters ...filter) ([]mo %s `, whereClause, - pagination, + pageClause, ) rows, err := e.Query(query, args...) @@ -244,7 +247,7 @@ func GetIssuesPaginated(e Execer, page pagination.Page, filters ...filter) ([]mo } func GetIssues(e Execer, filters ...filter) ([]models.Issue, error) { - return GetIssuesPaginated(e, pagination.FirstPage(), filters...) + return GetIssuesPaginated(e, pagination.Page{}, filters...) } func AddIssueComment(e Execer, c models.IssueComment) (int64, error) { diff --git a/appview/db/notifications.go b/appview/db/notifications.go index 483f3714..10f18ce1 100644 --- a/appview/db/notifications.go +++ b/appview/db/notifications.go @@ -60,16 +60,19 @@ func GetNotificationsPaginated(e Execer, page pagination.Page, filters ...filter whereClause += " AND " + condition } } + pageClause := "" + if page.Limit > 0 { + pageClause = " limit ? offset ? " + args = append(args, page.Limit, page.Offset) + } query := fmt.Sprintf(` select id, recipient_did, actor_did, type, entity_type, entity_id, read, created, repo_id, issue_id, pull_id from notifications %s order by created desc - limit ? offset ? - `, whereClause) - - args = append(args, page.Limit, page.Offset) + %s + `, whereClause, pageClause) rows, err := e.QueryContext(context.Background(), query, args...) if err != nil { -- 2.43.0