class InternalTranscriptionV6Job < ApplicationJob
  queue_as :default

  def perform(respondent_id, user_id)
    if SystemTask.where(running: true).where(task_class: "Voxtral").count.positive?
      status = "queued"
      running = false
    else
      status = "running"
      running = true
    end

    metadata = {
      respondent_id:
    }

    task = SystemTask.create!(
      status:,
      metadata:,
      running:,
      user_id:,
      task_type: "TranscribeV6",
      task_class: "Voxtral"
    )

    return unless running

    task.execute!
  end
end
