Chore: Deprecate FolderID from CountDashboardsInFolderRequest (#77804)

Deprecate FolderID from CountDashboardsInFolderRequest
This commit is contained in:
Kat Yang 2023-11-08 11:27:03 -05:00 committed by GitHub
parent bc875b4c13
commit 71a2ce5a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 0 deletions

View File

@ -1068,6 +1068,7 @@ func (d *dashboardStore) CountDashboardsInFolder(
var count int64
var err error
err = d.store.WithDbSession(ctx, func(sess *db.Session) error {
// nolint:staticcheck
session := sess.In("folder_id", req.FolderID).In("org_id", req.OrgID).
In("is_folder", d.store.GetDialect().BooleanStr(false))
count, err = session.Count(&dashboards.Dashboard{})

View File

@ -517,12 +517,14 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
// setup() saves one dashboard in the general folder and two in the "savedFolder".
count, err := dashboardStore.CountDashboardsInFolder(
context.Background(),
// nolint:staticcheck
&dashboards.CountDashboardsInFolderRequest{FolderID: 0, OrgID: 1})
require.NoError(t, err)
require.Equal(t, int64(1), count)
count, err = dashboardStore.CountDashboardsInFolder(
context.Background(),
// nolint:staticcheck
&dashboards.CountDashboardsInFolderRequest{FolderID: savedFolder.ID, OrgID: 1})
require.NoError(t, err)
require.Equal(t, int64(2), count)
@ -542,6 +544,7 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
})
require.NoError(t, err)
// nolint:staticcheck
count, err := dashboardStore.CountDashboardsInFolder(context.Background(), &dashboards.CountDashboardsInFolderRequest{FolderID: 2, OrgID: 1})
require.NoError(t, err)
require.Equal(t, count, int64(0))

View File

@ -376,6 +376,7 @@ type CountDashboardsInFolderQuery struct {
// to the store layer. The FolderID will be replaced with FolderUID when
// dashboards are updated with parent folder UIDs.
type CountDashboardsInFolderRequest struct {
// Deprecated: use FolderUID instead
FolderID int64
OrgID int64
}

View File

@ -602,6 +602,7 @@ func (dr DashboardServiceImpl) CountInFolder(ctx context.Context, orgID int64, f
return 0, err
}
// nolint:staticcheck
return dr.dashboardStore.CountDashboardsInFolder(ctx, &dashboards.CountDashboardsInFolderRequest{FolderID: folder.ID, OrgID: orgID})
}