perf: avoid commit status summary full table scan (#40451) (#40459)

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:
Giteabotandsilverwind authored and GitHub committed 2026-11-20 11:41:12 +00:00
1 parent 62e9f747e8
commit 2d84f79e3b
2 files changed
+12 -2

No files matched your search

+7
View File
@@ -89,6 +89,13 @@ func TestGetCommitStatuses(t *testing.T) {
"deploy/awesomeness": 5,
}, latestIndexes)
})
t.Run("GetLatestCommitStatusForRepoAndSHAsEmpty", func(t *testing.T) {
assert.NoError(t, git_model.UpdateCommitStatusSummary(t.Context(), repo1.ID, sha1))
statuses, err := git_model.GetLatestCommitStatusForRepoAndSHAs(t.Context(), nil)
assert.NoError(t, err)
assert.Empty(t, statuses)
})
}
func Test_CalcCommitStatus(t *testing.T) {