defmodule Towerops.Workers.SessionCleanupWorker do
  @moduledoc """
  Oban worker for cleaning up expired browser sessions.

  Deletes browser sessions that have passed their expiration timestamp.
  This worker runs daily at 3 AM via Oban cron.
  """
  use Oban.Worker, queue: :maintenance

  alias Towerops.Accounts

  @impl Oban.Worker
  @spec perform(Oban.Job.t()) :: {:ok, %{sessions_deleted: non_neg_integer()}}
  def perform(_job) do
    count = Accounts.delete_expired_browser_sessions()
    {:ok, %{sessions_deleted: count}}
  end
end
