From 97fd66db2e52ae830a324c9e82ee681b1851a5c0 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Tue, 24 Apr 2018 18:52:57 +0200 Subject: [PATCH] pkg: fix deadcode issues --- pkg/api/annotations.go | 16 ----- pkg/middleware/render_auth.go | 2 - pkg/services/sqlstore/migrations/stats_mig.go | 63 ++++++++++--------- 3 files changed, 32 insertions(+), 49 deletions(-) diff --git a/pkg/api/annotations.go b/pkg/api/annotations.go index fdf577a6a6f..52eeb57dbb9 100644 --- a/pkg/api/annotations.go +++ b/pkg/api/annotations.go @@ -294,19 +294,3 @@ func canSave(c *m.ReqContext, repo annotations.Repository, annotationID int64) R return nil } - -func canSaveByRegionID(c *m.ReqContext, repo annotations.Repository, regionID int64) Response { - items, err := repo.Find(&annotations.ItemQuery{RegionId: regionID, OrgId: c.OrgId}) - - if err != nil || len(items) == 0 { - return Error(500, "Could not find annotation to update", err) - } - - dashboardID := items[0].DashboardId - - if canSave, err := canSaveByDashboardID(c, dashboardID); err != nil || !canSave { - return dashboardGuardianResponse(err) - } - - return nil -} diff --git a/pkg/middleware/render_auth.go b/pkg/middleware/render_auth.go index 6c338becbda..c382eb8e707 100644 --- a/pkg/middleware/render_auth.go +++ b/pkg/middleware/render_auth.go @@ -31,8 +31,6 @@ func initContextWithRenderAuth(ctx *m.ReqContext) bool { return true } -type renderContextFunc func(key string) (string, error) - func AddRenderAuthKey(orgId int64, userId int64, orgRole m.RoleType) string { renderKeysLock.Lock() diff --git a/pkg/services/sqlstore/migrations/stats_mig.go b/pkg/services/sqlstore/migrations/stats_mig.go index 7e10eeb9f90..c47b8202c53 100644 --- a/pkg/services/sqlstore/migrations/stats_mig.go +++ b/pkg/services/sqlstore/migrations/stats_mig.go @@ -2,37 +2,38 @@ package migrations import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator" -func addStatsMigrations(mg *Migrator) { - statTable := Table{ - Name: "stat", - Columns: []*Column{ - {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true}, - {Name: "metric", Type: DB_Varchar, Length: 20, Nullable: false}, - {Name: "type", Type: DB_Int, Nullable: false}, - }, - Indices: []*Index{ - {Cols: []string{"metric"}, Type: UniqueIndex}, - }, - } - - // create table - mg.AddMigration("create stat table", NewAddTableMigration(statTable)) - - // create indices - mg.AddMigration("add index stat.metric", NewAddIndexMigration(statTable, statTable.Indices[0])) - - statValue := Table{ - Name: "stat_value", - Columns: []*Column{ - {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true}, - {Name: "value", Type: DB_Double, Nullable: false}, - {Name: "time", Type: DB_DateTime, Nullable: false}, - }, - } - - // create table - mg.AddMigration("create stat_value table", NewAddTableMigration(statValue)) -} +// commented out because of the deadcode CI check +//func addStatsMigrations(mg *Migrator) { +// statTable := Table{ +// Name: "stat", +// Columns: []*Column{ +// {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true}, +// {Name: "metric", Type: DB_Varchar, Length: 20, Nullable: false}, +// {Name: "type", Type: DB_Int, Nullable: false}, +// }, +// Indices: []*Index{ +// {Cols: []string{"metric"}, Type: UniqueIndex}, +// }, +// } +// +// // create table +// mg.AddMigration("create stat table", NewAddTableMigration(statTable)) +// +// // create indices +// mg.AddMigration("add index stat.metric", NewAddIndexMigration(statTable, statTable.Indices[0])) +// +// statValue := Table{ +// Name: "stat_value", +// Columns: []*Column{ +// {Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true}, +// {Name: "value", Type: DB_Double, Nullable: false}, +// {Name: "time", Type: DB_DateTime, Nullable: false}, +// }, +// } +// +// // create table +// mg.AddMigration("create stat_value table", NewAddTableMigration(statValue)) +//} func addTestDataMigrations(mg *Migrator) { testData := Table{