diff --git a/pkg/services/dashboards/database/database.go b/pkg/services/dashboards/database/database.go index b04453bc1b1..2229af64924 100644 --- a/pkg/services/dashboards/database/database.go +++ b/pkg/services/dashboards/database/database.go @@ -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{}) diff --git a/pkg/services/dashboards/database/database_test.go b/pkg/services/dashboards/database/database_test.go index 69218a2d51c..a3607eb1d8f 100644 --- a/pkg/services/dashboards/database/database_test.go +++ b/pkg/services/dashboards/database/database_test.go @@ -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)) diff --git a/pkg/services/dashboards/models.go b/pkg/services/dashboards/models.go index 2d094aabec5..4190a7c4cf7 100644 --- a/pkg/services/dashboards/models.go +++ b/pkg/services/dashboards/models.go @@ -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 } diff --git a/pkg/services/dashboards/service/dashboard_service.go b/pkg/services/dashboards/service/dashboard_service.go index 1531d3a91ce..9e480d7d88e 100644 --- a/pkg/services/dashboards/service/dashboard_service.go +++ b/pkg/services/dashboards/service/dashboard_service.go @@ -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}) }