mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-20 01:34:08 +00:00
Add PR pipeline list (#1641)
Instead of viewing PR pipelines in the branches lists, add a separate list for them. The API endpoint for PRs supports pagination (thus I added a lot of pagination-related stuff), the UI doesn't yet though.  Closes #1619 Extends this part of #1640 --------- Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
28
server/router/middleware/session/pagination.go
Normal file
28
server/router/middleware/session/pagination.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultPage = 1
|
||||
defaultPerPage = 25
|
||||
)
|
||||
|
||||
func Pagination(c *gin.Context) *model.PaginationData {
|
||||
page, err := strconv.ParseInt(c.Param("page"), 10, 64)
|
||||
if err != nil {
|
||||
page = defaultPage
|
||||
}
|
||||
perPage, err := strconv.ParseInt(c.Param("perPage"), 10, 64)
|
||||
if err != nil {
|
||||
perPage = defaultPerPage
|
||||
}
|
||||
return &model.PaginationData{
|
||||
Page: page,
|
||||
PerPage: perPage,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user