Resolve country code ambigious selection
This commit is contained in:
parent
d02ed117f9
commit
0ee0c28129
|
@ -1,8 +1,6 @@
|
||||||
package list
|
package list
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin"
|
"github.com/alecthomas/kingpin"
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/ooni/probe-cli/internal/cli/root"
|
"github.com/ooni/probe-cli/internal/cli/root"
|
||||||
|
@ -71,7 +69,7 @@ func init() {
|
||||||
StartTime: result.StartTime,
|
StartTime: result.StartTime,
|
||||||
NetworkName: result.Network.NetworkName,
|
NetworkName: result.Network.NetworkName,
|
||||||
Country: result.Network.CountryCode,
|
Country: result.Network.CountryCode,
|
||||||
ASN: fmt.Sprintf("AS%d", result.Network.ASN),
|
ASN: result.Network.ASN,
|
||||||
MeasurementCount: 0,
|
MeasurementCount: 0,
|
||||||
MeasurementAnomalyCount: 0,
|
MeasurementAnomalyCount: 0,
|
||||||
TestKeys: "{}", // FIXME this used to be Summary we probably need to use a list now
|
TestKeys: "{}", // FIXME this used to be Summary we probably need to use a list now
|
||||||
|
@ -101,7 +99,7 @@ func init() {
|
||||||
StartTime: result.StartTime,
|
StartTime: result.StartTime,
|
||||||
NetworkName: result.Network.NetworkName,
|
NetworkName: result.Network.NetworkName,
|
||||||
Country: result.Network.CountryCode,
|
Country: result.Network.CountryCode,
|
||||||
ASN: fmt.Sprintf("AS%d", result.Network.ASN),
|
ASN: result.Network.ASN,
|
||||||
TestKeys: testKeys,
|
TestKeys: testKeys,
|
||||||
MeasurementCount: totalCount,
|
MeasurementCount: totalCount,
|
||||||
MeasurementAnomalyCount: anmlyCount,
|
MeasurementAnomalyCount: anmlyCount,
|
||||||
|
|
|
@ -23,12 +23,14 @@ func ListMeasurements(sess sqlbuilder.Database, resultID int64) ([]MeasurementUR
|
||||||
"measurements.start_time as measurement_start_time",
|
"measurements.start_time as measurement_start_time",
|
||||||
"measurements.runtime as measurement_runtime",
|
"measurements.runtime as measurement_runtime",
|
||||||
"networks.id as network_id",
|
"networks.id as network_id",
|
||||||
|
"networks.country_code as network_country_code",
|
||||||
"results.id as result_id",
|
"results.id as result_id",
|
||||||
"results.start_time as result_start_time",
|
"results.start_time as result_start_time",
|
||||||
"results.is_done as result_is_done",
|
"results.is_done as result_is_done",
|
||||||
"results.runtime as result_runtime",
|
"results.runtime as result_runtime",
|
||||||
"results.test_group_name as test_group_name",
|
"results.test_group_name as test_group_name",
|
||||||
"urls.id as url_id",
|
"urls.id as url_id",
|
||||||
|
"urls.country_code as url_country_code",
|
||||||
db.Raw("networks.*"),
|
db.Raw("networks.*"),
|
||||||
db.Raw("urls.*"),
|
db.Raw("urls.*"),
|
||||||
db.Raw("measurements.*"),
|
db.Raw("measurements.*"),
|
||||||
|
|
|
@ -26,14 +26,19 @@ type MeasurementURLNetwork struct {
|
||||||
MeasurementIsDone bool `db:"measurement_is_done"`
|
MeasurementIsDone bool `db:"measurement_is_done"`
|
||||||
MeasurementRuntime float64 `db:"measurement_runtime"`
|
MeasurementRuntime float64 `db:"measurement_runtime"`
|
||||||
MsmtTblID int64 `db:"msmt_tbl_id"`
|
MsmtTblID int64 `db:"msmt_tbl_id"`
|
||||||
Network `db:",inline"`
|
|
||||||
NetworkID int64 `db:"network_id"`
|
Network `db:",inline"`
|
||||||
Result `db:",inline"`
|
NetworkID int64 `db:"network_id"`
|
||||||
ResultID int64 `db:"result_id"`
|
NetworkCountryCode string `db:"network_country_code"`
|
||||||
ResultRuntime float64 `db:"result_runtime"`
|
|
||||||
ResultStartTime time.Time `db:"result_start_time"`
|
Result `db:",inline"`
|
||||||
ResultIsDone bool `db:"result_is_done"`
|
ResultID int64 `db:"result_id"`
|
||||||
URL `db:",inline"`
|
ResultRuntime float64 `db:"result_runtime"`
|
||||||
|
ResultStartTime time.Time `db:"result_start_time"`
|
||||||
|
ResultIsDone bool `db:"result_is_done"`
|
||||||
|
|
||||||
|
URL `db:",inline"`
|
||||||
|
URLCountryCode sql.NullString `db:"url_country_code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network represents a network tested by the user
|
// Network represents a network tested by the user
|
||||||
|
|
|
@ -77,7 +77,7 @@ func logResultItem(w io.Writer, f log.Fields) error {
|
||||||
name := f.Get("name").(string)
|
name := f.Get("name").(string)
|
||||||
startTime := f.Get("start_time").(time.Time)
|
startTime := f.Get("start_time").(time.Time)
|
||||||
networkName := f.Get("network_name").(string)
|
networkName := f.Get("network_name").(string)
|
||||||
asn := fmt.Sprintf("AS %s", f.Get("asn").(string))
|
asn := fmt.Sprintf("AS%d (%s)", f.Get("asn").(uint), f.Get("country").(string))
|
||||||
//runtime := f.Get("runtime").(float64)
|
//runtime := f.Get("runtime").(float64)
|
||||||
//dataUsageUp := f.Get("dataUsageUp").(int64)
|
//dataUsageUp := f.Get("dataUsageUp").(int64)
|
||||||
//dataUsageDown := f.Get("dataUsageDown").(int64)
|
//dataUsageDown := f.Get("dataUsageDown").(int64)
|
||||||
|
|
|
@ -42,27 +42,27 @@ func MeasurementSummary(msmt MeasurementSummaryData) {
|
||||||
// MeasurementItem logs a progress type event
|
// MeasurementItem logs a progress type event
|
||||||
func MeasurementItem(msmt database.MeasurementURLNetwork) {
|
func MeasurementItem(msmt database.MeasurementURLNetwork) {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"type": "measurement_item",
|
"type": "measurement_item",
|
||||||
"id": msmt.MsmtTblID,
|
"id": msmt.MsmtTblID,
|
||||||
"test_name": msmt.TestName,
|
"test_name": msmt.TestName,
|
||||||
"test_group_name": msmt.Result.TestGroupName,
|
"test_group_name": msmt.Result.TestGroupName,
|
||||||
"start_time": msmt.MeasurementStartTime,
|
"start_time": msmt.MeasurementStartTime,
|
||||||
"test_keys": msmt.TestKeys,
|
"test_keys": msmt.TestKeys,
|
||||||
"probe_cc": msmt.Network.CountryCode,
|
"network_country_code": msmt.NetworkCountryCode,
|
||||||
"network_name": msmt.Network.NetworkName,
|
"network_name": msmt.Network.NetworkName,
|
||||||
"asn": msmt.Network.ASN,
|
"asn": msmt.Network.ASN,
|
||||||
"runtime": msmt.MeasurementRuntime,
|
"runtime": msmt.MeasurementRuntime,
|
||||||
"url": msmt.URL.URL.String,
|
"url": msmt.URL.URL.String,
|
||||||
"url_category_code": msmt.URL.CategoryCode.String,
|
"url_category_code": msmt.URL.CategoryCode.String,
|
||||||
"url_country_code": msmt.URL.CountryCode.String,
|
"url_country_code": msmt.URLCountryCode.String,
|
||||||
"is_anomaly": msmt.IsAnomaly.Bool,
|
"is_anomaly": msmt.IsAnomaly.Bool,
|
||||||
"is_uploaded": msmt.IsUploaded,
|
"is_uploaded": msmt.IsUploaded,
|
||||||
"is_upload_failed": msmt.IsUploadFailed,
|
"is_upload_failed": msmt.IsUploadFailed,
|
||||||
"upload_failure_msg": msmt.UploadFailureMsg.String,
|
"upload_failure_msg": msmt.UploadFailureMsg.String,
|
||||||
"is_failed": msmt.IsFailed,
|
"is_failed": msmt.IsFailed,
|
||||||
"failure_msg": msmt.FailureMsg.String,
|
"failure_msg": msmt.FailureMsg.String,
|
||||||
"is_done": msmt.MeasurementIsDone,
|
"is_done": msmt.MeasurementIsDone,
|
||||||
"report_file_path": msmt.ReportFilePath,
|
"report_file_path": msmt.ReportFilePath,
|
||||||
}).Info("measurement")
|
}).Info("measurement")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ type ResultItemData struct {
|
||||||
Runtime float64
|
Runtime float64
|
||||||
Country string
|
Country string
|
||||||
NetworkName string
|
NetworkName string
|
||||||
ASN string
|
ASN uint
|
||||||
Done bool
|
Done bool
|
||||||
DataUsageDown int64
|
DataUsageDown int64
|
||||||
DataUsageUp int64
|
DataUsageUp int64
|
||||||
|
@ -95,7 +95,7 @@ func ResultItem(result ResultItemData) {
|
||||||
"test_keys": result.TestKeys,
|
"test_keys": result.TestKeys,
|
||||||
"measurement_count": result.MeasurementCount,
|
"measurement_count": result.MeasurementCount,
|
||||||
"measurement_anomaly_count": result.MeasurementAnomalyCount,
|
"measurement_anomaly_count": result.MeasurementAnomalyCount,
|
||||||
"country": result.Country,
|
"network_country_code": result.Country,
|
||||||
"network_name": result.NetworkName,
|
"network_name": result.NetworkName,
|
||||||
"asn": result.ASN,
|
"asn": result.ASN,
|
||||||
"runtime": result.Runtime,
|
"runtime": result.Runtime,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user