Chore: use any rather than interface{} (#74066)
This commit is contained in:
@@ -49,7 +49,7 @@ func TestDeleteExpiredVersions(t *testing.T) {
|
||||
|
||||
t.Run("Clean up old dashboard versions successfully", func(t *testing.T) {
|
||||
dashboardVersionStore.ExptectedDeletedVersions = 4
|
||||
dashboardVersionStore.ExpectedVersions = []interface{}{1, 2, 3, 4}
|
||||
dashboardVersionStore.ExpectedVersions = []any{1, 2, 3, 4}
|
||||
err := dashboardVersionService.DeleteExpired(context.Background(), &dashver.DeleteExpiredVersionsCommand{DeletedRows: 4})
|
||||
require.Nil(t, err)
|
||||
})
|
||||
@@ -147,7 +147,7 @@ func TestListDashboardVersions(t *testing.T) {
|
||||
type FakeDashboardVersionStore struct {
|
||||
ExpectedDashboardVersion *dashver.DashboardVersion
|
||||
ExptectedDeletedVersions int64
|
||||
ExpectedVersions []interface{}
|
||||
ExpectedVersions []any
|
||||
ExpectedListVersions []*dashver.DashboardVersion
|
||||
ExpectedError error
|
||||
}
|
||||
@@ -160,11 +160,11 @@ func (f *FakeDashboardVersionStore) Get(ctx context.Context, query *dashver.GetD
|
||||
return f.ExpectedDashboardVersion, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakeDashboardVersionStore) GetBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, perBatch int, versionsToKeep int) ([]interface{}, error) {
|
||||
func (f *FakeDashboardVersionStore) GetBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, perBatch int, versionsToKeep int) ([]any, error) {
|
||||
return f.ExpectedVersions, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakeDashboardVersionStore) DeleteBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, versionIdsToDelete []interface{}) (int64, error) {
|
||||
func (f *FakeDashboardVersionStore) DeleteBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, versionIdsToDelete []any) (int64, error) {
|
||||
return f.ExptectedDeletedVersions, f.ExpectedError
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ func (ss *sqlxStore) Get(ctx context.Context, query *dashver.GetDashboardVersion
|
||||
return &version, err
|
||||
}
|
||||
|
||||
func (ss *sqlxStore) GetBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, perBatch int, versionsToKeep int) ([]interface{}, error) {
|
||||
var versionIds []interface{}
|
||||
func (ss *sqlxStore) GetBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, perBatch int, versionsToKeep int) ([]any, error) {
|
||||
var versionIds []any
|
||||
versionIdsToDeleteQuery := `SELECT id
|
||||
FROM dashboard_version, (
|
||||
SELECT dashboard_id, count(version) as count, min(version) as min
|
||||
@@ -45,7 +45,7 @@ func (ss *sqlxStore) GetBatch(ctx context.Context, cmd *dashver.DeleteExpiredVer
|
||||
|
||||
// This service is used by cleanup which need to belong to the same transaction
|
||||
// Here we need to make sure that the transaction is shared between services
|
||||
func (ss *sqlxStore) DeleteBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, versionIdsToDelete []interface{}) (int64, error) {
|
||||
func (ss *sqlxStore) DeleteBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, versionIdsToDelete []any) (int64, error) {
|
||||
var deleted int64
|
||||
err := ss.sess.WithTransaction(ctx, func(tx *session.SessionTx) error {
|
||||
deleteExpiredSQL := `DELETE FROM dashboard_version WHERE id IN (?` + strings.Repeat(",?", len(versionIdsToDelete)-1) + `)`
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
type store interface {
|
||||
Get(context.Context, *dashver.GetDashboardVersionQuery) (*dashver.DashboardVersion, error)
|
||||
GetBatch(context.Context, *dashver.DeleteExpiredVersionsCommand, int, int) ([]interface{}, error)
|
||||
DeleteBatch(context.Context, *dashver.DeleteExpiredVersionsCommand, []interface{}) (int64, error)
|
||||
GetBatch(context.Context, *dashver.DeleteExpiredVersionsCommand, int, int) ([]any, error)
|
||||
DeleteBatch(context.Context, *dashver.DeleteExpiredVersionsCommand, []any) (int64, error)
|
||||
List(context.Context, *dashver.ListDashboardVersionsQuery) ([]*dashver.DashboardVersion, error)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func testIntegrationGetDashboardVersion(t *testing.T, fn getStore) {
|
||||
for i := 0; i < versionsToWrite-1; i++ {
|
||||
insertTestDashboard(t, ss, "test dash 53", 1, int64(i), false, "diff-all")
|
||||
}
|
||||
versionIDsToDelete := []interface{}{1, 2, 3, 4}
|
||||
versionIDsToDelete := []any{1, 2, 3, 4}
|
||||
res, err := dashVerStore.DeleteBatch(
|
||||
context.Background(),
|
||||
&dashver.DeleteExpiredVersionsCommand{DeletedRows: 4},
|
||||
@@ -101,7 +101,7 @@ func testIntegrationGetDashboardVersion(t *testing.T, fn getStore) {
|
||||
})
|
||||
|
||||
t.Run("Get all versions for an updated dashboard", func(t *testing.T) {
|
||||
updateTestDashboard(t, ss, savedDash, map[string]interface{}{
|
||||
updateTestDashboard(t, ss, savedDash, map[string]any{
|
||||
"tags": "different-tag",
|
||||
})
|
||||
query := dashver.ListDashboardVersionsQuery{DashboardID: savedDash.ID, OrgID: 1, Limit: 1000}
|
||||
@@ -134,13 +134,13 @@ var (
|
||||
)
|
||||
|
||||
func insertTestDashboard(t *testing.T, sqlStore db.DB, title string, orgId int64,
|
||||
folderId int64, isFolder bool, tags ...interface{}) *dashboards.Dashboard {
|
||||
folderId int64, isFolder bool, tags ...any) *dashboards.Dashboard {
|
||||
t.Helper()
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: orgId,
|
||||
FolderID: folderId,
|
||||
IsFolder: isFolder,
|
||||
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"id": nil,
|
||||
"title": title,
|
||||
"tags": tags,
|
||||
@@ -189,7 +189,7 @@ func insertTestDashboard(t *testing.T, sqlStore db.DB, title string, orgId int64
|
||||
return dash
|
||||
}
|
||||
|
||||
func updateTestDashboard(t *testing.T, sqlStore db.DB, dashboard *dashboards.Dashboard, data map[string]interface{}) {
|
||||
func updateTestDashboard(t *testing.T, sqlStore db.DB, dashboard *dashboards.Dashboard, data map[string]any) {
|
||||
t.Helper()
|
||||
|
||||
data["id"] = dashboard.ID
|
||||
|
||||
@@ -36,8 +36,8 @@ func (ss *sqlStore) Get(ctx context.Context, query *dashver.GetDashboardVersionQ
|
||||
return &version, nil
|
||||
}
|
||||
|
||||
func (ss *sqlStore) GetBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, perBatch int, versionsToKeep int) ([]interface{}, error) {
|
||||
var versionIds []interface{}
|
||||
func (ss *sqlStore) GetBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, perBatch int, versionsToKeep int) ([]any, error) {
|
||||
var versionIds []any
|
||||
err := ss.db.WithTransactionalDbSession(ctx, func(sess *db.Session) error {
|
||||
versionIdsToDeleteQuery := `SELECT id
|
||||
FROM dashboard_version, (
|
||||
@@ -55,11 +55,11 @@ func (ss *sqlStore) GetBatch(ctx context.Context, cmd *dashver.DeleteExpiredVers
|
||||
return versionIds, err
|
||||
}
|
||||
|
||||
func (ss *sqlStore) DeleteBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, versionIdsToDelete []interface{}) (int64, error) {
|
||||
func (ss *sqlStore) DeleteBatch(ctx context.Context, cmd *dashver.DeleteExpiredVersionsCommand, versionIdsToDelete []any) (int64, error) {
|
||||
var deleted int64
|
||||
err := ss.db.WithTransactionalDbSession(ctx, func(sess *db.Session) error {
|
||||
deleteExpiredSQL := `DELETE FROM dashboard_version WHERE id IN (?` + strings.Repeat(",?", len(versionIdsToDelete)-1) + `)`
|
||||
sqlOrArgs := append([]interface{}{deleteExpiredSQL}, versionIdsToDelete...)
|
||||
sqlOrArgs := append([]any{deleteExpiredSQL}, versionIdsToDelete...)
|
||||
expiredResponse, err := sess.Exec(sqlOrArgs...)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user