implement db update
This commit is contained in:
parent
7151f4270f
commit
7e9a4fc3b7
|
@ -31,7 +31,7 @@ func init() {
|
|||
StartTime: time.Now().UTC(), // XXX get this from MK
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("%s", err)
|
||||
log.Errorf("DB result error: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -73,14 +73,22 @@ type Result struct {
|
|||
|
||||
// Update the Result in the database
|
||||
func (r Result) Update(db *sqlx.DB) error {
|
||||
// XXX implement me
|
||||
log.Debugf("Updating result %v", r)
|
||||
_, err := db.NamedExec(`UPDATE results SET
|
||||
(name, start_time, end_time, summary, done, data_usage_up, data_usage_down) =
|
||||
(:name, :start_time, :end_time, :summary, :done, :data_usage_up, :data_usage_down)
|
||||
WHERE id = :id`, r)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "updating result")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateResult writes the Result to the database a returns a pointer
|
||||
// to the Result
|
||||
func CreateResult(db *sqlx.DB, r Result) (*Result, error) {
|
||||
log.Debugf("Creating result %s", r)
|
||||
log.Debugf("Creating result %v", r)
|
||||
res, err := db.NamedExec(`INSERT INTO results
|
||||
(name, start_time)
|
||||
VALUES (:name,:start_time)`,
|
||||
|
|
|
@ -38,7 +38,7 @@ type Controller struct {
|
|||
|
||||
// Init should be called once to initialise the nettest
|
||||
func (c *Controller) Init(nt *mk.Nettest) {
|
||||
log.Debugf("Init: %s", nt)
|
||||
log.Debugf("Init: %v", nt)
|
||||
nt.Options = mk.NettestOptions{
|
||||
IncludeIP: c.ctx.Config.Sharing.IncludeIP,
|
||||
IncludeASN: c.ctx.Config.Sharing.IncludeASN,
|
||||
|
|
Loading…
Reference in New Issue
Block a user