diff --git a/appview/db/issues.go b/appview/db/issues.go --- a/appview/db/issues.go +++ b/appview/db/issues.go @@ -101,9 +101,12 @@ 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 @@ %s `, whereClause, - pagination, + pageClause, ) rows, err := e.Query(query, args...) @@ -244,7 +247,7 @@ } 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 --- a/appview/db/notifications.go +++ b/appview/db/notifications.go @@ -60,16 +60,19 @@ 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 {