From 812f71e21b5cbd998c12647fa879fa8ea2cace86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justin=20Nu=C3=9F?= Date: Tue, 22 Jul 2014 22:35:59 +0200 Subject: [PATCH] Update milestone issue stats when reopening/closing issue --- routers/repo/issue.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 5fe9ebc39..e71c835fd 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -642,6 +642,29 @@ func Comment(ctx *middleware.Context, params martini.Params) { return } + // Change open/closed issue counter for the associated milestone + if issue.MilestoneId > 0 { + l, err := models.GetMilestoneById(issue.MilestoneId) + + if err != nil { + ctx.Handle(500, "issue.Comment(GetLabelById)", err) + return + } + + if issue.IsClosed { + l.NumOpenIssues = l.NumOpenIssues - 1 + l.NumClosedIssues = l.NumClosedIssues + 1 + } else { + l.NumOpenIssues = l.NumOpenIssues + 1 + l.NumClosedIssues = l.NumClosedIssues - 1 + } + + if err = models.UpdateMilestone(l); err != nil { + ctx.Handle(500, "issue.Comment(UpdateLabel)", err) + return + } + } + cmtType := models.IT_CLOSE if !issue.IsClosed { cmtType = models.IT_REOPEN