Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).

appview/db: ignore pagination for non-paginated methods

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 <git@boltless.me>

authored by boltless.me and committed by

Tangled bfdcfc5f f37868d4

+15 -9
+8 -5
appview/db/issues.go
··· 101 101 pLower := FilterGte("row_num", page.Offset+1) 102 102 pUpper := FilterLte("row_num", page.Offset+page.Limit) 103 103 104 - args = append(args, pLower.Arg()...) 105 - args = append(args, pUpper.Arg()...) 106 - pagination := " where " + pLower.Condition() + " and " + pUpper.Condition() 104 + pageClause := "" 105 + if page.Limit > 0 { 106 + args = append(args, pLower.Arg()...) 107 + args = append(args, pUpper.Arg()...) 108 + pageClause = " where " + pLower.Condition() + " and " + pUpper.Condition() 109 + } 107 110 108 111 query := fmt.Sprintf( 109 112 ` ··· 131 128 %s 132 129 `, 133 130 whereClause, 134 - pagination, 131 + pageClause, 135 132 ) 136 133 137 134 rows, err := e.Query(query, args...) ··· 247 244 } 248 245 249 246 func GetIssues(e Execer, filters ...filter) ([]models.Issue, error) { 250 - return GetIssuesPaginated(e, pagination.FirstPage(), filters...) 247 + return GetIssuesPaginated(e, pagination.Page{}, filters...) 251 248 } 252 249 253 250 func AddIssueComment(e Execer, c models.IssueComment) (int64, error) {
+7 -4
appview/db/notifications.go
··· 60 60 whereClause += " AND " + condition 61 61 } 62 62 } 63 + pageClause := "" 64 + if page.Limit > 0 { 65 + pageClause = " limit ? offset ? " 66 + args = append(args, page.Limit, page.Offset) 67 + } 63 68 64 69 query := fmt.Sprintf(` 65 70 select id, recipient_did, actor_did, type, entity_type, entity_id, read, created, repo_id, issue_id, pull_id 66 71 from notifications 67 72 %s 68 73 order by created desc 69 - limit ? offset ? 70 - `, whereClause) 71 - 72 - args = append(args, page.Limit, page.Offset) 74 + %s 75 + `, whereClause, pageClause) 73 76 74 77 rows, err := e.QueryContext(context.Background(), query, args...) 75 78 if err != nil {