Skip to content

Commit

Permalink
print out total number of teams and users fetched
Browse files Browse the repository at this point in the history
add log when sleeping
  • Loading branch information
amenocal committed Nov 15, 2024
1 parent 23c4d3c commit cad327b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

}
}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/csv"
"log"
"os"
"strconv"
"strings"

"github.com/mona-actions/gh-migrate-teams/internal/repository"
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit cad327b

Please sign in to comment.