class GenerateBookmarksJob < ApplicationJob
  queue_as :default

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

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

    return unless running

    task.execute!
  end
end
