back interdiff of round #1 and #0

appview: improve pagination.Page usage #519

closed
opened by ptr.pet targeting master from [deleted fork]: pipeline-paginated
files
appview
db
issues
middleware
pages
templates
repo
issues
pagination
repo
ERROR
appview/issues/issues.go

Failed to calculate interdiff for this file.

REBASED
appview/issues/router.go

This patch was likely rebased, as context lines do not match.

ERROR
appview/middleware/middleware.go

Failed to calculate interdiff for this file.

ERROR
appview/pagination/page.go

Failed to calculate interdiff for this file.

NEW
appview/db/issues.go
··· 216 216 // get next issue_id 217 217 var newIssueId int 218 218 err := tx.QueryRow(` 219 - update repo_issue_seqs 220 - set next_issue_id = next_issue_id + 1 221 - where repo_at = ? 219 + update repo_issue_seqs 220 + set next_issue_id = next_issue_id + 1 221 + where repo_at = ? 222 222 returning next_issue_id - 1 223 223 `, issue.RepoAt).Scan(&newIssueId) 224 224 if err != nil { ··· 261 261 whereClause = " where " + strings.Join(conditions, " and ") 262 262 } 263 263 264 - pLower := FilterGte("row_num", page.Offset+1) 265 - pUpper := FilterLte("row_num", page.Offset+page.Limit) 264 + pLower := FilterGte("row_num", page.Count*page.No+1) 265 + pUpper := FilterLte("row_num", page.Count*(page.No+1)) 266 266 267 267 args = append(args, pLower.Arg()...) 268 268 args = append(args, pUpper.Arg()...) ··· 396 396 } 397 397 398 398 func GetIssues(e Execer, filters ...filter) ([]Issue, error) { 399 - return GetIssuesPaginated(e, pagination.FirstPage(), filters...) 399 + return GetIssuesPaginated(e, pagination.Page{No: 0, Count: 10}, filters...) 400 400 } 401 401 402 402 func GetIssue(e Execer, repoAt syntax.ATURI, issueId int) (*Issue, error) {
NEW
appview/pages/pages.go
··· 866 866 RepoInfo repoinfo.RepoInfo 867 867 Active string 868 868 Issues []db.Issue 869 - Page pagination.Page 869 + Pagination pagination.Pagination 870 870 FilteringByOpen bool 871 871 } 872 872
NEW
appview/pages/templates/repo/issues/issues.html
··· 87 87 {{ end }} 88 88 89 89 {{ define "pagination" }} 90 + {{ $currentPage := .Pagination.CurrentPage }} 90 91 <div class="flex justify-end mt-4 gap-2"> 91 92 {{ $currentState := "closed" }} 92 93 {{ if .FilteringByOpen }} 93 94 {{ $currentState = "open" }} 94 95 {{ end }} 95 96 96 - {{ if gt .Page.Offset 0 }} 97 - {{ $prev := .Page.Previous }} 97 + {{ if gt $currentPage.No 0 }} 98 + {{ $prev := .Pagination.PreviousPage }} 98 99 <a 99 100 class="btn flex items-center gap-2 no-underline hover:no-underline dark:text-white dark:hover:bg-gray-700" 100 101 hx-boost="true" 101 - href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&offset={{ $prev.Offset }}&limit={{ $prev.Limit }}" 102 + href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&page={{ add $prev.No 1 }}&count={{ $prev.Count }}" 102 103 > 103 104 {{ i "chevron-left" "w-4 h-4" }} 104 105 previous ··· 107 108 <div></div> 108 109 {{ end }} 109 110 110 - {{ if eq (len .Issues) .Page.Limit }} 111 - {{ $next := .Page.Next }} 111 + {{ if lt (add $currentPage.No 1) .Pagination.TotalPageCount }} 112 + {{ $next := .Pagination.NextPage }} 112 113 <a 113 114 class="btn flex items-center gap-2 no-underline hover:no-underline dark:text-white dark:hover:bg-gray-700" 114 115 hx-boost="true" 115 - href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&offset={{ $next.Offset }}&limit={{ $next.Limit }}" 116 + href = "/{{ $.RepoInfo.FullName }}/issues?state={{ $currentState }}&page={{ add $next.No 1 }}&count={{ $next.Count }}" 116 117 > 117 118 next 118 119 {{ i "chevron-right" "w-4 h-4" }}
NEW
appview/repo/feed.go
··· 26 26 27 27 issues, err := db.GetIssuesPaginated( 28 28 rp.db, 29 - pagination.Page{Limit: feedLimitPerType}, 29 + pagination.Page{No: 0, Count: feedLimitPerType}, 30 30 db.FilterEq("repo_at", f.RepoAt()), 31 31 ) 32 32 if err != nil {