package models

import (
	"time"
)

// QueueStatus représente le statut d'un job dans la queue
type QueueStatus string

const (
	QueueStatusPending    QueueStatus = "pending"
	QueueStatusProcessing QueueStatus = "processing"
	QueueStatusCompleted  QueueStatus = "completed"
	QueueStatusFailed     QueueStatus = "failed"
)

// HLSTranscodeQueue représente un job de transcodage HLS dans la queue
type HLSTranscodeQueue struct {
	ID           int64        `gorm:"primaryKey" json:"id"`
	TrackID      int64        `gorm:"not null;index" json:"track_id"`
	Track        Track        `gorm:"foreignKey:TrackID" json:"track,omitempty"`
	Priority     int          `gorm:"not null;default:5" json:"priority"`
	Status       QueueStatus  `gorm:"type:varchar(20);not null;default:'pending';index" json:"status"`
	RetryCount   int          `gorm:"not null;default:0" json:"retry_count"`
	MaxRetries   int          `gorm:"not null;default:3" json:"max_retries"`
	ErrorMessage *string      `gorm:"type:text" json:"error_message,omitempty"`
	CreatedAt    time.Time    `json:"created_at"`
	StartedAt    *time.Time   `json:"started_at,omitempty"`
	CompletedAt  *time.Time   `json:"completed_at,omitempty"`
}

func (HLSTranscodeQueue) TableName() string {
	return "hls_transcode_queue"
}

