Skip to content

Commit

Permalink
Remove unused ListAll() from objecttype repository (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
akajla09 authored Feb 7, 2024
1 parent e6f0e19 commit f4b37e0
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 86 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ apirunner.conf
.DS_Store
bin/
dist/
.idea/
28 changes: 0 additions & 28 deletions pkg/authz/objecttype/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 0 additions & 29 deletions pkg/authz/objecttype/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pkg/authz/objecttype/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 0 additions & 28 deletions pkg/authz/objecttype/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4b37e0

Please sign in to comment.