Task reports
This commit is contained in:
+3
-3
@@ -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
@@ -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
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user