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-06 11:18:15 +00:00
|
|
|
Week uint64 `json:"week"`
|
2015-03-06 10:00:04 +00:00
|
|
|
Author string `json:"author"`
|
|
|
|
Owner string `json:"owner"`
|
|
|
|
Repo string `json:"repo"`
|
2015-03-06 11:18:15 +00:00
|
|
|
Commits uint64 `json:"commits"`
|
|
|
|
Additions uint64 `json:"additions"`
|
|
|
|
Deletions uint64 `json:"deletions"`
|
2015-03-06 10:00:04 +00:00
|
|
|
}
|
2015-03-04 19:09:08 +00:00
|
|
|
|
2015-03-06 10:00:04 +00:00
|
|
|
const saveContribQuery = `
|
2015-03-06 16:29:26 +00:00
|
|
|
insert into contribs (week, author, owner, repo, commits, additions, deletions)
|
2015-03-06 11:29:52 +00:00
|
|
|
values (:week, :author, :owner, :repo, :commits, :additions, :deletions)
|
2015-03-06 10:00:04 +00:00
|
|
|
on duplicate key update
|
|
|
|
commits=values(commits), additions=values(additions), deletions=values(deletions)`
|
2015-03-04 19:09:08 +00:00
|
|
|
|
2015-03-04 20:51:17 +00:00
|
|
|
func (c *Contrib) Save() {
|
2015-03-06 13:35:13 +00:00
|
|
|
defer measure("SaveContrib", time.Now())
|
2015-03-06 11:29:52 +00:00
|
|
|
mustExecN(saveContribQuery, c)
|
2015-03-04 19:09:08 +00:00
|
|
|
}
|