Skip to content

Commit

Permalink
refactor: remove redundant order validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubisoft-potato committed Jan 17, 2025
1 parent 7431681 commit a8fc23a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 0 additions & 10 deletions pkg/coderef/api/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,5 @@ func validateListCodeReferencesRequest(req *proto.ListCodeReferencesRequest, loc
}
return dt.Err()
}
if req.OrderBy == proto.ListCodeReferencesRequest_DEFAULT {
dt, err := statusInvalidOrderBy.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalizeWithTemplate(locale.InvalidArgumentError, "order_by"),
})
if err != nil {
return statusInternal.Err()
}
return dt.Err()
}
return nil
}
9 changes: 7 additions & 2 deletions pkg/coderef/storage/v2/code_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/bucketeer-io/bucketeer/pkg/coderef/domain"
"github.com/bucketeer-io/bucketeer/pkg/storage/v2/mysql"
proto "github.com/bucketeer-io/bucketeer/proto/coderef"
)

var (
Expand Down Expand Up @@ -131,6 +132,7 @@ func (s *codeReferenceStorage) GetCodeReference(
id, environmentID string,
) (*domain.CodeReference, error) {
codeRef := &domain.CodeReference{}
var repositoryType int32
row := s.qe(ctx).QueryRowContext(
ctx,
selectCodeReferenceSQL,
Expand All @@ -147,7 +149,7 @@ func (s *codeReferenceStorage) GetCodeReference(
&mysql.JSONObject{Val: &codeRef.Aliases},
&codeRef.RepositoryName,
&codeRef.RepositoryOwner,
&codeRef.RepositoryType,
&repositoryType,
&codeRef.RepositoryBranch,
&codeRef.CommitHash,
&codeRef.EnvironmentId,
Expand All @@ -160,6 +162,7 @@ func (s *codeReferenceStorage) GetCodeReference(
}
return nil, err
}
codeRef.RepositoryType = proto.CodeReference_RepositoryType(repositoryType)
return codeRef, nil
}

Expand All @@ -181,6 +184,7 @@ func (s *codeReferenceStorage) ListCodeReferences(
codeRefs := make([]*domain.CodeReference, 0, limit)
for rows.Next() {
codeRef := &domain.CodeReference{}
var repositoryType int32
err := rows.Scan(
&codeRef.Id,
&codeRef.FeatureId,
Expand All @@ -191,7 +195,7 @@ func (s *codeReferenceStorage) ListCodeReferences(
&mysql.JSONObject{Val: &codeRef.Aliases},
&codeRef.RepositoryName,
&codeRef.RepositoryOwner,
&codeRef.RepositoryType,
&repositoryType,
&codeRef.RepositoryBranch,
&codeRef.CommitHash,
&codeRef.EnvironmentId,
Expand All @@ -201,6 +205,7 @@ func (s *codeReferenceStorage) ListCodeReferences(
if err != nil {
return nil, 0, 0, err
}
codeRef.RepositoryType = proto.CodeReference_RepositoryType(repositoryType)
codeRefs = append(codeRefs, codeRef)
}
if rows.Err() != nil {
Expand Down

0 comments on commit a8fc23a

Please sign in to comment.