refactor getFindDashboardsFn

This commit is contained in:
Alexander Zobnin
2024-09-09 11:49:02 +02:00
parent 341be2b3ae
commit 467b92bc96
+7 -3
View File
@@ -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) {