1
0
Fork 0
empact/db/contrib.go

28 lines
700 B
Go
Raw Permalink Normal View History

2015-03-04 19:09:08 +00:00
package db
2015-03-06 13:35:13 +00:00
import (
"time"
)
2015-03-06 10:00:04 +00:00
type Contrib struct {
2015-03-20 15:22:49 +00:00
Week int `json:"week"`
2015-03-21 14:12:09 +00:00
OrgID int `json:"org_id" db:"org_id"`
RepoID int `json:"repo_id" db:"repo_id"`
UserID int `json:"user_id" db:"user_id"`
2015-03-20 15:22:49 +00:00
Commits int `json:"commits"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
2015-03-06 10:00:04 +00:00
}
2015-03-04 19:09:08 +00:00
2015-03-04 20:51:17 +00:00
func (c *Contrib) Save() {
2015-03-21 14:58:40 +00:00
defer measure(time.Now(), "SaveContrib")
2015-03-20 11:48:42 +00:00
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
2015-03-20 14:18:20 +00:00
commits = values(commits),
additions = values(additions),
deletions = values(deletions)
2015-03-20 11:48:42 +00:00
`, c)
2015-03-04 19:09:08 +00:00
}