#809 fix wrong closed issue count when create closed issue via API
Add start count corrector for Repository.NumClosedIssuesrelease/v1.15
parent
28c03f1147
commit
e9ae926e04
|
@ -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 |
|
||||
|:-------------:|:-------:|:-------:|
|
||||
|
|
2
gogs.go
2
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())
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.9.27.0512
|
||||
0.9.28.0527
|
Loading…
Reference in New Issue