From 5e022a98e6429d08e3a32e10fa7ba98566ab71a1 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Mon, 26 Nov 2018 09:45:42 +0100 Subject: [PATCH] show only opened milestones on issues page milestone filter (#5051) * show only opened milestones on issues page milestone filter * update Godoc * update Godoc everywhere * update swagger * use false instead of 0 * Add seccond ordering by ID for milestones where no deadline is set --- models/issue_milestone.go | 6 +++--- routers/api/v1/repo/milestone.go | 4 ++-- templates/swagger/v1_json.tmpl | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/models/issue_milestone.go b/models/issue_milestone.go index a84522a6d1..ead3e5a4f6 100644 --- a/models/issue_milestone.go +++ b/models/issue_milestone.go @@ -11,7 +11,6 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" api "code.gitea.io/sdk/gitea" - "github.com/go-xorm/xorm" ) @@ -178,10 +177,11 @@ func (milestones MilestoneList) getMilestoneIDs() []int64 { return ids } -// GetMilestonesByRepoID returns all milestones of a repository. +// GetMilestonesByRepoID returns all opened milestones of a repository. func GetMilestonesByRepoID(repoID int64) (MilestoneList, error) { miles := make([]*Milestone, 0, 10) - return miles, x.Where("repo_id = ?", repoID).Asc("deadline_unix").Find(&miles) + return miles, x.Where("repo_id = ? AND is_closed = ?", repoID, false). + Asc("deadline_unix").Asc("id").Find(&miles) } // GetMilestones returns a list of milestones of given repository and status. diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go index c621536ad7..88386c3efa 100644 --- a/routers/api/v1/repo/milestone.go +++ b/routers/api/v1/repo/milestone.go @@ -14,11 +14,11 @@ import ( api "code.gitea.io/sdk/gitea" ) -// ListMilestones list all the milestones for a repository +// ListMilestones list all the opened milestones for a repository func ListMilestones(ctx *context.APIContext) { // swagger:operation GET /repos/{owner}/{repo}/milestones issue issueGetMilestonesList // --- - // summary: Get all of a repository's milestones + // summary: Get all of a repository's opened milestones // produces: // - application/json // parameters: diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index dada2c98e3..8befe64f89 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -3065,7 +3065,7 @@ "tags": [ "issue" ], - "summary": "Get all of a repository's milestones", + "summary": "Get all of a repository's opened milestones", "operationId": "issueGetMilestonesList", "parameters": [ { -- 2.39.5