Task reports

This commit is contained in:
2015-03-05 03:51:17 +07:00
parent 8ac16bb695
commit ed666552ef
8 changed files with 80 additions and 86 deletions
+3 -3
View File
@@ -17,13 +17,13 @@ type (
)
const (
importContribQuery = "" +
saveContribQuery = "" +
"replace into contributions (week, author, owner, repo, commits, additions, deletions) " +
"values (?, ?, ?, ?, ?, ?, ?)"
)
func ImportContrib(c *Contrib) {
if _, err := stmt(importContribQuery).Exec(structs.Values(c)); err != nil {
func (c *Contrib) Save() {
if _, err := stmt(saveContribQuery).Exec(structs.Values(c)); err != nil {
panic(err)
}
}
+3 -3
View File
@@ -12,11 +12,11 @@ type (
)
const (
repoImportQuery = "replace into repos (owner, name, updated_at) values (?, ?, now())"
saveRepoQuery = "replace into repos (owner, name, updated_at) values (?, ?, now())"
)
func ImportRepo(r *Repo) {
if _, err := stmt(repoImportQuery).Exec(structs.Values(r)); err != nil {
func (r *Repo) Save() {
if _, err := stmt(saveRepoQuery).Exec(structs.Values(r)); err != nil {
panic(err)
}
}
+32
View File
@@ -0,0 +1,32 @@
package db
import (
"time"
"github.com/fatih/structs"
)
type (
Task struct {
Token string
Owner string
Job string
Worker string
Duration int64
Error string
CreatedAt time.Time
StartedAt time.Time
}
)
const (
saveTaskQuery = "" +
"insert into tasks (token, owner, job, worker, duration, error, created_at, started_at) " +
"values (?, ?, ?, ?, ?, ?, ?, ?)"
)
func (t *Task) Save() {
if _, err := stmt(saveTaskQuery).Exec(structs.Values(t)); err != nil {
panic(err)
}
}