# typed: strict
class DeferredJob < T::ImmutableStruct
  extend T::Sig
  include T::Struct::ActsAsComparable

  const :job_class, T.class_of(Scraper::JobBase)
  const :params, T::Hash[Symbol, T.untyped]
  const :set_args, T::Hash[Symbol, T.untyped]

  sig { returns(String) }
  def describe_params
    params
      .filter_map do |key, value|
        if value.nil?
          nil
        elsif value.is_a?(Domain::User) || value.is_a?(Domain::Post)
          "#{key}=#{value.to_param}"
        else
          "#{key}=#{value}"
        end
      end
      .map { |param| "[#{param}]" }
      .join("")
  end
end
