Skip to content

Commit

Permalink
fix: exclude canceled job offers (#363)
Browse files Browse the repository at this point in the history
Co-authored-by: Narb <29411347+narbs91@users.noreply.github.com>
  • Loading branch information
walkah and narbs91 authored Sep 17, 2024
1 parent 973f396 commit 8b2784f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/solver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ func (solverServer *solverServer) getJobOffers(res corehttp.ResponseWriter, req
if notMatched := req.URL.Query().Get("not_matched"); notMatched == "true" {
query.NotMatched = true
}
if includeCancelled := req.URL.Query().Get("include_cancelled"); includeCancelled == "true" {
query.IncludeCancelled = true
}
return solverServer.store.GetJobOffers(query)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/solver/store/memory/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func (s *SolverStoreMemory) GetJobOffers(query store.GetJobOffersQuery) ([]data.
matching = false
}
}
if !query.IncludeCancelled && jobOffer.State == data.GetAgreementStateIndex("JobOfferCancelled") {
matching = false
}
if matching {
jobOffers = append(jobOffers, *jobOffer)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/solver/store/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ type GetJobOffersQuery struct {

// we use the DealID property of the jobOfferContainer to tell if it's been matched
NotMatched bool `json:"not_matched"`

// this will include cancelled job offers in the results
IncludeCancelled bool `json:"include_cancelled"`
}

type GetResourceOffersQuery struct {
Expand Down

0 comments on commit 8b2784f

Please sign in to comment.