Skip to content

Commit

Permalink
refactor: change field name
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanarya0 committed Jun 21, 2024
1 parent 3215c13 commit ce3fca3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/store/postgres/servicedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ type ServiceData struct {
NamespaceID string `db:"namespace_id"`
EntityID string `db:"entity_id"`
Value sql.NullString `db:"value"`
Key string `db:"key"`
KeyName string `db:"key"`
ProjectID string `db:"project_id"`
ResourceID string `db:"resource_id"`
}

func (from ServiceData) transformToServiceData() servicedata.ServiceData {
var value any
if from.Key != "" {
if from.KeyName != "" {
err := json.Unmarshal([]byte(from.Value.String), &value)
if err != nil {
return servicedata.ServiceData{}
Expand All @@ -45,7 +45,7 @@ func (from ServiceData) transformToServiceData() servicedata.ServiceData {
Key: servicedata.Key{
URN: from.URN,
ProjectID: from.ProjectID,
Name: from.Key,
Name: from.KeyName,
ResourceID: from.ResourceID,
},
Value: value,
Expand Down
4 changes: 2 additions & 2 deletions internal/store/postgres/servicedata_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ func (r ServiceDataRepository) Get(ctx context.Context, filter servicedata.Filte

sdMap := map[string]any{}
for _, sd := range serviceDataModel {
if sd.Key != "" {
if sd.KeyName != "" {
var value any
err := json.Unmarshal([]byte(sd.Value.String), &value)
if err != nil {
continue
}
sdMap[sd.Key] = value
sdMap[sd.KeyName] = value
}
}

Expand Down

0 comments on commit ce3fca3

Please sign in to comment.