#809 fix wrong closed issue count when create closed issue via API

Add start count corrector for Repository.NumClosedIssues
tokarchuk/v1.17
Unknwon 9 years ago
parent 28c03f1147
commit e9ae926e04
  1. 2
      README.md
  2. 2
      gogs.go
  3. 21
      models/repo.go
  4. 8
      routers/api/v1/repo/issue.go
  5. 2
      templates/.VERSION

@ -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) ![](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 | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.9.27.0512" const APP_VER = "0.9.28.0527"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

@ -1830,9 +1830,26 @@ func CheckRepoStats() {
repoStatsCheck(checkers[i]) 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 ***** // ***** 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 { if err != nil {
log.Error(4, "Select repository count 'num_forks': %v", err) log.Error(4, "Select repository count 'num_forks': %v", err)
} else { } else {

@ -57,7 +57,6 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
PosterID: ctx.User.Id, PosterID: ctx.User.Id,
Poster: ctx.User, Poster: ctx.User,
Content: form.Body, Content: form.Body,
IsClosed: form.Closed,
} }
if ctx.Repo.IsWriter() { if ctx.Repo.IsWriter() {
@ -86,6 +85,13 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
return 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 // Refetch from database to assign some automatic values
var err error var err error
issue, err = models.GetIssueByID(issue.ID) issue, err = models.GetIssueByID(issue.ID)

@ -1 +1 @@
0.9.27.0512 0.9.28.0527
Loading…
Cancel
Save