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