Skip to content

Commit

Permalink
feat: Add new GetResults store method
Browse files Browse the repository at this point in the history
  • Loading branch information
bgins committed Dec 5, 2024
1 parent 8b2a423 commit c1b47e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/solver/store/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ func (store *SolverStoreDatabase) GetDealsAll() ([]data.DealContainer, error) {
return deals, nil
}

func (store *SolverStoreDatabase) GetResults() ([]data.Result, error) {
var results []data.Result
return results, nil
}

func (store *SolverStoreDatabase) GetJobOffer(id string) (*data.JobOfferContainer, error) {
// Offers are unique by CID, so we can query first
var record JobOffer
Expand Down
10 changes: 10 additions & 0 deletions pkg/solver/store/memory/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ func (s *SolverStoreMemory) GetDealsAll() ([]data.DealContainer, error) {
return deals, nil
}

func (s *SolverStoreMemory) GetResults() ([]data.Result, error) {
s.mutex.RLock()
defer s.mutex.RUnlock()
results := []data.Result{}
for _, result := range s.resultMap {
results = append(results, *result)
}
return results, nil
}

func (s *SolverStoreMemory) GetJobOffer(id string) (*data.JobOfferContainer, error) {
s.mutex.RLock()
defer s.mutex.RUnlock()
Expand Down
1 change: 1 addition & 0 deletions pkg/solver/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type SolverStore interface {
GetResourceOffers(query GetResourceOffersQuery) ([]data.ResourceOfferContainer, error)
GetDeals(query GetDealsQuery) ([]data.DealContainer, error)
GetDealsAll() ([]data.DealContainer, error)
GetResults() ([]data.Result, error)
GetJobOffer(id string) (*data.JobOfferContainer, error)
GetResourceOffer(id string) (*data.ResourceOfferContainer, error)
GetResourceOfferByAddress(address string) (*data.ResourceOfferContainer, error)
Expand Down

0 comments on commit c1b47e0

Please sign in to comment.