Skip to content

Commit

Permalink
feat: Add GetResourceOfferByAddress method
Browse files Browse the repository at this point in the history
  • Loading branch information
bgins committed Dec 4, 2024
1 parent 9779715 commit 7b791e7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/solver/store/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,18 @@ func (store *SolverStoreDatabase) GetResourceOffer(id string) (*data.ResourceOff
}

func (store *SolverStoreDatabase) GetResourceOfferByAddress(address string) (*data.ResourceOfferContainer, error) {
resourceOffer := &data.ResourceOfferContainer{}
return resourceOffer, nil
var record ResourceOffer
result := store.db.Where("resource_provider = ?", address).First(&record)

if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, nil
}
return nil, result.Error
}

resourceOffer := record.Attributes.Data()
return &resourceOffer, nil
}

func (store *SolverStoreDatabase) GetDeal(id string) (*data.DealContainer, error) {
Expand Down

0 comments on commit 7b791e7

Please sign in to comment.