Skip to content

Commit 9d28a28

Browse files
committed
Some comments
1 parent 450a27b commit 9d28a28

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

services/repository/contributors_graph.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package repository
66
import (
77
"bufio"
88
"context"
9-
"errors"
109
"fmt"
1110
"os"
1211
"strconv"
@@ -29,8 +28,6 @@ const (
2928
contributorStatsCacheTimeout int64 = 60 * 10
3029
)
3130

32-
var ErrAwaitGeneration = errors.New("generation took longer than ")
33-
3431
type WeekData struct {
3532
Week int64 `json:"week"` // Starting day of the week as Unix timestamp
3633
Additions int `json:"additions"` // Number of additions in that week
@@ -85,14 +82,14 @@ func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *rep
8582
return res, nil
8683
}
8784

88-
// dont start multiple async generations
85+
// dont start multiple generations for the same repository and same revision
8986
releaser, err := globallock.Lock(ctx, cacheKey)
9087
if err != nil {
9188
return nil, err
9289
}
9390
defer releaser()
9491

95-
// check if generation is already completed by other request
92+
// check if generation is already completed by other request when we were waiting for lock
9693
if cache.IsExist(cacheKey) {
9794
var res map[string]*ContributorData
9895
if _, cacheErr := cache.GetJSON(cacheKey, &res); cacheErr != nil {
@@ -101,7 +98,6 @@ func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *rep
10198
return res, nil
10299
}
103100

104-
// run generation async
105101
res, err := generateContributorStats(ctx, repo, revision)
106102
if err != nil {
107103
return nil, err
@@ -196,7 +192,7 @@ func getExtendedCommitStats(ctx context.Context, repoPath string, baseCommit *gi
196192
},
197193
})
198194
if err != nil {
199-
return nil, fmt.Errorf("Failed to get ContributorsCommitStats for repository.\nError: %w\nStderr: %s", err, stderr)
195+
return nil, fmt.Errorf("failed to get ContributorsCommitStats for repository.\nError: %w\nStderr: %s", err, stderr)
200196
}
201197

202198
return extendedCommitStats, nil

0 commit comments

Comments
 (0)