From 467b92bc9657b887a3555bceed7ad9717a047748 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 9 Sep 2024 11:49:02 +0200 Subject: [PATCH] refactor getFindDashboardsFn --- pkg/services/dashboards/service/zanzana.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/services/dashboards/service/zanzana.go b/pkg/services/dashboards/service/zanzana.go index 347352687aa..2b86cb29161 100644 --- a/pkg/services/dashboards/service/zanzana.go +++ b/pkg/services/dashboards/service/zanzana.go @@ -15,6 +15,10 @@ import ( "github.com/grafana/grafana/pkg/services/dashboards" ) +const ( + maxListQueryLength = 8 +) + type searchResult struct { runner string result []dashboards.DashboardSearchProjection @@ -91,10 +95,10 @@ type findDashboardsFn func(ctx context.Context, query *dashboards.FindPersistedD // getFindDashboardsFn makes a decision which search method should be used func (dr *DashboardServiceImpl) getFindDashboardsFn(query *dashboards.FindPersistedDashboardsQuery) findDashboardsFn { - if len(query.Title) > 8 { - return dr.findDashboardsZanzanaCheck + if len(query.Title) <= maxListQueryLength { + return dr.findDashboardsZanzanaList } - return dr.findDashboardsZanzanaList + return dr.findDashboardsZanzanaCheck } func (dr *DashboardServiceImpl) findDashboardsZanzanaList(ctx context.Context, query *dashboards.FindPersistedDashboardsQuery) ([]dashboards.DashboardSearchProjection, error) {