Fix data usage count

This commit is contained in:
Arturo Filastò 2018-09-12 13:48:18 +02:00
parent 54af7170d4
commit 4880d31120
2 changed files with 5 additions and 18 deletions

2
Gopkg.lock generated
View File

@ -68,7 +68,7 @@
branch = "master" branch = "master"
name = "github.com/measurement-kit/go-measurement-kit" name = "github.com/measurement-kit/go-measurement-kit"
packages = ["."] packages = ["."]
revision = "33cbd62d4a73b68af069f70a797c2250332c059a" revision = "4b5013c619f6f0293fd67b6892a7f90066d3c18d"
[[projects]] [[projects]]
branch = "master" branch = "master"

View File

@ -63,12 +63,6 @@ func (c *Controller) SetInputIdxMap(inputIdxMap map[int64]int64) error {
return nil return nil
} }
type StatusEnd struct {
DownloadedKB float64 `json:"download_kb"`
UploadedKB float64 `json:"uploaded_kb"`
Failure string `json:"failure"`
}
// Init should be called once to initialise the nettest // Init should be called once to initialise the nettest
func (c *Controller) Init(nt *mk.Nettest) error { func (c *Controller) Init(nt *mk.Nettest) error {
log.Debugf("Init: %v", nt) log.Debugf("Init: %v", nt)
@ -287,19 +281,12 @@ func (c *Controller) Init(nt *mk.Nettest) error {
} }
} }
var endMsg StatusEnd if e.Value.Failure != "" {
err := json.Unmarshal([]byte(e.Value.JSONStr), &endMsg) log.Errorf("Failure in status.end: %s", e.Value.Failure)
if err != nil {
log.WithError(err).Errorf("failed to extract status.end message %s", e.Value.JSONStr)
return
} }
if endMsg.Failure != "" { c.res.DataUsageDown += e.Value.DownloadedKB
log.Errorf("Failure in status.end: %s", endMsg.Failure) c.res.DataUsageDown += e.Value.UploadedKB
}
c.res.DataUsageDown += endMsg.DownloadedKB
c.res.DataUsageDown += endMsg.UploadedKB
}) })
log.Debugf("Registered all the handlers") log.Debugf("Registered all the handlers")