diff options
author | 6543 <6543@obermui.de> | 2020-04-06 20:42:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 19:42:30 +0100 |
commit | ad31d6b5e8856b22ddad45477be9d078a869a953 (patch) | |
tree | 63a8e832f97b50aee3bef9321fa5f238b0c0e8d4 /models/repo.go | |
parent | ef89e75d0eb232e98ca7a7ef278b8681c7f4fe50 (diff) | |
download | gitea-ad31d6b5e8856b22ddad45477be9d078a869a953.tar.gz gitea-ad31d6b5e8856b22ddad45477be9d078a869a953.zip |
Fix release counter on API repository info (#10968)
Use the same mechanism as the webpage for calculating the release count
Fix #10946
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/models/repo.go b/models/repo.go index 8f0736ef82..a901c3476b 100644 --- a/models/repo.go +++ b/models/repo.go @@ -166,7 +166,6 @@ type Repository struct { NumMilestones int `xorm:"NOT NULL DEFAULT 0"` NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"` NumOpenMilestones int `xorm:"-"` - NumReleases int `xorm:"-"` IsPrivate bool `xorm:"INDEX"` IsEmpty bool `xorm:"INDEX"` @@ -353,6 +352,8 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool) repo.mustOwner(e) + numReleases, _ := GetReleaseCountByRepoID(repo.ID, FindReleasesOptions{IncludeDrafts: false, IncludeTags: true}) + return &api.Repository{ ID: repo.ID, Owner: repo.Owner.APIFormat(), @@ -376,7 +377,7 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool) Watchers: repo.NumWatches, OpenIssues: repo.NumOpenIssues, OpenPulls: repo.NumOpenPulls, - Releases: repo.NumReleases, + Releases: int(numReleases), DefaultBranch: repo.DefaultBranch, Created: repo.CreatedUnix.AsTime(), Updated: repo.UpdatedUnix.AsTime(), |