Skip to content

Commit

Permalink
Change errors during refectoring
Browse files Browse the repository at this point in the history
  • Loading branch information
milosgagovic committed Sep 26, 2023
1 parent 9c99bf3 commit 7de1bbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions domain/redirectdefinition/repository/redirectdefinition.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package redirectrepository

import (
"context"

redirectstore "github.com/foomo/redirects/domain/redirectdefinition/store"

Check failure on line 6 in domain/redirectdefinition/repository/redirectdefinition.go

View workflow job for this annotation

GitHub Actions / test

import 'github.com/foomo/redirects/domain/redirectdefinition/store' is not allowed from list 'Main' (depguard)

keelmongo "github.com/foomo/keel/persistence/mongo"

Check failure on line 8 in domain/redirectdefinition/repository/redirectdefinition.go

View workflow job for this annotation

GitHub Actions / test

import 'github.com/foomo/keel/persistence/mongo' is not allowed from list 'Main' (depguard)
Expand All @@ -15,7 +16,7 @@ type (
RSI interface {
Find(ctx context.Context, id string) (*redirectstore.RedirectDefinition, error)
}
BaseRedirectsDefinition struct {
RedirectsDefinitionRepository struct {
l *zap.Logger
collection *keelmongo.Collection
}
Expand All @@ -39,25 +40,24 @@ func NewRedirectsStore(l *zap.Logger, persistor *keelmongo.Persistor) (rs *Redir
}
return &RedirectsDefinitionRepository{
l: l,
persistor: persistor,
collection: collection}, nil
}

func (rs RedirectsDefinitionRepository) Find(ctx context.Context, id string) (*RedirectDefinition, error) {
var result RedirectDefinition
func (rs RedirectsDefinitionRepository) Find(ctx context.Context, id string) (*redirectstore.RedirectDefinition, error) {
var result redirectstore.RedirectDefinition
findErr := rs.collection.FindOne(ctx, bson.M{"id": id}, &result)
if findErr != nil {
return nil, findErr
}
return &result, nil
}

func (rs RedirectsDefinitionRepository) Insert(ctx context.Context, def *RedirectDefinition) error {
func (rs RedirectsDefinitionRepository) Insert(ctx context.Context, def *redirectstore.RedirectDefinition) error {
_, err := rs.collection.Col().InsertOne(ctx, def)
return err
}

func (rs RedirectsDefinitionRepository) Update(ctx context.Context, def *RedirectDefinition) error {
func (rs RedirectsDefinitionRepository) Update(ctx context.Context, def *redirectstore.RedirectDefinition) error {
filter := bson.D{{Key: "id", Value: def.ID}}
update := bson.D{{Key: "$set", Value: def}}

Expand All @@ -67,7 +67,7 @@ func (rs RedirectsDefinitionRepository) Update(ctx context.Context, def *Redirec
}

// maybe will be needed for migrating manual redirections?
func (rs RedirectsDefinitionRepository) UpsertMany(ctx context.Context, defs []*RedirectDefinition) error {
func (rs RedirectsDefinitionRepository) UpsertMany(ctx context.Context, defs []*redirectstore.RedirectDefinition) error {

Check failure on line 70 in domain/redirectdefinition/repository/redirectdefinition.go

View workflow job for this annotation

GitHub Actions / test

unnecessary leading newline (whitespace)

var operations []mongo.WriteModel

Check failure on line 72 in domain/redirectdefinition/repository/redirectdefinition.go

View workflow job for this annotation

GitHub Actions / test

Consider pre-allocating `operations` (prealloc)

Expand Down
7 changes: 4 additions & 3 deletions domain/redirectdefinition/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package redirectdefinition
import (
"github.com/foomo/contentserver/content"
keelmongo "github.com/foomo/keel/persistence/mongo"
redirectstore "github.com/foomo/redirects/domain/redirectdefinition/store"
"go.uber.org/zap"
)

Expand All @@ -22,12 +23,12 @@ func (rs *Service) CreateRedirectsFromContentserverexport(old, new map[string]*c
return nil
}

func (rs *Service) Search(dimension, id, path string) ([]*RedirectDefinition, error) {
func (rs *Service) Search(dimension, id, path string) ([]*redirectstore.RedirectDefinition, error) {

Check warning on line 26 in domain/redirectdefinition/service.go

View workflow job for this annotation

GitHub Actions / test

unused-parameter: parameter 'dimension' seems to be unused, consider removing or renaming it as _ (revive)
// TODO: Implement
return nil, nil
}

func (rs *Service) Create(def *RedirectDefinition) error {
func (rs *Service) Create(def *redirectstore.RedirectDefinition) error {

Check warning on line 31 in domain/redirectdefinition/service.go

View workflow job for this annotation

GitHub Actions / test

unused-parameter: parameter 'def' seems to be unused, consider removing or renaming it as _ (revive)
// TODO: Implement
return nil
}
Expand All @@ -37,7 +38,7 @@ func (rs *Service) Delete(id string) error {
return nil
}

func (rs *Service) Update(def *RedirectDefinition) error {
func (rs *Service) Update(def *redirectstore.RedirectDefinition) error {
// TODO: Implement
return nil
}

0 comments on commit 7de1bbe

Please sign in to comment.