mirror of https://github.com/gogs/gogs.git
api/issue: minor code refactor (#3688)
parent
99d86c7175
commit
1c87b082c1
|
@ -813,6 +813,7 @@ type IssuesOptions struct {
|
||||||
SortType string
|
SortType string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// buildIssuesQuery returns nil if it foresees there won't be any value returned.
|
||||||
func buildIssuesQuery(opts *IssuesOptions) *xorm.Session {
|
func buildIssuesQuery(opts *IssuesOptions) *xorm.Session {
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
|
|
||||||
|
|
|
@ -15,30 +15,13 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"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) {
|
func listIssues(ctx *context.APIContext, opts *models.IssuesOptions) {
|
||||||
issues, err := models.Issues(opts)
|
issues, err := models.Issues(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "Issues", err)
|
ctx.Error(500, "Issues", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
count, err := models.IssuesCount(opts)
|
count, err := models.IssuesCount(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "IssuesCount", err)
|
ctx.Error(500, "IssuesCount", err)
|
||||||
|
@ -59,6 +42,24 @@ func listIssues(ctx *context.APIContext, opts *models.IssuesOptions) {
|
||||||
ctx.JSON(200, &apiIssues)
|
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) {
|
func GetIssue(ctx *context.APIContext) {
|
||||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue