diff --git a/internal/git/git.go b/internal/git/git.go index 961a5354..db31617a 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -21,6 +21,11 @@ import ( "github.com/launchdarkly/ld-find-code-refs/v2/internal/log" ) +const ( + // ... other constants ... + millisecondsInSecond = 1000 // Descriptive constant for milliseconds conversion +) + type Client struct { workspace string GitBranch string @@ -327,7 +332,7 @@ func makeExtinctionRepFromCommit(projectKey, flagKey string, commit *object.Comm return ld.ExtinctionRep{ Revision: commit.Hash.String(), Message: commit.Message, - Time: commit.Author.When.Unix() * 1000, + Time: commit.Author.When.Unix() * millisecondsInSecond, ProjKey: projectKey, FlagKey: flagKey, } diff --git a/internal/ld/ld.go b/internal/ld/ld.go index 997bf271..9776d4f8 100644 --- a/internal/ld/ld.go +++ b/internal/ld/ld.go @@ -77,8 +77,8 @@ func IsTransient(err error) bool { // Fallback to default backoff if header can't be parsed // https://apidocs.launchdarkly.com/#section/Overview/Rate-limiting // Method is curried in order to avoid stubbing the time package and fallback Backoff in unit tests -func RateLimitBackoff(now func() time.Time, fallbackBackoff h.Backoff) func(minDuration, max time.Duration, attemptNum int, resp *http.Response) time.Duration { - return func(minDuration, max time.Duration, attemptNum int, resp *http.Response) time.Duration { +func RateLimitBackoff(now func() time.Time, fallbackBackoff h.Backoff) func(minDuration, maxDuration time.Duration, attemptNum int, resp *http.Response) time.Duration { + return func(minDuration, maxDuration time.Duration, attemptNum int, resp *http.Response) time.Duration { if resp != nil { if resp.StatusCode == http.StatusTooManyRequests { if s, ok := resp.Header["X-Ratelimit-Reset"]; ok { @@ -96,7 +96,7 @@ func RateLimitBackoff(now func() time.Time, fallbackBackoff h.Backoff) func(minD } } - return fallbackBackoff(minDuration, max, attemptNum, resp) + return fallbackBackoff(minDuration, maxDuration, attemptNum, resp) } }