aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-07-03 09:53:05 +0800
committerGitHub <noreply@github.com>2023-07-03 01:53:05 +0000
commit807c9712efd4ae43052c971e92bda5724a9c3724 (patch)
tree1f5dce00df9b182ffda242a5fc1f90677121c0aa /routers/web
parent640a88fa099302919320ab242aa21a2ded1c4760 (diff)
downloadgitea-807c9712efd4ae43052c971e92bda5724a9c3724.tar.gz
gitea-807c9712efd4ae43052c971e92bda5724a9c3724.zip
Get latest commit statuses from database instead of git data on dashboard for repositories (#25605)
related #24638
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/repo/repo.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index a1e1346b38..781a12b2d9 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -579,13 +579,15 @@ func SearchRepo(ctx *context.Context) {
// collect the latest commit of each repo
// at most there are dozens of repos (limited by MaxResponseItems), so it's not a big problem at the moment
- repoIDsToLatestCommitSHAs := make(map[int64]string, len(repos))
+ repoBranchNames := make(map[int64]string, len(repos))
for _, repo := range repos {
- commitID, err := repo_service.GetBranchCommitID(ctx, repo, repo.DefaultBranch)
- if err != nil {
- continue
- }
- repoIDsToLatestCommitSHAs[repo.ID] = commitID
+ repoBranchNames[repo.ID] = repo.DefaultBranch
+ }
+
+ repoIDsToLatestCommitSHAs, err := git_model.FindBranchesByRepoAndBranchName(ctx, repoBranchNames)
+ if err != nil {
+ log.Error("FindBranchesByRepoAndBranchName: %v", err)
+ return
}
// call the database O(1) times to get the commit statuses for all repos