require "formatters/abstract_indexable_formatter"

class ManualIndexableFormatter < AbstractIndexableFormatter
  def type
    "manual"
  end

private
  def extra_attributes
    {
      specialist_sectors: specialist_sectors
    }
  end

  def indexable_content
    entity.summary # Manuals don't have a body
  end

  def organisation_slugs
    [entity.organisation_slug]
  end

  def specialist_sectors
    entity.tags.select { |t| t[:type] == "specialist_sector" }.map { |t| t[:slug] }
  end
end

require "formatters/abstract_indexable_formatter"

class ManualIndexableFormatter < AbstractIndexableFormatter
  def type
    "manual"
  end

private
  def extra_attributes
    {
      specialist_sectors: specialist_sectors
    }
  end

  def indexable_content
    entity.summary # Manuals don't have a body
  end

  def organisation_slugs
    [entity.organisation_slug]
  end

  def specialist_sectors
    if entity.tags.present?
      entity.tags.select { |t| t[:type] == "specialist_sector" }.map { |t| t[:slug] }
    else
      []
    end
  end
end

Handle tags not always being present on a manual
Handle tags not always being present on a manual

Even though all already-published manuals in Production with tags in
Panopticon have been published again to pick up the tags to send to Rummager,
some published manuals in a database replicated from Preview 2 days ago didn't
have the tags populated in Specialist Publisher. Tags aren't fetched when
republishing, so we need to handle the tags not being present when
republishing in order for the script to fix leading slashes to run without
errors.
