From 4880d31120492c01041617034208b2cfbd31e852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Wed, 12 Sep 2018 13:48:18 +0200 Subject: [PATCH] Fix data usage count --- Gopkg.lock | 2 +- nettests/nettests.go | 21 ++++----------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 2d6eb69..c9e1d9b 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -68,7 +68,7 @@ branch = "master" name = "github.com/measurement-kit/go-measurement-kit" packages = ["."] - revision = "33cbd62d4a73b68af069f70a797c2250332c059a" + revision = "4b5013c619f6f0293fd67b6892a7f90066d3c18d" [[projects]] branch = "master" diff --git a/nettests/nettests.go b/nettests/nettests.go index 1f5cd58..89ec036 100644 --- a/nettests/nettests.go +++ b/nettests/nettests.go @@ -63,12 +63,6 @@ func (c *Controller) SetInputIdxMap(inputIdxMap map[int64]int64) error { 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 func (c *Controller) Init(nt *mk.Nettest) error { log.Debugf("Init: %v", nt) @@ -287,19 +281,12 @@ func (c *Controller) Init(nt *mk.Nettest) error { } } - var endMsg StatusEnd - err := json.Unmarshal([]byte(e.Value.JSONStr), &endMsg) - if err != nil { - log.WithError(err).Errorf("failed to extract status.end message %s", e.Value.JSONStr) - return + if e.Value.Failure != "" { + log.Errorf("Failure in status.end: %s", e.Value.Failure) } - if endMsg.Failure != "" { - log.Errorf("Failure in status.end: %s", endMsg.Failure) - } - - c.res.DataUsageDown += endMsg.DownloadedKB - c.res.DataUsageDown += endMsg.UploadedKB + c.res.DataUsageDown += e.Value.DownloadedKB + c.res.DataUsageDown += e.Value.UploadedKB }) log.Debugf("Registered all the handlers")