Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format code #1

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions routers/api/v1/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ func SearchIssues(ctx *context.APIContext) {
var labelIDs []int64
var err error
if len(keyword) > 0 && len(repoIDs) > 0 {
issueIDs, err = issue_indexer.SearchIssuesByKeyword(repoIDs, keyword)
if err != nil {
if issueIDs, err = issue_indexer.SearchIssuesByKeyword(repoIDs, keyword); err != nil {
ctx.Error(http.StatusInternalServerError, "SearchIssuesByKeyword", err)
return
}
Expand All @@ -157,6 +156,10 @@ func SearchIssues(ctx *context.APIContext) {
// This would otherwise return all issues if no issues were found by the search.
if len(keyword) == 0 || len(issueIDs) > 0 || len(labelIDs) > 0 {
issuesOpt := &models.IssuesOptions{
ListOptions: models.ListOptions{
Page: ctx.QueryInt("page"),
PageSize: setting.UI.IssuePagingNum,
},
RepoIDs: repoIDs,
IsClosed: isClosed,
IssueIDs: issueIDs,
Expand All @@ -166,12 +169,7 @@ func SearchIssues(ctx *context.APIContext) {
IsPull: isPull,
}

issuesOpt.ListOptions = models.ListOptions{
Page: ctx.QueryInt("page"),
PageSize: setting.UI.IssuePagingNum,
}
issues, err = models.Issues(issuesOpt)
if err != nil {
if issues, err = models.Issues(issuesOpt); err != nil {
ctx.Error(http.StatusInternalServerError, "Issues", err)
return
}
Expand All @@ -180,8 +178,7 @@ func SearchIssues(ctx *context.APIContext) {
Page: 0,
PageSize: issueCount,
}
filteredCount, err = models.CountIssues(issuesOpt)
if err != nil {
if filteredCount, err = models.CountIssues(issuesOpt); err != nil {
ctx.Error(http.StatusInternalServerError, "CountIssues", err)
return
}
Expand Down Expand Up @@ -326,6 +323,7 @@ func ListIssues(ctx *context.APIContext) {
// This would otherwise return all issues if no issues were found by the search.
if len(keyword) == 0 || len(issueIDs) > 0 || len(labelIDs) > 0 {
issuesOpt := &models.IssuesOptions{
ListOptions: listOptions,
RepoIDs: []int64{ctx.Repo.Repository.ID},
IsClosed: isClosed,
IssueIDs: issueIDs,
Expand All @@ -334,9 +332,7 @@ func ListIssues(ctx *context.APIContext) {
IsPull: isPull,
}

issuesOpt.ListOptions = listOptions
issues, err = models.Issues(issuesOpt)
if err != nil {
if issues, err = models.Issues(issuesOpt); err != nil {
ctx.Error(http.StatusInternalServerError, "Issues", err)
return
}
Expand All @@ -345,16 +341,14 @@ func ListIssues(ctx *context.APIContext) {
Page: 0,
PageSize: ctx.Repo.Repository.NumIssues,
}
filteredCount, err = models.CountIssues(issuesOpt)
if err != nil {
if filteredCount, err = models.CountIssues(issuesOpt); err != nil {
ctx.Error(http.StatusInternalServerError, "CountIssues", err)
return
}
}

ctx.SetLinkHeader(int(filteredCount), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", filteredCount))

ctx.JSON(http.StatusOK, convert.ToAPIIssueList(issues))
}

Expand Down