Fix incorrect milestone count when provide a keyword (#25880)
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. 
This commit is contained in:
		
					parent
					
						
							
								ec35af470c
							
						
					
				
			
			
				commit
				
					
						3add4ca216
					
				
			
		
					 1 changed files with 9 additions and 10 deletions
				
			
		| 
						 | 
					@ -38,18 +38,8 @@ func Milestones(ctx *context.Context) {
 | 
				
			||||||
	ctx.Data["PageIsMilestones"] = true
 | 
						ctx.Data["PageIsMilestones"] = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	isShowClosed := ctx.FormString("state") == "closed"
 | 
						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")
 | 
						sortType := ctx.FormString("sort")
 | 
				
			||||||
 | 
					 | 
				
			||||||
	keyword := ctx.FormTrim("q")
 | 
						keyword := ctx.FormTrim("q")
 | 
				
			||||||
 | 
					 | 
				
			||||||
	page := ctx.FormInt("page")
 | 
						page := ctx.FormInt("page")
 | 
				
			||||||
	if page <= 1 {
 | 
						if page <= 1 {
 | 
				
			||||||
		page = 1
 | 
							page = 1
 | 
				
			||||||
| 
						 | 
					@ -74,6 +64,15 @@ func Milestones(ctx *context.Context) {
 | 
				
			||||||
		ctx.ServerError("GetMilestones", err)
 | 
							ctx.ServerError("GetMilestones", err)
 | 
				
			||||||
		return
 | 
							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 ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
 | 
				
			||||||
		if err := miles.LoadTotalTrackedTimes(); err != nil {
 | 
							if err := miles.LoadTotalTrackedTimes(); err != nil {
 | 
				
			||||||
			ctx.ServerError("LoadTotalTrackedTimes", err)
 | 
								ctx.ServerError("LoadTotalTrackedTimes", err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue