package schedulers

import (
	"context"
	"sort"

	"github.com/pingcap/test-infra/services/tps/pkg/common"
)

type FifoScheduler struct {
}

func (s *FifoScheduler) Name() string {
	return "FifoScheduler"
}

func (s *FifoScheduler) Filter(ctx context.Context, jobs []*common.ArgoJob) (result []*common.ArgoJob, err error) {
	// sort by createAt
	sort.Slice(jobs, func(i, j int) bool {
		return jobs[i].PlanExec.CreatedAt < jobs[j].PlanExec.CreatedAt
	})
	return jobs, nil
}
