From cad327b05272c19bd1b3e58a70d36da2f94f55f7 Mon Sep 17 00:00:00 2001 From: Alejandro Menocal Date: Fri, 15 Nov 2024 10:24:10 -0600 Subject: [PATCH] print out total number of teams and users fetched add log when sleeping --- internal/api/api.go | 2 ++ pkg/sync/sync.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/internal/api/api.go b/internal/api/api.go index e9edeb5..cca400e 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -43,7 +43,9 @@ func (c *RateLimitAwareGraphQLClient) Query(ctx context.Context, q interface{}, return nil } else { // Sleep until rate limit resets + log.Println("Rate limit exceeded, sleeping until reset at:", rateLimitQuery.RateLimit.ResetAt.Time) time.Sleep(time.Until(rateLimitQuery.RateLimit.ResetAt.Time)) + } } } diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index 25255d2..f46af74 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -4,6 +4,7 @@ import ( "encoding/csv" "log" "os" + "strconv" "strings" "github.com/mona-actions/gh-migrate-teams/internal/repository" @@ -85,6 +86,7 @@ func SyncTeamsByRepo() { repos, err := repository.ParseRepositoryFile(os.Getenv("GHMT_REPO_FILE")) teams := []team.Team{} teamMap := make(map[string]bool) // Map to track added teams + totalMembers := 0 if err != nil { log.Println("error while reading repository file - ", err) @@ -100,9 +102,13 @@ func SyncTeamsByRepo() { // If the team is not in the map, add it to the map and the teams slice teamMap[t.Id] = true teams = append(teams, t) + totalMembers += len(t.Members) } } } + // Print out how many teams were found: + teamsSpinnerSuccess.UpdateText("Fetched a total of " + strconv.Itoa(len(teams)) + " teams with total of " + strconv.Itoa(totalMembers) + " members from the repository list") + teamsSpinnerSuccess.Success() // Create teams in target organization