From f4b37e04d67b6ee29b8d98577ad5d6aeb3525f76 Mon Sep 17 00:00:00 2001 From: Aditya Kajla Date: Tue, 6 Feb 2024 16:37:54 -0800 Subject: [PATCH] Remove unused ListAll() from objecttype repository (#297) --- .gitignore | 1 + pkg/authz/objecttype/mysql.go | 28 ---------------------------- pkg/authz/objecttype/postgres.go | 29 ----------------------------- pkg/authz/objecttype/repository.go | 1 - pkg/authz/objecttype/sqlite.go | 28 ---------------------------- 5 files changed, 1 insertion(+), 86 deletions(-) diff --git a/.gitignore b/.gitignore index 296e63c9..f6265342 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ apirunner.conf .DS_Store bin/ dist/ +.idea/ diff --git a/pkg/authz/objecttype/mysql.go b/pkg/authz/objecttype/mysql.go index da9d0e86..b78d3494 100644 --- a/pkg/authz/objecttype/mysql.go +++ b/pkg/authz/objecttype/mysql.go @@ -112,34 +112,6 @@ func (repo MySQLRepository) GetByTypeId(ctx context.Context, typeId string) (Mod return &objectType, nil } -func (repo MySQLRepository) ListAll(ctx context.Context) ([]Model, error) { - models := make([]Model, 0) - objectTypes := make([]ObjectType, 0) - err := repo.DB.SelectContext( - ctx, - &objectTypes, - ` - SELECT id, typeId, definition, createdAt, updatedAt, deletedAt - FROM objectType - WHERE - deletedAt IS NULL - `, - ) - - if err != nil { - if errors.Is(err, sql.ErrNoRows) { - return models, nil - } - return models, errors.Wrap(err, "error listing all object types") - } - - for i := range objectTypes { - models = append(models, &objectTypes[i]) - } - - return models, nil -} - func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error) { models := make([]Model, 0) objectTypes := make([]ObjectType, 0) diff --git a/pkg/authz/objecttype/postgres.go b/pkg/authz/objecttype/postgres.go index 20244cb7..03437494 100644 --- a/pkg/authz/objecttype/postgres.go +++ b/pkg/authz/objecttype/postgres.go @@ -118,35 +118,6 @@ func (repo PostgresRepository) GetByTypeId(ctx context.Context, typeId string) ( return &objectType, nil } -func (repo PostgresRepository) ListAll(ctx context.Context) ([]Model, error) { - models := make([]Model, 0) - objectTypes := make([]ObjectType, 0) - err := repo.DB.SelectContext( - ctx, - &objectTypes, - ` - SELECT id, type_id, definition, created_at, updated_at, deleted_at - FROM object_type - WHERE - deleted_at IS NULL - `, - ) - - if err != nil { - if errors.Is(err, sql.ErrNoRows) { - return models, nil - } - - return models, errors.Wrap(err, "error listing all object types") - } - - for i := range objectTypes { - models = append(models, &objectTypes[i]) - } - - return models, nil -} - func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error) { models := make([]Model, 0) objectTypes := make([]ObjectType, 0) diff --git a/pkg/authz/objecttype/repository.go b/pkg/authz/objecttype/repository.go index 749d03a6..0ef32c8d 100644 --- a/pkg/authz/objecttype/repository.go +++ b/pkg/authz/objecttype/repository.go @@ -27,7 +27,6 @@ type ObjectTypeRepository interface { Create(ctx context.Context, objectType Model) (int64, error) GetById(ctx context.Context, id int64) (Model, error) GetByTypeId(ctx context.Context, typeId string) (Model, error) - ListAll(ctx context.Context) ([]Model, error) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error) UpdateByTypeId(ctx context.Context, typeId string, objectType Model) error DeleteByTypeId(ctx context.Context, typeId string) error diff --git a/pkg/authz/objecttype/sqlite.go b/pkg/authz/objecttype/sqlite.go index e12506c3..dcc61556 100644 --- a/pkg/authz/objecttype/sqlite.go +++ b/pkg/authz/objecttype/sqlite.go @@ -118,34 +118,6 @@ func (repo SQLiteRepository) GetByTypeId(ctx context.Context, typeId string) (Mo return &objectType, nil } -func (repo SQLiteRepository) ListAll(ctx context.Context) ([]Model, error) { - models := make([]Model, 0) - objectTypes := make([]ObjectType, 0) - err := repo.DB.SelectContext( - ctx, - &objectTypes, - ` - SELECT id, typeId, definition, createdAt, updatedAt, deletedAt - FROM objectType - WHERE - deletedAt IS NULL - `, - ) - - if err != nil { - if errors.Is(err, sql.ErrNoRows) { - return models, nil - } - return models, errors.Wrap(err, "error listing all object types") - } - - for i := range objectTypes { - models = append(models, &objectTypes[i]) - } - - return models, nil -} - func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error) { models := make([]Model, 0) objectTypes := make([]ObjectType, 0)