1
0
Fork 0

Sync org teams task

This commit is contained in:
Gregory Eremin 2015-03-19 19:55:17 +07:00
parent 782769861a
commit 264e103196
1 changed files with 32 additions and 0 deletions

View File

@ -101,6 +101,38 @@ func SyncUserOrgs(token string) (err error) {
} }
} }
return
}
func SyncOrgTeams(token string, org *db.Org) (err error) {
defer report("SyncOrgTeams", time.Now())
client := newGithubClient(token)
opt := &github.ListOptions{PerPage: 100}
for {
opt.Page++
var teams []github.Team
var resp *github.Response
if teams, resp, err = client.Organizations.ListTeams(org.Login, opt); err != nil {
return
}
saveResponseMeta(token, resp)
for _, team := range teams {
t := &db.Team{
ID: uint64(*team.ID),
Name: *team.Name,
Slug: *team.Slug,
Permission: *team.Permission,
OrgID: org.ID,
}
t.Save()
}
if opt.Page == resp.LastPage {
break
}
}
return return
} }
} }