diff --git a/internal/cli/list/list.go b/internal/cli/list/list.go index 66be3e4..c2f1e74 100644 --- a/internal/cli/list/list.go +++ b/internal/cli/list/list.go @@ -41,7 +41,6 @@ func init() { output.SectionTitle("Incomplete results") } for idx, result := range incompleteResults { - output.ResultItem(output.ResultItemData{ ID: result.Result.ID, Index: idx, @@ -68,6 +67,10 @@ func init() { if err != nil { log.WithError(err).Error("failed to list measurement counts") } + testKeys, err := database.GetResultTestKeys(ctx.DB, result.Result.ID) + if err != nil { + log.WithError(err).Error("failed to get testKeys") + } output.ResultItem(output.ResultItemData{ ID: result.Result.ID, Index: idx, @@ -77,7 +80,7 @@ func init() { NetworkName: result.Network.NetworkName, Country: result.Network.CountryCode, ASN: fmt.Sprintf("AS%d", result.Network.ASN), - TestKeys: "{}", // FIXME this used to be Summary we probably need to use a list now + TestKeys: testKeys, MeasurementCount: totalCount, MeasurementAnomalyCount: anmlyCount, Done: result.IsDone, diff --git a/internal/database/actions.go b/internal/database/actions.go index f17229d..a002663 100644 --- a/internal/database/actions.go +++ b/internal/database/actions.go @@ -37,6 +37,24 @@ func ListMeasurements(sess sqlbuilder.Database, resultID int64) ([]MeasurementUR return measurements, nil } +// GetResultTestKeys returns a list of TestKeys for a given measurements +func GetResultTestKeys(sess sqlbuilder.Database, resultID int64) (string, error) { + res := sess.Collection("measurements").Find("result_id", resultID) + defer res.Close() + + var msmt Measurement + for res.Next(&msmt) { + if msmt.TestName == "web_connectivity" { + break + } + // We only really care about the NDT TestKeys + if msmt.TestName == "ndt" { + return msmt.TestKeys, nil + } + } + return "{}", nil +} + // GetMeasurementCounts returns the number of anomalous and total measurement for a given result func GetMeasurementCounts(sess sqlbuilder.Database, resultID int64) (uint64, uint64, error) { var (