summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/issue.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-03-29 18:12:21 +0100
committerGitHub <noreply@github.com>2021-03-29 18:12:21 +0100
commitc1ca4a83136c12853a3301b16dc8dce4cb0cf5c7 (patch)
treeed96de7ce320e719e5773229cc208e43601c656e /routers/api/v1/repo/issue.go
parent2b9e0b4d1bfb1b21851e1d56373cbcc52b2c2dfe (diff)
downloadgitea-c1ca4a83136c12853a3301b16dc8dce4cb0cf5c7.tar.gz
gitea-c1ca4a83136c12853a3301b16dc8dce4cb0cf5c7.zip
Improve /api/v1/repos/issues/search by just getting repo ids (#15179)
/api/v1/repos/issues/search is a highly inefficient search which is unfortunately the basis for our dependency searching algorithm. In particular it currently loads all of the repositories and their owners and their primary coding language all of which is immediately thrown away. This PR makes one simple change - just get the IDs. Related #14560 Related #12827 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers/api/v1/repo/issue.go')
-rw-r--r--routers/api/v1/repo/issue.go24
1 files changed, 4 insertions, 20 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 17dad97945..683a2a43b7 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -16,7 +16,6 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
- "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
@@ -113,11 +112,7 @@ func SearchIssues(ctx *context.APIContext) {
}
// find repos user can access (for issue search)
- repoIDs := make([]int64, 0)
opts := &models.SearchRepoOptions{
- ListOptions: models.ListOptions{
- PageSize: 15,
- },
Private: false,
AllPublic: true,
TopicOnly: false,
@@ -132,21 +127,10 @@ func SearchIssues(ctx *context.APIContext) {
opts.AllLimited = true
}
- for page := 1; ; page++ {
- opts.Page = page
- repos, count, err := models.SearchRepositoryByName(opts)
- if err != nil {
- ctx.Error(http.StatusInternalServerError, "SearchRepositoryByName", err)
- return
- }
-
- if len(repos) == 0 {
- break
- }
- log.Trace("Processing next %d repos of %d", len(repos), count)
- for _, repo := range repos {
- repoIDs = append(repoIDs, repo.ID)
- }
+ repoIDs, _, err := models.SearchRepositoryIDs(opts)
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "SearchRepositoryByName", err)
+ return
}
var issues []*models.Issue