summaryrefslogtreecommitdiffstats
path: root/models/issue_list.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-29 21:02:12 +0800
committerGitHub <noreply@github.com>2021-12-29 21:02:12 +0800
commit8ce1b539b1aaf242903b5b0c342dd592bd8da8d9 (patch)
tree455d363b51d69a9be4058961a16d5c43b7698f47 /models/issue_list.go
parent8fa97a25f0dccc4db94d344ce7af632f8fe358b0 (diff)
downloadgitea-8ce1b539b1aaf242903b5b0c342dd592bd8da8d9.tar.gz
gitea-8ce1b539b1aaf242903b5b0c342dd592bd8da8d9.zip
Use conditions but not repo ids as query condition (#16839)
* Use conditions but not repo ids as query condition * Improve the performance of pulls/issue * Remove duplicated code * fix lint * Fix bug * Fix stats * More fixes * Fix build * Fix lint * Fix test * Fix build * Adjust the logic * Merge * Fix conflicts * improve the performance * Add comments for the query conditions functions * Some improvements
Diffstat (limited to 'models/issue_list.go')
-rw-r--r--models/issue_list.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/models/issue_list.go b/models/issue_list.go
index 5d8a9f6921..b516e7336e 100644
--- a/models/issue_list.go
+++ b/models/issue_list.go
@@ -25,6 +25,9 @@ const (
func (issues IssueList) getRepoIDs() []int64 {
repoIDs := make(map[int64]struct{}, len(issues))
for _, issue := range issues {
+ if issue.Repo != nil {
+ continue
+ }
if _, ok := repoIDs[issue.RepoID]; !ok {
repoIDs[issue.RepoID] = struct{}{}
}
@@ -56,8 +59,12 @@ func (issues IssueList) loadRepositories(e db.Engine) ([]*repo_model.Repository,
}
for _, issue := range issues {
- issue.Repo = repoMaps[issue.RepoID]
- if issue.PullRequest != nil {
+ if issue.Repo == nil {
+ issue.Repo = repoMaps[issue.RepoID]
+ } else {
+ repoMaps[issue.RepoID] = issue.Repo
+ }
+ if issue.PullRequest != nil && issue.PullRequest.BaseRepo == nil {
issue.PullRequest.BaseRepo = issue.Repo
}
}