package common

import (
	"time"

	"github.com/pingcap/test-infra/common/model"
)

type CaseExecQueryOpts struct {
	Status                     []model.ExecutionStatus
	IDs                        []model.ID
	CaseIDs                    []model.ID
	RootPlanID                 *model.ID
	RootPlanExecID             *model.ID
	FromStartedAt, ToStartedAt *int64
	Offset, Count              uint
}

type PlanExecQueryOpts struct {
	Status     []model.ExecutionStatus
	IDs        []model.ID
	PlanIDs    []model.ID
	TriggerIDs []model.ID
	// only returns the plan-execs that were created by CRON triggers
	OnlyCron                   bool
	TriagePhase                *model.TriagePhase
	ResourcePoolID             *model.ID
	HasLivingTestbed           bool
	CreatedAt                  *time.Time
	FromStartedAt, ToStartedAt *int64
	FromUpdatedAt              *time.Time
	SortedBy                   PlanExecSortedBy
	SortedDescending           bool
	Offset, Count              uint
}

type PlanExecCreateOpts struct {
	PlanIDs []model.ID

	// internal fields
	Priority model.ExecPriority
}

type PlanExecSortedBy string

const (
	PlanExecSortedByCreatedAt PlanExecSortedBy = "plan_executions.created_at"
	PlanExecSortedByUpdatedAt PlanExecSortedBy = "plan_executions.updated_at"
	PlanExecSortedByStartedAt PlanExecSortedBy = "plan_executions.started_at"
)
