mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-08 08:02:12 +00:00
Merge pull request '[GITEA] Fix /issues/search endpoint' (#2020) from gusted/improve-search-issue into forgejo-dependency
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2020 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
a6f4d63b31
|
@ -2482,7 +2482,8 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
|||
func SearchIssues(ctx *context.Context) {
|
||||
before, since, err := context.GetQueryBeforeSince(ctx.Base)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusUnprocessableEntity, err.Error())
|
||||
log.Error("GetQueryBeforeSince: %v", err)
|
||||
ctx.Error(http.StatusUnprocessableEntity, "invalid before or since")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2519,10 +2520,11 @@ func SearchIssues(ctx *context.Context) {
|
|||
if ctx.FormString("owner") != "" {
|
||||
owner, err := user_model.GetUserByName(ctx, ctx.FormString("owner"))
|
||||
if err != nil {
|
||||
log.Error("GetUserByName: %v", err)
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
ctx.Error(http.StatusBadRequest, "Owner not found", err.Error())
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "GetUserByName", err.Error())
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -2533,15 +2535,16 @@ func SearchIssues(ctx *context.Context) {
|
|||
}
|
||||
if ctx.FormString("team") != "" {
|
||||
if ctx.FormString("owner") == "" {
|
||||
ctx.Error(http.StatusBadRequest, "", "Owner organisation is required for filtering on team")
|
||||
ctx.Error(http.StatusBadRequest, "Owner organisation is required for filtering on team")
|
||||
return
|
||||
}
|
||||
team, err := organization.GetTeam(ctx, opts.OwnerID, ctx.FormString("team"))
|
||||
if err != nil {
|
||||
log.Error("GetTeam: %v", err)
|
||||
if organization.IsErrTeamNotExist(err) {
|
||||
ctx.Error(http.StatusBadRequest, "Team not found", err.Error())
|
||||
ctx.Error(http.StatusBadRequest)
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "GetUserByName", err.Error())
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -2554,7 +2557,8 @@ func SearchIssues(ctx *context.Context) {
|
|||
}
|
||||
repoIDs, _, err = repo_model.SearchRepositoryIDs(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "SearchRepositoryIDs", err.Error())
|
||||
log.Error("SearchRepositoryIDs: %v", err)
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if len(repoIDs) == 0 {
|
||||
|
@ -2588,7 +2592,8 @@ func SearchIssues(ctx *context.Context) {
|
|||
}
|
||||
includedAnyLabels, err = issues_model.GetLabelIDsByNames(ctx, includedLabelNames)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetLabelIDsByNames", err.Error())
|
||||
log.Error("GetLabelIDsByNames: %v", err)
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -2602,7 +2607,8 @@ func SearchIssues(ctx *context.Context) {
|
|||
}
|
||||
includedMilestones, err = issues_model.GetMilestoneIDsByNames(ctx, includedMilestoneNames)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetMilestoneIDsByNames", err.Error())
|
||||
log.Error("GetMilestoneIDsByNames: %v", err)
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -2669,12 +2675,14 @@ func SearchIssues(ctx *context.Context) {
|
|||
|
||||
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "SearchIssues", err.Error())
|
||||
log.Error("SearchIssues: %v", err)
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
issues, err := issues_model.GetIssuesByIDs(ctx, ids, true)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "FindIssuesByIDs", err.Error())
|
||||
log.Error("GetIssuesByIDs: %v", err)
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue