You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/07/14 07:39:13 UTC

[incubator-devlake] 04/06: fix: Response needn't to be renamed

This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit ba87f8ac1c97d09fe2e000a9bb0a8aefcb7cb5b4
Author: phzbbbbbbbb <48...@users.noreply.github.com>
AuthorDate: Wed Jul 13 22:50:39 2022 +0800

    fix: Response needn't to be renamed
---
 plugins/github/tasks/api_client.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/plugins/github/tasks/api_client.go b/plugins/github/tasks/api_client.go
index 55bfd47f..6a37a893 100644
--- a/plugins/github/tasks/api_client.go
+++ b/plugins/github/tasks/api_client.go
@@ -59,13 +59,13 @@ func CreateApiClient(taskCtx core.TaskContext, connection *models.GithubConnecti
 		Method:               http.MethodGet,
 		DynamicRateLimit: func(res *http.Response) (int, time.Duration, error) {
 			/* calculate by number of remaining requests
-			remaining, err := strconv.Atoi(res.Header.Get("X-RateLimitPerHour-Remaining"))
+			remaining, err := strconv.Atoi(res.Header.Get("X-RateLimit-Remaining"))
 			if err != nil {
-				return 0,0, fmt.Errorf("failed to parse X-RateLimitPerHour-Remaining header: %w", err)
+				return 0,0, fmt.Errorf("failed to parse X-RateLimit-Remaining header: %w", err)
 			}
-			reset, err := strconv.Atoi(res.Header.Get("X-RateLimitPerHour-Reset"))
+			reset, err := strconv.Atoi(res.Header.Get("X-RateLimit-Reset"))
 			if err != nil {
-				return 0, 0, fmt.Errorf("failed to parse X-RateLimitPerHour-Reset header: %w", err)
+				return 0, 0, fmt.Errorf("failed to parse X-RateLimit-Reset header: %w", err)
 			}
 			date, err := http.ParseTime(res.Header.Get("Date"))
 			if err != nil {
@@ -73,9 +73,9 @@ func CreateApiClient(taskCtx core.TaskContext, connection *models.GithubConnecti
 			}
 			return remaining * len(tokens), time.Unix(int64(reset), 0).Sub(date), nil
 			*/
-			rateLimit, err := strconv.Atoi(res.Header.Get("X-RateLimitPerHour-Limit"))
+			rateLimit, err := strconv.Atoi(res.Header.Get("X-RateLimit-Limit"))
 			if err != nil {
-				return 0, 0, fmt.Errorf("failed to parse X-RateLimitPerHour-Limit header: %w", err)
+				return 0, 0, fmt.Errorf("failed to parse X-RateLimit-Limit header: %w", err)
 			}
 			// even though different token could have different rate limit, but it is hard to support it
 			// so, we calculate the rate limit of a single token, and presume all tokens are the same, to