aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/issue.go28
1 files changed, 13 insertions, 15 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 9afde1f5ed..253bdb43d2 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -18,27 +18,25 @@ import (
// ListIssues list the issues of a repository
func ListIssues(ctx *context.APIContext) {
- isClosed := ctx.Query("state") == "closed"
- issueOpts := models.IssuesOptions{
- RepoID: ctx.Repo.Repository.ID,
- Page: ctx.QueryInt("page"),
- IsClosed: util.OptionalBoolOf(isClosed),
+ var isClosed util.OptionalBool
+ switch ctx.Query("state") {
+ case "closed":
+ isClosed = util.OptionalBoolTrue
+ case "all":
+ isClosed = util.OptionalBoolNone
+ default:
+ isClosed = util.OptionalBoolFalse
}
- issues, err := models.Issues(&issueOpts)
+ issues, err := models.Issues(&models.IssuesOptions{
+ RepoID: ctx.Repo.Repository.ID,
+ Page: ctx.QueryInt("page"),
+ IsClosed: isClosed,
+ })
if err != nil {
ctx.Error(500, "Issues", err)
return
}
- if ctx.Query("state") == "all" {
- issueOpts.IsClosed = util.OptionalBoolOf(!isClosed)
- tempIssues, err := models.Issues(&issueOpts)
- if err != nil {
- ctx.Error(500, "Issues", err)
- return
- }
- issues = append(issues, tempIssues...)
- }
err = models.IssueList(issues).LoadAttributes()
if err != nil {