Update contrib model

This commit is contained in:
2015-03-20 18:48:42 +07:00
parent f01da56147
commit ede2707070
2 changed files with 14 additions and 15 deletions
+9 -10
View File
@@ -6,21 +6,20 @@ import (
type Contrib struct {
Week uint64 `json:"week"`
Author string `json:"author"`
Owner string `json:"owner"`
Repo string `json:"repo"`
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"`
}
const saveContribQuery = `
insert into contribs (week, author, owner, repo, commits, additions, deletions)
values (:week, :author, :owner, :repo, :commits, :additions, :deletions)
on duplicate key update
commits=values(commits), additions=values(additions), deletions=values(deletions)`
func (c *Contrib) Save() {
defer measure("SaveContrib", time.Now())
mustExecN(saveContribQuery, c)
mustExecN(`
insert into contribs (week, org_id, repo_id, user_id, commits, additions, deletions)
values (:week, :org_id, :repo_id, :user_id, :commits, :additions, :deletions)
on duplicate key update
commits=values(commits), additions=values(additions), deletions=values(deletions)
`, c)
}