فهرست منبع

Fixed issue with json dashboard index, json file dashboards turned up when filtering on 'is starred'

Torkel Ödegaard 10 سال پیش
والد
کامیت
5f004f95f2
2فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 4 0
      pkg/search/json_index.go
  2. 7 0
      pkg/search/json_index_test.go

+ 4 - 0
pkg/search/json_index.go

@@ -47,6 +47,10 @@ func (index *JsonDashIndex) updateLoop() {
 func (index *JsonDashIndex) Search(query *Query) ([]*Hit, error) {
 func (index *JsonDashIndex) Search(query *Query) ([]*Hit, error) {
 	results := make([]*Hit, 0)
 	results := make([]*Hit, 0)
 
 
+	if query.IsStarred {
+		return results, nil
+	}
+
 	for _, item := range index.items {
 	for _, item := range index.items {
 		if len(results) > query.Limit {
 		if len(results) > query.Limit {
 			break
 			break

+ 7 - 0
pkg/search/json_index_test.go

@@ -31,5 +31,12 @@ func TestJsonDashIndex(t *testing.T) {
 			So(res[0].Title, ShouldEqual, "Home")
 			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)
+		})
+
 	})
 	})
 }
 }