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