Browse Source

milestone: only show issue-related count under issue list (#4316)

Unknwon 7 years ago
parent
commit
79ba0314e9
6 changed files with 17 additions and 6 deletions
  1. 1 1
      .editorconfig
  2. 1 1
      gogs.go
  3. 9 0
      models/milestone.go
  4. 1 1
      routers/repo/http.go
  5. 1 1
      templates/.VERSION
  6. 4 2
      templates/repo/issue/milestones.tmpl

+ 1 - 1
.editorconfig

@@ -21,5 +21,5 @@ indent_style = space
 indent_size = 2
 
 [*.js]
-indent_style = space
+indent_style = tab
 indent_size = 4

+ 1 - 1
gogs.go

@@ -16,7 +16,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.10.28.0323"
+const APP_VER = "0.10.29.0324"
 
 func init() {
 	setting.AppVer = APP_VER

+ 9 - 0
models/milestone.go

@@ -103,6 +103,15 @@ func (m *Milestone) APIFormat() *api.Milestone {
 	return apiMilestone
 }
 
+func (m *Milestone) CountIssues(isClosed, includePulls bool) int64 {
+	sess := x.Where("milestone_id = ?", m.ID).And("is_closed = ?", isClosed)
+	if !includePulls {
+		sess.And("is_pull = ?", false)
+	}
+	count, _ := sess.Count(new(Issue))
+	return count
+}
+
 // NewMilestone creates new milestone of repository.
 func NewMilestone(m *Milestone) (err error) {
 	sess := x.NewSession()

+ 1 - 1
routers/repo/http.go

@@ -243,7 +243,7 @@ func serviceRPC(h serviceHandler, service string) {
 		err     error
 	)
 
-	// Handle GZIP.
+	// Handle GZIP
 	if h.r.Header.Get("Content-Encoding") == "gzip" {
 		reqBody, err = gzip.NewReader(reqBody)
 		if err != nil {

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.10.28.0323
+0.10.29.0324

+ 4 - 2
templates/repo/issue/milestones.tmpl

@@ -45,8 +45,10 @@
 							{{end}}
 						{{end}}
 						<span class="issue-stats">
-							<i class="octicon octicon-issue-opened"></i> {{$.i18n.Tr "repo.issues.open_tab" .NumOpenIssues}}
-							<i class="octicon octicon-issue-closed"></i> {{$.i18n.Tr "repo.issues.close_tab" .NumClosedIssues}}
+							{{ $openCount := .CountIssues false false}}
+							{{ $closedCount := .CountIssues true false}}
+							<i class="octicon octicon-issue-opened"></i> {{$.i18n.Tr "repo.issues.open_tab" $openCount}}
+							<i class="octicon octicon-issue-closed"></i> {{$.i18n.Tr "repo.issues.close_tab" $closedCount}}
 						</span>
 					</div>
 					{{if $.IsRepositoryWriter}}