mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 09:50:41 +00:00
Properly calculate the number of open issues per label
This commit is contained in:
parent
cd8b43d984
commit
1f61340fa3
2 changed files with 41 additions and 0 deletions
|
@ -182,6 +182,17 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com
|
||||||
}
|
}
|
||||||
issue.IsClosed = true
|
issue.IsClosed = true
|
||||||
|
|
||||||
|
if err = issue.GetLabels(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, label := range issue.Labels {
|
||||||
|
label.NumClosedIssues++
|
||||||
|
|
||||||
|
if err = UpdateLabel(label); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err = UpdateIssue(issue); err != nil {
|
if err = UpdateIssue(issue); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if err = UpdateIssueUserPairsByStatus(issue.Id, issue.IsClosed); err != nil {
|
} else if err = UpdateIssueUserPairsByStatus(issue.Id, issue.IsClosed); err != nil {
|
||||||
|
@ -230,6 +241,17 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com
|
||||||
}
|
}
|
||||||
issue.IsClosed = false
|
issue.IsClosed = false
|
||||||
|
|
||||||
|
if err = issue.GetLabels(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, label := range issue.Labels {
|
||||||
|
label.NumClosedIssues--
|
||||||
|
|
||||||
|
if err = UpdateLabel(label); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err = UpdateIssue(issue); err != nil {
|
if err = UpdateIssue(issue); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if err = UpdateIssueUserPairsByStatus(issue.Id, issue.IsClosed); err != nil {
|
} else if err = UpdateIssueUserPairsByStatus(issue.Id, issue.IsClosed); err != nil {
|
||||||
|
|
|
@ -549,6 +549,7 @@ func UpdateIssueLabel(ctx *middleware.Context) {
|
||||||
label.NumClosedIssues--
|
label.NumClosedIssues--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = models.UpdateLabel(label); err != nil {
|
if err = models.UpdateLabel(label); err != nil {
|
||||||
ctx.Handle(500, "issue.UpdateIssueLabel(UpdateLabel)", err)
|
ctx.Handle(500, "issue.UpdateIssueLabel(UpdateLabel)", err)
|
||||||
return
|
return
|
||||||
|
@ -767,6 +768,24 @@ func Comment(ctx *middleware.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = issue.GetLabels(); err != nil {
|
||||||
|
send(500, nil, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, label := range issue.Labels {
|
||||||
|
if issue.IsClosed {
|
||||||
|
label.NumClosedIssues++
|
||||||
|
} else {
|
||||||
|
label.NumClosedIssues--
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = models.UpdateLabel(label); err != nil {
|
||||||
|
send(500, nil, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Change open/closed issue counter for the associated milestone
|
// Change open/closed issue counter for the associated milestone
|
||||||
if issue.MilestoneId > 0 {
|
if issue.MilestoneId > 0 {
|
||||||
if err = models.ChangeMilestoneIssueStats(issue); err != nil {
|
if err = models.ChangeMilestoneIssueStats(issue); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue