mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Pagination on releases page (#2035)
* Added count to GetReleasesByRepoID so pagination will work * Separated it out to a new function, can then also leave the API part unaffected * Remove extra whitespace added in untouched function * Added comment and corrected name in error handler * Account for if the user is owner or not in the count * Also check if repo is draft * revert back to the correct count in the ReleasesToDisplay loop * Fixed lint error regarding else with return statement * Use Cond struct instead of string, corrected name in error handler * Removed unused return variable names
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/process"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/sdk/gitea"
|
||||
"github.com/go-xorm/builder"
|
||||
"github.com/go-xorm/xorm"
|
||||
)
|
||||
|
||||
@@ -244,6 +245,19 @@ func GetReleasesByRepoID(repoID int64, page, pageSize int) (rels []*Release, err
|
||||
return rels, err
|
||||
}
|
||||
|
||||
// GetReleaseCountByRepoID returns the count of releases of repository
|
||||
func GetReleaseCountByRepoID(repoID int64, includeDrafts bool) (int64, error) {
|
||||
var cond = builder.NewCond()
|
||||
cond = cond.And(builder.Eq{"repo_id": repoID})
|
||||
|
||||
if includeDrafts {
|
||||
return x.Where(cond).Count(&Release{})
|
||||
}
|
||||
|
||||
cond = cond.And(builder.Eq{"is_draft": false})
|
||||
return x.Where(cond).Count(&Release{})
|
||||
}
|
||||
|
||||
// GetReleasesByRepoIDAndNames returns a list of releases of repository according repoID and tagNames.
|
||||
func GetReleasesByRepoIDAndNames(repoID int64, tagNames []string) (rels []*Release, err error) {
|
||||
err = x.
|
||||
|
Reference in New Issue
Block a user