summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-05-27 18:23:39 -0700
committerUnknwon <u@gogs.io>2016-05-27 18:23:39 -0700
commite9ae926e040c94ce66666ae6c330c93918fa321c (patch)
treee67748f36b0a13a45a374e69258dc6f178c0c5a5
parent28c03f1147e4f3fbeaac7711d6f2adb5d7532c0a (diff)
downloadgitea-e9ae926e040c94ce66666ae6c330c93918fa321c.tar.gz
gitea-e9ae926e040c94ce66666ae6c330c93918fa321c.zip
#809 fix wrong closed issue count when create closed issue via API
Add start count corrector for Repository.NumClosedIssues
-rw-r--r--README.md2
-rw-r--r--gogs.go2
-rw-r--r--models/repo.go21
-rw-r--r--routers/api/v1/repo/issue.go8
-rw-r--r--templates/.VERSION2
5 files changed, 29 insertions, 6 deletions
diff --git a/README.md b/README.md
index f56dc33a18..a6cb1630db 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
-##### Current version: 0.9.27
+##### Current version: 0.9.28
| Web | UI | Preview |
|:-------------:|:-------:|:-------:|
diff --git a/gogs.go b/gogs.go
index 2941012263..3795310e26 100644
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.9.27.0512"
+const APP_VER = "0.9.28.0527"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
diff --git a/models/repo.go b/models/repo.go
index 1715067df9..6cc16eca15 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1830,9 +1830,26 @@ func CheckRepoStats() {
repoStatsCheck(checkers[i])
}
- // FIXME: use checker when v0.9, stop supporting old fork repo format.
+ // ***** START: Repository.NumClosedIssues *****
+ desc := "repository count 'num_closed_issues'"
+ results, err := x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_closed_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=?)", true)
+ if err != nil {
+ log.Error(4, "Select %s: %v", desc, err)
+ } else {
+ for _, result := range results {
+ id := com.StrTo(result["id"]).MustInt64()
+ log.Trace("Updating %s: %d", desc, id)
+ _, err = x.Exec("UPDATE `repository` SET num_closed_issues=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=?) WHERE id=?", id, true, id)
+ if err != nil {
+ log.Error(4, "Update %s[%d]: %v", desc, id, err)
+ }
+ }
+ }
+ // ***** END: Repository.NumClosedIssues *****
+
+ // FIXME: use checker when stop supporting old fork repo format.
// ***** START: Repository.NumForks *****
- results, err := x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_forks!=(SELECT COUNT(*) FROM `repository` WHERE fork_id=repo.id)")
+ results, err = x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_forks!=(SELECT COUNT(*) FROM `repository` WHERE fork_id=repo.id)")
if err != nil {
log.Error(4, "Select repository count 'num_forks': %v", err)
} else {
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 8c9336ba9c..a80adbc356 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -57,7 +57,6 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
PosterID: ctx.User.Id,
Poster: ctx.User,
Content: form.Body,
- IsClosed: form.Closed,
}
if ctx.Repo.IsWriter() {
@@ -86,6 +85,13 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
return
}
+ if form.Closed {
+ if err := issue.ChangeStatus(ctx.User, ctx.Repo.Repository, true); err != nil {
+ ctx.Error(500, "issue.ChangeStatus", err)
+ return
+ }
+ }
+
// Refetch from database to assign some automatic values
var err error
issue, err = models.GetIssueByID(issue.ID)
diff --git a/templates/.VERSION b/templates/.VERSION
index 3821321969..e10c862842 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.9.27.0512 \ No newline at end of file
+0.9.28.0527 \ No newline at end of file