<commit_before>require 'gds_api/helpers'

class Finder
  include GdsApi::Helpers

  attr_reader :slug, :name, :document_noun, :facets
  attr_accessor :keywords

  def self.get(slug)
    schema_attributes = FinderFrontend.finder_api.get_schema(slug).to_hash
    artefact_attributes = content_api.artefact(slug)
    organisation_tags = artefact_attributes.tags.select { |t| t.details.type == "organisation" }

    FinderParser.parse(
      schema_attributes.merge(
        "name" => artefact_attributes['title'],
        "organisations" => organisation_tags,
      )
    )
  end

  def initialize(attrs = {})
    @slug = attrs[:slug]
    @name = attrs[:name]
    @document_noun = attrs[:document_noun]
    @facets = attrs[:facets]
    @organisations = attrs[:organisations]
  end

  def results
    @results ||= ResultSet.get(slug, search_params)
  end

  def primary_organisation
    organisations.first
  end

private
  attr_reader :organisations

  def search_params
    facet_search_params.merge(keyword_search_params)
  end

  def facet_search_params
    facets.values
  end

  def keyword_search_params
    if keywords
      { "keywords" => keywords }
    else
      {}
    end
  end

  def self.content_api
    @content_api ||= GdsApi::ContentApi.new(Plek.current.find('contentapi'))
  end
end
<commit_msg>Add some scaffold for related links<commit_after>require 'gds_api/helpers'

class Finder
  include GdsApi::Helpers

  attr_reader :slug, :name, :document_noun, :facets, :related_links
  attr_accessor :keywords

  def self.get(slug)
    schema_attributes = FinderFrontend.finder_api.get_schema(slug).to_hash
    artefact_attributes = content_api.artefact(slug)
    organisation_tags = artefact_attributes.tags.select { |t| t.details.type == "organisation" }

    FinderParser.parse(
      schema_attributes.merge(
        "name" => artefact_attributes['title'],
        "organisations" => organisation_tags,
      )
    )
  end

  def initialize(attrs = {})
    @slug = attrs[:slug]
    @name = attrs[:name]
    @document_noun = attrs[:document_noun]
    @facets = attrs[:facets]
    @organisations = attrs[:organisations]
    @related_links = [{title: 'Link other thing', web_url: '/link-1'},
                      {title: 'Link to thing', web_url: '/link-2'}]#attrs[:related_links]
  end

  def results
    @results ||= ResultSet.get(slug, search_params)
  end

  def primary_organisation
    organisations.first
  end

private
  attr_reader :organisations

  def search_params
    facet_search_params.merge(keyword_search_params)
  end

  def facet_search_params
    facets.values
  end

  def keyword_search_params
    if keywords
      { "keywords" => keywords }
    else
      {}
    end
  end

  def self.content_api
    @content_api ||= GdsApi::ContentApi.new(Plek.current.find('contentapi'))
  end
end

{'fraction_non_alphanumeric': 0.10386387805742645, 'fraction_numerical': 0.0007089684509039348, 'mean_word_length': 3.5152, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6232645', 'n_tokens_mistral': 937, 'n_tokens_neox': 937, 'n_words': 179}