From 444288cb6f62b14eaec5f1859a08b07069646960 Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Sun, 5 Oct 2014 21:29:26 +0200 Subject: [PATCH] Choose a metric with high resolution as 'base' metric This way if we discover the metrics have different resolutions, we'll return the one containing (hopefully) the most information. Note that we still might have 'more' information (in terms of non-None data points) if we chose a different metric instead. Future work, I guess. Updates issue #4. --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index 38946d7..4b81536 100644 --- a/main.go +++ b/main.go @@ -390,6 +390,15 @@ func handleRenderPB(w http.ResponseWriter, req *http.Request, format string, res return } + // Use the metric with the highest resolution as our base + var highest int + for i, d := range decoded { + if d.GetStepTime() < decoded[highest].GetStepTime() { + highest = i + } + } + decoded[0], decoded[highest] = decoded[highest], decoded[0] + metric := decoded[0] mergeValues(req, &metric, decoded)