diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-02-13 01:42:28 +0100 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2017-02-12 19:42:28 -0500 |
commit | 99d86c7175f4c513597c1b8c4d75f0712c946c59 (patch) | |
tree | e8d30a38efc93eabed14dfb56c730a3c1cedde05 /routers/api/v1 | |
parent | 68ead67a6330953ae3ec3b78b85adae8da4bedf7 (diff) |
Implement more issue-endpoints (#3688)
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/api.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/issue.go | 26 |
2 files changed, 27 insertions, 3 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index b03f949f..85599568 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -221,6 +221,8 @@ func RegisterRoutes(m *macaron.Macaron) { m.Combo("/:id").Get(user.GetPublicKey). Delete(user.DeletePublicKey) }) + + m.Combo("/issues", reqToken()).Get(repo.ListUserIssues) }, reqToken()) // Repositories @@ -300,6 +302,8 @@ func RegisterRoutes(m *macaron.Macaron) { }, repoAssignment()) }, reqToken()) + m.Get("/issues", reqToken(), repo.ListUserIssues) + // Organizations m.Get("/user/orgs", reqToken(), org.ListMyOrgs) m.Get("/users/:username/orgs", org.ListUserOrgs) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index fe967ae0..059c6f74 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -15,15 +15,35 @@ import ( "github.com/gogits/gogs/modules/setting" ) +func ListUserIssues(ctx *context.APIContext) { + opts := models.IssuesOptions{ + AssigneeID: ctx.User.ID, + Page: ctx.QueryInt("page"), + } + + listIssues(ctx, &opts) +} + func ListIssues(ctx *context.APIContext) { - issues, err := models.Issues(&models.IssuesOptions{ + opts := models.IssuesOptions{ RepoID: ctx.Repo.Repository.ID, Page: ctx.QueryInt("page"), - }) + } + + listIssues(ctx, &opts) +} + +func listIssues(ctx *context.APIContext, opts *models.IssuesOptions) { + issues, err := models.Issues(opts) if err != nil { ctx.Error(500, "Issues", err) return } + count, err := models.IssuesCount(opts) + if err != nil { + ctx.Error(500, "IssuesCount", err) + return + } // FIXME: use IssueList to improve performance. apiIssues := make([]*api.Issue, len(issues)) @@ -35,7 +55,7 @@ func ListIssues(ctx *context.APIContext) { apiIssues[i] = issues[i].APIFormat() } - ctx.SetLinkHeader(ctx.Repo.Repository.NumIssues, setting.UI.IssuePagingNum) + ctx.SetLinkHeader(int(count), setting.UI.IssuePagingNum) ctx.JSON(200, &apiIssues) } |