mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-22 01:45:12 +09:00
Backport #40451 by @silverwind The dashboard repo list read the entire `commit_status_summary` table on every load when the page held an empty repo and the other repos' statuses were cached, about 1.2 s with 1M rows. Those other repos also showed and cached the status of an arbitrary older commit. Also fixes the MySQL upsert not updating `target_url`. Assisted-by: Claude Code:claude-opus-5-5 Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
62e9f747e8
commit
2d84f79e3b
2 files changed
+12
-2
No files matched your search
@@ -32,6 +32,9 @@ type RepoSHA struct {
|
||||
}
|
||||
|
||||
func GetLatestCommitStatusForRepoAndSHAs(ctx context.Context, repoSHAs []RepoSHA) ([]*CommitStatus, error) {
|
||||
if len(repoSHAs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
cond := builder.NewCond()
|
||||
for _, rs := range repoSHAs {
|
||||
cond = cond.Or(builder.Eq{"repo_id": rs.RepoID, "sha": rs.SHA})
|
||||
@@ -67,8 +70,8 @@ func UpdateCommitStatusSummary(ctx context.Context, repoID int64, sha string) er
|
||||
// mysql will return 0 when update a record which state hasn't been changed which behaviour is different from other database,
|
||||
// so we need to use insert in on duplicate
|
||||
if setting.Database.Type.IsMySQL() {
|
||||
_, err := db.GetEngine(ctx).Exec("INSERT INTO commit_status_summary (repo_id,sha,state,target_url) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE state=?",
|
||||
repoID, sha, state.State, state.TargetURL, state.State)
|
||||
_, err := db.GetEngine(ctx).Exec("INSERT INTO commit_status_summary (repo_id,sha,state,target_url) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE state=?, target_url=?",
|
||||
repoID, sha, state.State, state.TargetURL, state.State, state.TargetURL)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user