From 9d28a281a29e1151548f911c0f0bc3291de133a9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 25 Mar 2025 12:37:43 -0700 Subject: [PATCH] Some comments --- services/repository/contributors_graph.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/services/repository/contributors_graph.go b/services/repository/contributors_graph.go index 6488f10470..9112b592a8 100644 --- a/services/repository/contributors_graph.go +++ b/services/repository/contributors_graph.go @@ -6,7 +6,6 @@ package repository import ( "bufio" "context" - "errors" "fmt" "os" "strconv" @@ -29,8 +28,6 @@ const ( contributorStatsCacheTimeout int64 = 60 * 10 ) -var ErrAwaitGeneration = errors.New("generation took longer than ") - type WeekData struct { Week int64 `json:"week"` // Starting day of the week as Unix timestamp Additions int `json:"additions"` // Number of additions in that week @@ -85,14 +82,14 @@ func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *rep return res, nil } - // dont start multiple async generations + // dont start multiple generations for the same repository and same revision releaser, err := globallock.Lock(ctx, cacheKey) if err != nil { return nil, err } defer releaser() - // check if generation is already completed by other request + // check if generation is already completed by other request when we were waiting for lock if cache.IsExist(cacheKey) { var res map[string]*ContributorData if _, cacheErr := cache.GetJSON(cacheKey, &res); cacheErr != nil { @@ -101,7 +98,6 @@ func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *rep return res, nil } - // run generation async res, err := generateContributorStats(ctx, repo, revision) if err != nil { return nil, err @@ -196,7 +192,7 @@ func getExtendedCommitStats(ctx context.Context, repoPath string, baseCommit *gi }, }) if err != nil { - return nil, fmt.Errorf("Failed to get ContributorsCommitStats for repository.\nError: %w\nStderr: %s", err, stderr) + return nil, fmt.Errorf("failed to get ContributorsCommitStats for repository.\nError: %w\nStderr: %s", err, stderr) } return extendedCommitStats, nil