From 5f004f95f2bdee98eef3ae70e769ca6e81402b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 May 2015 15:42:59 +0200 Subject: [PATCH] Fixed issue with json dashboard index, json file dashboards turned up when filtering on 'is starred' --- pkg/search/json_index.go | 4 ++++ pkg/search/json_index_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/pkg/search/json_index.go b/pkg/search/json_index.go index 0b4c335e703..edf791562c9 100644 --- a/pkg/search/json_index.go +++ b/pkg/search/json_index.go @@ -47,6 +47,10 @@ func (index *JsonDashIndex) updateLoop() { func (index *JsonDashIndex) Search(query *Query) ([]*Hit, error) { results := make([]*Hit, 0) + if query.IsStarred { + return results, nil + } + for _, item := range index.items { if len(results) > query.Limit { break diff --git a/pkg/search/json_index_test.go b/pkg/search/json_index_test.go index 38fbf7207d9..52741cc6806 100644 --- a/pkg/search/json_index_test.go +++ b/pkg/search/json_index_test.go @@ -31,5 +31,12 @@ func TestJsonDashIndex(t *testing.T) { So(res[0].Title, ShouldEqual, "Home") }) + Convey("Should not return when starred is filtered", func() { + res, err := index.Search(&Query{Title: "", Tag: "", IsStarred: true}) + So(err, ShouldBeNil) + + So(len(res), ShouldEqual, 0) + }) + }) }