Revert "Search: Fix only searching for folder id zero (#44175)" (#44424)

This reverts commit 007cd144a9 from #44175.
This commit is contained in:
Marcus Efraimsson 2022-01-25 15:04:26 +01:00 committed by GitHub
parent cb09162cde
commit 62b69a0b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 26 deletions

View File

@ -305,7 +305,7 @@ func (ss *SQLStore) findDashboards(ctx context.Context, query *search.FindPersis
}
if len(query.FolderIds) > 0 {
filters = append(filters, searchstore.FolderFilter{Dialect: dialect, IDs: query.FolderIds})
filters = append(filters, searchstore.FolderFilter{IDs: query.FolderIds})
}
var res []DashboardSearchProjection

View File

@ -384,24 +384,6 @@ func TestDashboardDataAccess(t *testing.T) {
require.Equal(t, hit.FolderURL, fmt.Sprintf("/dashboards/f/%s/%s", savedFolder.Uid, savedFolder.Slug))
})
t.Run("Should be able to search for general folder's children", func(t *testing.T) {
setup()
query := search.FindPersistedDashboardsQuery{
OrgId: 1,
FolderIds: []int64{0},
SignedInUser: &models.SignedInUser{OrgId: 1, OrgRole: models.ROLE_EDITOR},
}
err := sqlStore.SearchDashboards(context.Background(), &query)
require.NoError(t, err)
require.Equal(t, len(query.Result), 1)
hit := query.Result[0]
require.Equal(t, savedDash2.Id, hit.ID)
require.Equal(t, fmt.Sprintf("/d/%s/%s", savedDash2.Uid, savedDash2.Slug), hit.URL)
require.Equal(t, int64(0), hit.FolderID)
})
t.Run("Should be able to search for dashboard by dashboard ids", func(t *testing.T) {
setup()
query := search.FindPersistedDashboardsQuery{

View File

@ -87,16 +87,10 @@ func (f TitleFilter) Where() (string, []interface{}) {
}
type FolderFilter struct {
Dialect migrator.Dialect
IDs []int64
IDs []int64
}
func (f FolderFilter) Where() (string, []interface{}) {
if len(f.IDs) == 1 && f.IDs[0] == 0 {
sql := fmt.Sprintf("dashboard.folder_id = 0 AND dashboard.is_folder = %s", f.Dialect.BooleanStr(false))
return sql, []interface{}{}
}
return sqlIDin("dashboard.folder_id", f.IDs)
}