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
tokarchuk/v1.17
Lanre Adelowo 6 years ago committed by Lunny Xiao
parent d9b0b7f56e
commit 5e022a98e6
  1. 6
      models/issue_milestone.go
  2. 4
      routers/api/v1/repo/milestone.go
  3. 2
      templates/swagger/v1_json.tmpl

@ -11,7 +11,6 @@ import (
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/util"
api "code.gitea.io/sdk/gitea" api "code.gitea.io/sdk/gitea"
"github.com/go-xorm/xorm" "github.com/go-xorm/xorm"
) )
@ -178,10 +177,11 @@ func (milestones MilestoneList) getMilestoneIDs() []int64 {
return ids return ids
} }
// GetMilestonesByRepoID returns all milestones of a repository. // GetMilestonesByRepoID returns all opened milestones of a repository.
func GetMilestonesByRepoID(repoID int64) (MilestoneList, error) { func GetMilestonesByRepoID(repoID int64) (MilestoneList, error) {
miles := make([]*Milestone, 0, 10) 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. // GetMilestones returns a list of milestones of given repository and status.

@ -14,11 +14,11 @@ import (
api "code.gitea.io/sdk/gitea" 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) { func ListMilestones(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/milestones issue issueGetMilestonesList // 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: // produces:
// - application/json // - application/json
// parameters: // parameters:

@ -3065,7 +3065,7 @@
"tags": [ "tags": [
"issue" "issue"
], ],
"summary": "Get all of a repository's milestones", "summary": "Get all of a repository's opened milestones",
"operationId": "issueGetMilestonesList", "operationId": "issueGetMilestonesList",
"parameters": [ "parameters": [
{ {

Loading…
Cancel
Save