empact/db/contrib.go

22 lines
660 B
Go
Raw Normal View History

2015-03-05 02:09:08 +07:00
package db
2015-03-06 17:00:04 +07:00
type Contrib struct {
Week int64 `json:"week"`
Author string `json:"author"`
Owner string `json:"owner"`
Repo string `json:"repo"`
Commits int64 `json:"commits"`
Additions int64 `json:"additions"`
Deletions int64 `json:"deletions"`
}
2015-03-05 02:09:08 +07:00
2015-03-06 17:00:04 +07:00
const saveContribQuery = `
insert into contributions (week, author, owner, repo, commits, additions, deletions)
values (?, ?, ?, ?, ?, ?, ?)
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 17:00:04 +07:00
conn.MustExec(saveContribQuery, c.Week, c.Author, c.Owner, c.Repo, c.Commits, c.Additions, c.Deletions)
2015-03-05 02:09:08 +07:00
}