1
0
Fork 0

Int should be enough

This commit is contained in:
Gregory Eremin 2015-03-20 22:22:49 +07:00
parent 788b7d7683
commit abd0d96b10
10 changed files with 39 additions and 39 deletions

View File

@ -5,13 +5,13 @@ import (
)
type Contrib struct {
Week uint64 `json:"week"`
OrgID uint64 `json:"org_id"`
RepoID uint64 `json:"repo_id"`
UserID uint64 `json:"user_id"`
Commits uint64 `json:"commits"`
Additions uint64 `json:"additions"`
Deletions uint64 `json:"deletions"`
Week int `json:"week"`
OrgID int `json:"org_id"`
RepoID int `json:"repo_id"`
UserID int `json:"user_id"`
Commits int `json:"commits"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
}
func (c *Contrib) Save() {

View File

@ -7,13 +7,13 @@ import (
"time"
)
func SaveOrgMembers(orgID uint64, members []uint64) {
func SaveOrgMembers(orgID int, members []int) {
defer measure("SaveOrgMembers", time.Now())
tx := db.MustBegin()
var ids = []string{}
for _, id := range members {
ids = append(ids, strconv.FormatUint(id, 10))
ids = append(ids, strconv.Itoa(id))
}
tx.MustExec(fmt.Sprintf(`
delete from org_members
@ -37,13 +37,13 @@ func SaveOrgMembers(orgID uint64, members []uint64) {
}
}
func SaveTeamMembers(orgID, teamID uint64, members []uint64) {
func SaveTeamMembers(orgID, teamID int, members []int) {
defer measure("SaveTeamMembers", time.Now())
tx := db.MustBegin()
var ids = []string{}
for _, id := range members {
ids = append(ids, strconv.FormatUint(id, 10))
ids = append(ids, strconv.Itoa(id))
}
tx.MustExec(fmt.Sprintf(`
delete from team_members
@ -68,13 +68,13 @@ func SaveTeamMembers(orgID, teamID uint64, members []uint64) {
}
}
func SaveTeamRepos(orgID, teamID uint64, repos []uint64) {
func SaveTeamRepos(orgID, teamID int, repos []int) {
defer measure("SaveTeamRepos", time.Now())
tx := db.MustBegin()
var ids = []string{}
for _, id := range repos {
ids = append(ids, strconv.FormatUint(id, 10))
ids = append(ids, strconv.Itoa(id))
}
tx.MustExec(fmt.Sprintf(`
delete from team_repos

View File

@ -5,7 +5,7 @@ import (
)
type Org struct {
ID uint64 `json:"id"`
ID int `json:"id"`
Login string `json:"login"`
Company string `json:"company"`
AvatarURL string `json:"avatar_url" db:"avatar_url"`

View File

@ -5,8 +5,8 @@ import (
)
type Repo struct {
ID uint64 `json:"id"`
OrgID uint64 `json:"org_id"`
ID int `json:"id"`
OrgID int `json:"org_id"`
Name string `json:"name"`
Description string `json:"description"`
IsPrivate bool `json:"is_private"`

View File

@ -5,8 +5,8 @@ import (
)
type Team struct {
ID uint64 `json:"id"`
OrgID uint64 `json:"org_id" db:"org_id"`
ID int `json:"id"`
OrgID int `json:"org_id"`
Slug string `json:"slug"`
Name string `json:"name"`
Permission string `json:"permission"`

View File

@ -5,11 +5,11 @@ import (
)
type Token struct {
ID uint64 `json:"id"`
ID int `json:"id"`
User string `json:"user"`
Token string `json:"token"`
Quota uint64 `json:"quota"`
Remaining uint64 `json:"remaining"`
Quota int `json:"quota"`
Remaining int `json:"remaining"`
ResetAt time.Time `json:"reset_at" db:"reset_at"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
}

View File

@ -5,7 +5,7 @@ import (
)
type User struct {
ID uint64 `json:"id"`
ID int `json:"id"`
Login string `json:"login"`
Name string `json:"name"`
AvatarURL string `json:"avatar_url" db:"avatar_url"`

View File

@ -25,7 +25,7 @@ func SyncRepos(token, owner string) {
descr = *repo.Description
}
r := &db.Repo{
OrgID: uint64(*repo.Organization.ID),
OrgID: *repo.Organization.ID,
Name: *repo.Name,
Description: descr,
IsPrivate: *repo.Private,
@ -59,13 +59,13 @@ func SyncContrib(token, owner string, repo *db.Repo) {
}
c := &db.Contrib{
Week: uint64(week.Week.Time.Unix()),
Week: int(week.Week.Time.Unix()),
OrgID: repo.OrgID,
RepoID: repo.ID,
UserID: uint64(*contrib.Author.ID),
Commits: uint64(*week.Commits),
Additions: uint64(*week.Additions),
Deletions: uint64(*week.Deletions),
UserID: *contrib.Author.ID,
Commits: *week.Commits,
Additions: *week.Additions,
Deletions: *week.Deletions,
}
c.Save()
}
@ -95,7 +95,7 @@ func SyncUserOrgs(token string) (err error) {
avatarURL = *org.AvatarURL
}
o := &db.Org{
ID: uint64(*org.ID),
ID: *org.ID,
Login: *org.Login,
Company: company,
AvatarURL: avatarURL,
@ -128,8 +128,8 @@ func SyncOrgTeams(token string, org *db.Org) (err error) {
for _, team := range teams {
t := &db.Team{
ID: uint64(*team.ID),
Name: *team.Name,
ID: *team.ID,
Slug: *team.Slug,
Permission: *team.Permission,
OrgID: org.ID,
@ -151,7 +151,7 @@ func SyncOrgMembers(token string, org *db.Org) (err error) {
client := newGithubClient(token)
opt := &github.ListMembersOptions{ListOptions: github.ListOptions{PerPage: 100}}
var ids = []uint64{}
var ids = []int{}
for {
opt.Page++
var users []github.User
@ -162,7 +162,7 @@ func SyncOrgMembers(token string, org *db.Org) (err error) {
saveResponseMeta(token, resp)
for _, user := range users {
ids = append(ids, uint64(*user.ID))
ids = append(ids, *user.ID)
go SyncUserInfo(token, *user.Login)
}
if opt.Page >= resp.LastPage {
@ -179,7 +179,7 @@ func SyncTeamMembers(token string, team *db.Team) (err error) {
client := newGithubClient(token)
opt := &github.ListOptions{PerPage: 100}
var ids = []uint64{}
var ids = []int{}
for {
opt.Page++
var users []github.User
@ -190,7 +190,7 @@ func SyncTeamMembers(token string, team *db.Team) (err error) {
saveResponseMeta(token, resp)
for _, user := range users {
ids = append(ids, uint64(*user.ID))
ids = append(ids, *user.ID)
}
if opt.Page >= resp.LastPage {
break
@ -206,7 +206,7 @@ func SyncTeamRepos(token string, team *db.Team) (err error) {
client := newGithubClient(token)
opt := &github.ListOptions{PerPage: 100}
var ids = []uint64{}
var ids = []int{}
for {
opt.Page++
var repos []github.Repository
@ -217,7 +217,7 @@ func SyncTeamRepos(token string, team *db.Team) (err error) {
saveResponseMeta(token, resp)
for _, repo := range repos {
ids = append(ids, uint64(*repo.ID))
ids = append(ids, *repo.ID)
}
if opt.Page >= resp.LastPage {
break

View File

@ -22,8 +22,8 @@ func saveResponseMeta(token string, res *github.Response) {
}
tok := &db.Token{
Token: token,
Quota: uint64(res.Limit),
Remaining: uint64(res.Remaining),
Quota: res.Limit,
Remaining: res.Remaining,
ResetAt: res.Reset.Time,
}
tok.Save()

View File

@ -31,7 +31,7 @@ func FetchUserInfo(token, login string) (u *db.User, err error) {
u = &db.User{
Login: *user.Login,
Name: name,
ID: uint64(*user.ID),
ID: *user.ID,
AvatarURL: avatarURL,
}