summaryrefslogtreecommitdiffstats
path: root/routers/repo/milestone.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-05-12 23:54:35 +0200
committerGitHub <noreply@github.com>2020-05-12 22:54:35 +0100
commit7257c39ddfe9d9d424192e6bd307a70ed544f5be (patch)
tree67e2fb0861e0b5fe610e424c8b3906db438c6335 /routers/repo/milestone.go
parentba40263fdda53446c7cae6e41885ebdee8bb7b52 (diff)
downloadgitea-7257c39ddfe9d9d424192e6bd307a70ed544f5be.tar.gz
gitea-7257c39ddfe9d9d424192e6bd307a70ed544f5be.zip
Refactor Milestone related (#11225)
Diffstat (limited to 'routers/repo/milestone.go')
-rw-r--r--routers/repo/milestone.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/routers/repo/milestone.go b/routers/repo/milestone.go
index 5fbf929f35..e30e6371f0 100644
--- a/routers/repo/milestone.go
+++ b/routers/repo/milestone.go
@@ -15,6 +15,8 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
+
+ "xorm.io/builder"
)
const (
@@ -30,13 +32,13 @@ func Milestones(ctx *context.Context) {
ctx.Data["PageIsMilestones"] = true
isShowClosed := ctx.Query("state") == "closed"
- openCount, closedCount, err := models.MilestoneStats(ctx.Repo.Repository.ID)
+ stats, err := models.GetMilestonesStatsByRepoCond(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}))
if err != nil {
ctx.ServerError("MilestoneStats", err)
return
}
- ctx.Data["OpenCount"] = openCount
- ctx.Data["ClosedCount"] = closedCount
+ ctx.Data["OpenCount"] = stats.OpenCount
+ ctx.Data["ClosedCount"] = stats.ClosedCount
sortType := ctx.Query("sort")
page := ctx.QueryInt("page")
@@ -46,9 +48,9 @@ func Milestones(ctx *context.Context) {
var total int
if !isShowClosed {
- total = int(openCount)
+ total = int(stats.OpenCount)
} else {
- total = int(closedCount)
+ total = int(stats.ClosedCount)
}
miles, err := models.GetMilestones(ctx.Repo.Repository.ID, page, isShowClosed, sortType)