mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-03-31 10:25:55 +00:00
Parallelize users admin page requests.
This commit is contained in:
parent
13aa7def19
commit
63070da7fb
1 changed files with 33 additions and 17 deletions
|
|
@ -481,28 +481,44 @@ func usersAdminHandler(w http.ResponseWriter, r *http.Request) *AppError {
|
|||
if err != nil {
|
||||
return InternalError(err, "Could not look up accounts")
|
||||
}
|
||||
users := make([]map[string]interface{}, len(accounts))
|
||||
|
||||
type AdminUserData struct {
|
||||
Account *Account
|
||||
User *github.User
|
||||
EmailAddress string
|
||||
Repos *Repos
|
||||
ReposError error
|
||||
}
|
||||
ch := make(chan *AdminUserData)
|
||||
for i := range accounts {
|
||||
account := &accounts[i]
|
||||
oauthTransport := githubOAuthTransport(c)
|
||||
oauthTransport.Token = &account.OAuthToken
|
||||
githubClient := github.NewClient(oauthTransport.Client())
|
||||
go func(account *Account) {
|
||||
oauthTransport := githubOAuthTransport(c)
|
||||
oauthTransport.Token = &account.OAuthToken
|
||||
githubClient := github.NewClient(oauthTransport.Client())
|
||||
|
||||
user, _, err := githubClient.Users.Get("")
|
||||
user, _, err := githubClient.Users.Get("")
|
||||
|
||||
emailAddress, err := account.GetDigestEmailAddress(githubClient)
|
||||
if err != nil {
|
||||
emailAddress = err.Error()
|
||||
}
|
||||
emailAddress, err := account.GetDigestEmailAddress(githubClient)
|
||||
if err != nil {
|
||||
emailAddress = err.Error()
|
||||
}
|
||||
|
||||
repos, reposErr := getRepos(c, githubClient, account, user)
|
||||
repos, reposErr := getRepos(c, githubClient, account, user)
|
||||
ch <- &AdminUserData{
|
||||
Account: account,
|
||||
User: user,
|
||||
EmailAddress: emailAddress,
|
||||
Repos: repos,
|
||||
ReposError: reposErr,
|
||||
}
|
||||
}(&accounts[i])
|
||||
}
|
||||
|
||||
users[i] = map[string]interface{}{
|
||||
"Account": account,
|
||||
"User": user,
|
||||
"EmailAddress": emailAddress,
|
||||
"Repos": repos,
|
||||
"ReposError": reposErr,
|
||||
users := make([]*AdminUserData, 0)
|
||||
for _ = range accounts {
|
||||
select {
|
||||
case r := <-ch:
|
||||
users = append(users, r)
|
||||
}
|
||||
}
|
||||
var data = map[string]interface{}{
|
||||
|
|
|
|||
Loading…
Reference in a new issue