package models

import "time"

// Columns match the live table (migrations/2026_10_03_consultation_waiting_queue.sql).
// The queue rules live in services/consultation_queue_service.go; this stack
// only reads the list and delegates add/remove there.
type AstrologerWaitingQueue struct {
	ID               uint       `gorm:"primaryKey;column:id"`
	AstrologerID     uint       `gorm:"column:astrologer_id;not null;index"`
	UserID           uint       `gorm:"column:user_id;not null;index"`
	WaitingType      string     `gorm:"column:waiting_type;type:enum('CHAT','CALL');not null"`
	Medium           string     `gorm:"column:medium"`
	QueuePosition    int        `gorm:"column:queue_position;default:1"`
	Status           string     `gorm:"column:status;default:'WAITING'"`
	RequestedAt      *time.Time `gorm:"column:requested_at"`
	WaitExpiresAt    *time.Time `gorm:"column:wait_expires_at"`
	NotifiedAt       *time.Time `gorm:"column:notified_at"`
	NotifyExpiresAt  *time.Time `gorm:"column:notify_expires_at"`
	ConnectingAt     *time.Time `gorm:"column:connecting_at"`
	ConnectExpiresAt *time.Time `gorm:"column:connect_expires_at"`
	ConnectedAt      *time.Time `gorm:"column:connected_at"`
	EndedAt          *time.Time `gorm:"column:ended_at"`
	EndReason        string     `gorm:"column:end_reason"`
	ConsultationID   *uint      `gorm:"column:consultation_id"`
	CreatedAt        *time.Time `gorm:"column:created_at"`
	UpdatedAt        *time.Time `gorm:"column:updated_at"`
	//------------------------------------
	// Relations
	//------------------------------------
	User       User       `gorm:"foreignKey:UserID;references:ID"`
	Astrologer Astrologer `gorm:"foreignKey:AstrologerID;references:ID"`
}

func (AstrologerWaitingQueue) TableName() string {
	return "astrologer_waiting_queue"
}
