mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Refactor Milestone related (#11225)
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user