empact/db/contrib.go

27 lines
688 B
Go
Raw Normal View History

2015-03-05 02:09:08 +07:00
package db
2015-03-06 20:35:13 +07:00
import (
"time"
)
2015-03-06 17:00:04 +07:00
type Contrib struct {
2015-03-06 18:18:15 +07:00
Week uint64 `json:"week"`
2015-03-06 17:00:04 +07:00
Author string `json:"author"`
Owner string `json:"owner"`
Repo string `json:"repo"`
2015-03-06 18:18:15 +07:00
Commits uint64 `json:"commits"`
Additions uint64 `json:"additions"`
Deletions uint64 `json:"deletions"`
2015-03-06 17:00:04 +07:00
}
2015-03-05 02:09:08 +07:00
2015-03-06 17:00:04 +07:00
const saveContribQuery = `
2015-03-06 23:29:26 +07:00
insert into contribs (week, author, owner, repo, commits, additions, deletions)
2015-03-06 18:29:52 +07:00
values (:week, :author, :owner, :repo, :commits, :additions, :deletions)
2015-03-06 17:00:04 +07:00
on duplicate key update
commits=values(commits), additions=values(additions), deletions=values(deletions)`
2015-03-05 02:09:08 +07:00
2015-03-05 03:51:17 +07:00
func (c *Contrib) Save() {
2015-03-06 20:35:13 +07:00
defer measure("SaveContrib", time.Now())
2015-03-06 18:29:52 +07:00
mustExecN(saveContribQuery, c)
2015-03-05 02:09:08 +07:00
}