summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-07-17 05:12:59 -0400
committerGitHub <noreply@github.com>2023-07-17 11:12:59 +0200
commit36b9a86bd803646dd97832fb24b4fcf7a0cdf410 (patch)
tree163422cd29f35595315ca0be3f71ac5c23f98b66
parente627f161c2ff75d3bb66b494ce8d9d2b77e6b7ec (diff)
downloadgitea-36b9a86bd803646dd97832fb24b4fcf7a0cdf410.tar.gz
gitea-36b9a86bd803646dd97832fb24b4fcf7a0cdf410.zip
Fix incorrect milestone count when provide a keyword (#25880) (#25904)
Backport #25880 by @yp05327 You can confirm this issue in: https://try.gitea.io/yp05327/testrepo/milestones?state=open&q=a There's no milestone, but the count is 1. ![image](https://github.com/go-gitea/gitea/assets/18380374/25e58cee-aeeb-43c1-8ec8-6e2ec6bf1284) Co-authored-by: yp05327 <576951401@qq.com>
-rw-r--r--routers/web/repo/milestone.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go
index 38ef693967..f422151994 100644
--- a/routers/web/repo/milestone.go
+++ b/routers/web/repo/milestone.go
@@ -38,18 +38,8 @@ func Milestones(ctx *context.Context) {
ctx.Data["PageIsMilestones"] = true
isShowClosed := ctx.FormString("state") == "closed"
- stats, err := issues_model.GetMilestonesStatsByRepoCond(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}))
- if err != nil {
- ctx.ServerError("MilestoneStats", err)
- return
- }
- ctx.Data["OpenCount"] = stats.OpenCount
- ctx.Data["ClosedCount"] = stats.ClosedCount
-
sortType := ctx.FormString("sort")
-
keyword := ctx.FormTrim("q")
-
page := ctx.FormInt("page")
if page <= 1 {
page = 1
@@ -74,6 +64,15 @@ func Milestones(ctx *context.Context) {
ctx.ServerError("GetMilestones", err)
return
}
+
+ stats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}), keyword)
+ if err != nil {
+ ctx.ServerError("GetMilestoneStats", err)
+ return
+ }
+ ctx.Data["OpenCount"] = stats.OpenCount
+ ctx.Data["ClosedCount"] = stats.ClosedCount
+
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
if err := miles.LoadTotalTrackedTimes(); err != nil {
ctx.ServerError("LoadTotalTrackedTimes", err)