From c1b47e0a2608285bee26bfb182160060067948e0 Mon Sep 17 00:00:00 2001 From: Brian Ginsburg Date: Wed, 4 Dec 2024 18:47:33 -0800 Subject: [PATCH] feat: Add new GetResults store method --- pkg/solver/store/db/db.go | 5 +++++ pkg/solver/store/memory/store.go | 10 ++++++++++ pkg/solver/store/store.go | 1 + 3 files changed, 16 insertions(+) diff --git a/pkg/solver/store/db/db.go b/pkg/solver/store/db/db.go index 7d60ad3a..bc14e119 100644 --- a/pkg/solver/store/db/db.go +++ b/pkg/solver/store/db/db.go @@ -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 diff --git a/pkg/solver/store/memory/store.go b/pkg/solver/store/memory/store.go index da3470ab..62d9fd0c 100644 --- a/pkg/solver/store/memory/store.go +++ b/pkg/solver/store/memory/store.go @@ -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() diff --git a/pkg/solver/store/store.go b/pkg/solver/store/store.go index cd6ad4ce..af3cd071 100644 --- a/pkg/solver/store/store.go +++ b/pkg/solver/store/store.go @@ -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)