From 71dd335bf8c920f3f74bb80166b2418d5907cb1c Mon Sep 17 00:00:00 2001 From: Kat Yang <69819079+yangkb09@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:51:54 -0500 Subject: [PATCH] Chore: Deprecate FolderID in Hit (#77623) * Chore: Deprecate FolderID in Hit * chore: regen specs * chore: remove accidental deprecation comment --- .../dashboards/database/database_test.go | 4 ++- .../dashboards/service/dashboard_service.go | 2 +- pkg/services/search/model/model.go | 31 ++++++++++--------- public/api-merged.json | 1 + public/openapi3.json | 1 + 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/pkg/services/dashboards/database/database_test.go b/pkg/services/dashboards/database/database_test.go index 7a969d347d9..b2f8deb6112 100644 --- a/pkg/services/dashboards/database/database_test.go +++ b/pkg/services/dashboards/database/database_test.go @@ -452,6 +452,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) { hit := hits[0] require.Equal(t, hit.ID, savedDash.ID) require.Equal(t, hit.URL, fmt.Sprintf("/d/%s/%s", savedDash.UID, savedDash.Slug)) + // nolint:staticcheck require.Equal(t, hit.FolderID, savedFolder.ID) require.Equal(t, hit.FolderUID, savedFolder.UID) require.Equal(t, hit.FolderTitle, savedFolder.Title) @@ -479,6 +480,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) { hit := hits[0] require.Equal(t, hit.ID, savedDash.ID) require.Equal(t, hit.URL, fmt.Sprintf("/d/%s/%s", savedDash.UID, savedDash.Slug)) + // nolint:staticcheck require.Equal(t, hit.FolderID, savedFolder.ID) require.Equal(t, hit.FolderUID, savedFolder.UID) require.Equal(t, hit.FolderTitle, savedFolder.Title) @@ -1231,7 +1233,7 @@ func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashb URI: "db/" + item.Slug, URL: dashboards.GetDashboardFolderURL(item.IsFolder, item.UID, item.Slug), Type: hitType, - FolderID: item.FolderID, + FolderID: item.FolderID, // nolint:staticcheck FolderUID: item.FolderUID, FolderTitle: item.FolderTitle, Tags: []string{}, diff --git a/pkg/services/dashboards/service/dashboard_service.go b/pkg/services/dashboards/service/dashboard_service.go index 6175599b0dd..7c817c91370 100644 --- a/pkg/services/dashboards/service/dashboard_service.go +++ b/pkg/services/dashboards/service/dashboard_service.go @@ -558,7 +558,7 @@ func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashb URI: "db/" + item.Slug, URL: dashboards.GetDashboardFolderURL(item.IsFolder, item.UID, item.Slug), Type: getHitType(item), - FolderID: item.FolderID, + FolderID: item.FolderID, // nolint:staticcheck FolderUID: item.FolderUID, FolderTitle: item.FolderTitle, Tags: []string{}, diff --git a/pkg/services/search/model/model.go b/pkg/services/search/model/model.go index 619af0c6531..1d87154dee0 100644 --- a/pkg/services/search/model/model.go +++ b/pkg/services/search/model/model.go @@ -62,21 +62,22 @@ const ( ) type Hit struct { - ID int64 `json:"id"` - UID string `json:"uid"` - Title string `json:"title"` - URI string `json:"uri"` - URL string `json:"url"` - Slug string `json:"slug"` - Type HitType `json:"type"` - Tags []string `json:"tags"` - IsStarred bool `json:"isStarred"` - FolderID int64 `json:"folderId,omitempty"` - FolderUID string `json:"folderUid,omitempty"` - FolderTitle string `json:"folderTitle,omitempty"` - FolderURL string `json:"folderUrl,omitempty"` - SortMeta int64 `json:"sortMeta"` - SortMetaName string `json:"sortMetaName,omitempty"` + ID int64 `json:"id"` + UID string `json:"uid"` + Title string `json:"title"` + URI string `json:"uri"` + URL string `json:"url"` + Slug string `json:"slug"` + Type HitType `json:"type"` + Tags []string `json:"tags"` + IsStarred bool `json:"isStarred"` + // Deprecated: use FolderUID instead + FolderID int64 `json:"folderId,omitempty"` + FolderUID string `json:"folderUid,omitempty"` + FolderTitle string `json:"folderTitle,omitempty"` + FolderURL string `json:"folderUrl,omitempty"` + SortMeta int64 `json:"sortMeta"` + SortMetaName string `json:"sortMetaName,omitempty"` } type HitList []*Hit diff --git a/public/api-merged.json b/public/api-merged.json index 74dd22a95b3..8468ef9a4d1 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -15278,6 +15278,7 @@ "type": "object", "properties": { "folderId": { + "description": "Deprecated: use FolderUID instead", "type": "integer", "format": "int64" }, diff --git a/public/openapi3.json b/public/openapi3.json index 51f786dcd50..4e9b9cdb6bc 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -6191,6 +6191,7 @@ "Hit": { "properties": { "folderId": { + "description": "Deprecated: use FolderUID instead", "format": "int64", "type": "integer" },