1
0
Fork 0
forked from forgejo/forgejo

Add stat to ToCommit function for speed (#21337)

Calls to ToCommit are very slow due to fetching diffs, analyzing files.
This patch lets us supply `stat` as false to speed fetching a commit
when we don't need the diff.

/v1/repo/commits has a default `stat` set as true now. Set to false to
experience fetching thousands of commits per second instead of 2-5 per
second.
This commit is contained in:
Gennady Kovshenin 2022-10-06 06:21:04 +03:00 committed by GitHub
parent 8765f139c7
commit fd2d5f06b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 31 deletions

View file

@ -69,7 +69,7 @@ func getNote(ctx *context.APIContext, identifier string) {
return
}
cmt, err := convert.ToCommit(ctx.Repo.Repository, ctx.Repo.GitRepo, note.Commit, nil)
cmt, err := convert.ToCommit(ctx.Repo.Repository, ctx.Repo.GitRepo, note.Commit, nil, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ToCommit", err)
return