diff options
author | Unknwon <u@gogs.io> | 2017-02-12 19:46:38 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-02-12 19:46:38 -0500 |
commit | 1c87b082c1545a02293e08773f402b19f1ebaffe (patch) | |
tree | 5c790c9dfc0216f579e0e453728158cc2d77c1c5 /routers/api/v1/repo | |
parent | 99d86c7175f4c513597c1b8c4d75f0712c946c59 (diff) |
api/issue: minor code refactor (#3688)
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r-- | routers/api/v1/repo/issue.go | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 059c6f74..7b823e9e 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -15,30 +15,13 @@ 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) { - 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) @@ -59,6 +42,24 @@ func listIssues(ctx *context.APIContext, opts *models.IssuesOptions) { ctx.JSON(200, &apiIssues) } +func ListUserIssues(ctx *context.APIContext) { + opts := models.IssuesOptions{ + AssigneeID: ctx.User.ID, + Page: ctx.QueryInt("page"), + } + + listIssues(ctx, &opts) +} + +func ListIssues(ctx *context.APIContext) { + opts := models.IssuesOptions{ + RepoID: ctx.Repo.Repository.ID, + Page: ctx.QueryInt("page"), + } + + listIssues(ctx, &opts) +} + func GetIssue(ctx *context.APIContext) { issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { |