From 31ccb1c18176665b35fbfc09a136ffa00dac556f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Tue, 11 Sep 2018 15:19:08 +0200 Subject: [PATCH] Improvements to the list output --- internal/database/actions.go | 2 ++ internal/database/models.go | 5 ++++- internal/output/output.go | 15 ++++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/internal/database/actions.go b/internal/database/actions.go index 2fe12c6..88334b5 100644 --- a/internal/database/actions.go +++ b/internal/database/actions.go @@ -118,6 +118,8 @@ func CreateMeasurement(sess sqlbuilder.Database, reportID sql.NullString, testNa ResultID: resultID, ReportFilePath: reportFilePath, URLID: urlID, + IsFailed: false, + IsDone: false, // XXX Do we want to have this be part of something else? StartTime: time.Now().UTC(), TestKeys: "", diff --git a/internal/database/models.go b/internal/database/models.go index 60c510b..6d188aa 100644 --- a/internal/database/models.go +++ b/internal/database/models.go @@ -25,6 +25,8 @@ type MeasurementURLNetwork struct { MsmtTblID int64 `db:"msmt_tbl_id"` Network `db:",inline"` NetworkID int64 `db:"network_id"` + Result `db:",inline"` + ResultID int64 `db:"result_id"` URL `db:",inline"` } @@ -54,7 +56,7 @@ type Measurement struct { Runtime float64 `db:"runtime"` // Fractional number of seconds IsDone bool `db:"is_done"` IsUploaded bool `db:"is_uploaded"` - IsFailed string `db:"is_failed"` + IsFailed bool `db:"is_failed"` FailureMsg sql.NullString `db:"failure_msg,omitempty"` IsUploadFailed bool `db:"is_upload_failed"` UploadFailureMsg sql.NullString `db:"upload_failure_msg,omitempty"` @@ -101,6 +103,7 @@ func (r *Result) Finished(sess sqlbuilder.Database) error { // Failed writes the error string to the measurement func (m *Measurement) Failed(sess sqlbuilder.Database, failure string) error { m.FailureMsg = sql.NullString{String: failure, Valid: true} + m.IsFailed = true err := sess.Collection("measurements").Find("id", m.ID).Update(m) if err != nil { return errors.Wrap(err, "updating measurement") diff --git a/internal/output/output.go b/internal/output/output.go index 0e6a214..2c92698 100644 --- a/internal/output/output.go +++ b/internal/output/output.go @@ -26,22 +26,23 @@ func MeasurementItem(msmt database.MeasurementURLNetwork) { "type": "measurement_item", "id": msmt.MsmtTblID, "test_name": msmt.TestName, - "start_time": msmt.StartTime, + "test_group_name": msmt.Result.TestGroupName, + "start_time": msmt.Measurement.StartTime, "test_keys": msmt.TestKeys, "probe_cc": msmt.Network.CountryCode, "network_name": msmt.Network.NetworkName, "asn": msmt.Network.ASN, - "runtime": msmt.Runtime, - "url": msmt.URL.URL, - "url_category_code": msmt.URL.CategoryCode, - "url_country_code": msmt.URL.CountryCode, - "is_anomaly": msmt.IsAnomaly, + "runtime": msmt.Measurement.Runtime, + "url": msmt.URL.URL.String, + "url_category_code": msmt.URL.CategoryCode.String, + "url_country_code": msmt.URL.CountryCode.String, + "is_anomaly": msmt.IsAnomaly.Bool, "is_uploaded": msmt.IsUploaded, "is_upload_failed": msmt.IsUploadFailed, "upload_failure_msg": msmt.UploadFailureMsg.String, "is_failed": msmt.IsFailed, "failure_msg": msmt.FailureMsg.String, - "is_done": msmt.IsDone, + "is_done": msmt.Measurement.IsDone, "report_file_path": msmt.ReportFilePath, }).Info("measurement") }