From 67a691dfe0803487526a47613ac10e9096030387 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Thu, 23 Mar 2017 12:02:57 -0500 Subject: [PATCH] use id instead of key in topN results --- cache.go | 2 +- handler_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cache.go b/cache.go index 0185ce260..6a0fb3447 100644 --- a/cache.go +++ b/cache.go @@ -258,7 +258,7 @@ func (p BitmapPairs) Len() int { return len(p) } func (p BitmapPairs) Less(i, j int) bool { return p[i].Count > p[j].Count } type Pair struct { - Key uint64 `json:"key"` + Key uint64 `json:"id"` Count uint64 `json:"count"` } diff --git a/handler_test.go b/handler_test.go index 099d85074..8191e2d3f 100644 --- a/handler_test.go +++ b/handler_test.go @@ -354,7 +354,7 @@ func TestHandler_Query_Pairs_JSON(t *testing.T) { h.ServeHTTP(w, MustNewHTTPRequest("POST", "/query", strings.NewReader(`TopN(frame=x, n=2)`))) if w.Code != http.StatusOK { t.Fatalf("unexpected status code: %d", w.Code) - } else if body := w.Body.String(); body != `{"results":[[{"key":1,"count":2},{"key":3,"count":4}]]}`+"\n" { + } else if body := w.Body.String(); body != `{"results":[[{"id":1,"count":2},{"id":3,"count":4}]]}`+"\n" { t.Fatalf("unexpected body: %q", body) } }