mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
fix: bind matcher source to playlist
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/cosmic-clash/cosmic-clash/server/domain"
|
||||
)
|
||||
|
||||
type CandidateSource func(context.Context, time.Time, int) ([]domain.Candidate, error)
|
||||
type CandidateSource func(context.Context, time.Time, domain.Playlist, int) ([]domain.Candidate, error)
|
||||
|
||||
type ProposalCreator interface {
|
||||
CreateProposal(context.Context, domain.Proposal, map[string]string, time.Time) error
|
||||
@@ -68,7 +68,7 @@ func (w Worker) RunOnce(ctx context.Context) (bool, error) {
|
||||
return false, fmt.Errorf("invalid matcher size")
|
||||
}
|
||||
now := w.Now()
|
||||
candidates, err := w.Source(ctx, now, w.Size)
|
||||
candidates, err := w.Source(ctx, now, w.Playlist, w.Size)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -77,6 +77,9 @@ func (w Worker) RunOnce(ctx context.Context) (bool, error) {
|
||||
}
|
||||
queue := domain.NewQueue()
|
||||
for _, candidate := range candidates {
|
||||
if candidate.Playlist != w.Playlist {
|
||||
return false, fmt.Errorf("candidate playlist does not match worker")
|
||||
}
|
||||
if _, err := queue.Create(candidate.PlayerID, candidate.TicketID, "matcher-"+candidate.TicketID, candidate, now); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user