diff options
Diffstat (limited to 'models/release.go')
-rw-r--r-- | models/release.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/models/release.go b/models/release.go index 46f9e88752..ebd2b6d384 100644 --- a/models/release.go +++ b/models/release.go @@ -175,6 +175,7 @@ func GetReleaseByID(id int64) (*Release, error) { // FindReleasesOptions describes the conditions to Find releases type FindReleasesOptions struct { + ListOptions IncludeDrafts bool IncludeTags bool TagNames []string @@ -197,17 +198,17 @@ func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond { } // GetReleasesByRepoID returns a list of releases of repository. -func GetReleasesByRepoID(repoID int64, opts FindReleasesOptions, page, pageSize int) (rels []*Release, err error) { - if page <= 0 { - page = 1 +func GetReleasesByRepoID(repoID int64, opts FindReleasesOptions) ([]*Release, error) { + sess := x. + Desc("created_unix", "id"). + Where(opts.toConds(repoID)) + + if opts.PageSize != 0 { + sess = opts.setSessionPagination(sess) } - err = x. - Desc("created_unix", "id"). - Limit(pageSize, (page-1)*pageSize). - Where(opts.toConds(repoID)). - Find(&rels) - return rels, err + rels := make([]*Release, 0, opts.PageSize) + return rels, sess.Find(&rels) } // GetReleasesByRepoIDAndNames returns a list of releases of repository according repoID and tagNames. |