Browse Source

Fix releases to be counted from database not tags (#2389)

tags/v1.3.0-rc1
Lauris BH 6 years ago
parent
commit
edb95faba2
3 changed files with 11 additions and 3 deletions
  1. 1
    1
      models/repo.go
  2. 9
    1
      modules/context/repo.go
  3. 1
    1
      templates/repo/header.tmpl

+ 1
- 1
models/repo.go View File

@@ -194,7 +194,7 @@ type Repository struct {
NumMilestones int `xorm:"NOT NULL DEFAULT 0"`
NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
NumOpenMilestones int `xorm:"-"`
NumTags int `xorm:"-"`
NumReleases int `xorm:"-"`

IsPrivate bool `xorm:"INDEX"`
IsBare bool `xorm:"INDEX"`

+ 9
- 1
modules/context/repo.go View File

@@ -275,7 +275,15 @@ func RepoAssignment() macaron.Handler {
return
}
ctx.Data["Tags"] = tags
ctx.Repo.Repository.NumTags = len(tags)

count, err := models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{
IncludeDrafts: false,
})
if err != nil {
ctx.Handle(500, "GetReleaseCountByRepoID", err)
return
}
ctx.Repo.Repository.NumReleases = int(count)

ctx.Data["Title"] = owner.Name + "/" + repo.Name
ctx.Data["Repository"] = repo

+ 1
- 1
templates/repo/header.tmpl View File

@@ -81,7 +81,7 @@

{{if and (.Repository.UnitEnabled $.UnitTypeReleases) (not .IsBareRepo) }}
<a class="{{if .PageIsReleaseList}}active{{end}} item" href="{{.RepoLink}}/releases">
<i class="octicon octicon-tag"></i> {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .Repository.NumTags}}gray{{else}}blue{{end}} small label">{{.Repository.NumTags}}</span>
<i class="octicon octicon-tag"></i> {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .Repository.NumReleases}}gray{{else}}blue{{end}} small label">{{.Repository.NumReleases}}</span>
</a>
{{end}}


Loading…
Cancel
Save