Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Jul 30, 2021
1 parent 11217af commit 3a13265
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion controller/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func GetRepoChart(gh *github.GitHub, cache *cache.Redis) http.HandlerFunc {

stargazers, err := gh.Stargazers(r.Context(), repo)
if errors.Is(err, github.ErrTooManyStars) {
w.Write([]byte(errSvg(err)))
_, _ = w.Write([]byte(errSvg(err)))
return
}
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ var ErrGitHubAPI = errors.New("failed to talk with github api")

// GitHub client struct.
type GitHub struct {
tokens roundrobin.RoundRobiner
pageSize int
cache *cache.Redis
tokens roundrobin.RoundRobiner
pageSize int
cache *cache.Redis
maxRateUsagePct int
}

Expand Down Expand Up @@ -139,7 +139,7 @@ func (gh *GitHub) checkToken(token *roundrobin.Token) error {
}

func isAboveTargetUsage(rate rate, target int) bool {
return rate.Remaining*100 / rate.Limit < target
return rate.Remaining*100/rate.Limit < target
}

type rateLimit struct {
Expand Down
7 changes: 4 additions & 3 deletions internal/github/stars.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import (
"golang.org/x/sync/errgroup"
)

var errNoMorePages = errors.New("no more pages to get")
var ErrTooManyStars = errors.New("repo has too many stargazers, github won't allow us to list all stars")
var (
errNoMorePages = errors.New("no more pages to get")
ErrTooManyStars = errors.New("repo has too many stargazers, github won't allow us to list all stars")
)

// Stargazer is a star at a given time.
type Stargazer struct {
Expand Down Expand Up @@ -140,7 +142,6 @@ func (gh *GitHub) totalPages(repo Repository) int {
return repo.StargazersCount / gh.pageSize
}


func (gh *GitHub) lastPage(repo Repository) int {
return gh.totalPages(repo) + 1
}
Expand Down

0 comments on commit 3a13265

Please sign in to comment.