Skip to content

Commit

Permalink
feat: Add GetMatchDecision method
Browse files Browse the repository at this point in the history
  • Loading branch information
bgins committed Dec 7, 2024
1 parent bc572f8 commit 6b6f334
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/solver/store/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,20 @@ func (store *SolverStoreDatabase) GetResult(id string) (*data.Result, error) {
}

func (store *SolverStoreDatabase) GetMatchDecision(resourceOffer string, jobOffer string) (*data.MatchDecision, error) {
decision := &data.MatchDecision{}
return decision, nil
// The resource offer and job offer are unique
// CIDs, so we can query first
var record MatchDecision
result := store.db.Where("resource_offer = ? AND job_offer = ?", resourceOffer, jobOffer).First(&record)

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

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

func (store *SolverStoreDatabase) UpdateJobOfferState(id string, dealID string, state uint8) (*data.JobOfferContainer, error) {
Expand Down

0 comments on commit 6b6f334

Please sign in to comment.