diff --git a/internal/cli/run/run.go b/internal/cli/run/run.go index 1fe3b1f..5013c0b 100644 --- a/internal/cli/run/run.go +++ b/internal/cli/run/run.go @@ -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 } diff --git a/internal/database/models.go b/internal/database/models.go index c0a2787..28888cc 100644 --- a/internal/database/models.go +++ b/internal/database/models.go @@ -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)`, diff --git a/nettests/nettests.go b/nettests/nettests.go index 0d7e208..2793728 100644 --- a/nettests/nettests.go +++ b/nettests/nettests.go @@ -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,