diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-11-08 10:39:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-08 10:39:03 +0800 |
commit | 5667d4daae2df8c648d3c30cd7f6aadd5cb0e698 (patch) | |
tree | 24b739896a721abb794a9a9bc0a97ea16c25ed79 /models | |
parent | 864d1b1f9f6a72589d77ec0f08b21c476b8e13d4 (diff) | |
parent | 562f9b6eae72e3f952a2ce1e74249bcd44e69272 (diff) | |
download | gitea-5667d4daae2df8c648d3c30cd7f6aadd5cb0e698.tar.gz gitea-5667d4daae2df8c648d3c30cd7f6aadd5cb0e698.zip |
Merge pull request #73 from bkcsoft/gt/2164-release-pagination
Add Pagination to Releases-page (and de-duplicate pagination templates)
Diffstat (limited to 'models')
-rw-r--r-- | models/release.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/models/release.go b/models/release.go index 0e1edd121b..4841ae7ba3 100644 --- a/models/release.go +++ b/models/release.go @@ -138,8 +138,11 @@ func GetReleaseByID(id int64) (*Release, error) { } // GetReleasesByRepoID returns a list of releases of repository. -func GetReleasesByRepoID(repoID int64) (rels []*Release, err error) { - err = x.Desc("created_unix").Find(&rels, Release{RepoID: repoID}) +func GetReleasesByRepoID(repoID int64, page, pageSize int) (rels []*Release, err error) { + if page <= 0 { + page = 1 + } + err = x.Desc("created_unix").Limit(pageSize, (page-1)*pageSize).Find(&rels, Release{RepoID: repoID}) return rels, err } |