<commit_before>module Facets
  class FinderService
    LINKED_FINDER_CONTENT_ID = "42ce66de-04f3-4192-bf31-8394538e0734".freeze

    def linked_finder_ids(facet_group_content_id)
      Rails.cache.fetch("FinderLinksService/linked_finder_ids", expires_in: 4.hours) do
        finders_for_facet_group(facet_group_content_id).map { |f| f["content_id"] }
      end
    end

    def pinned_item_links(content_id = LINKED_FINDER_CONTENT_ID)
      finder_links(content_id).to_hash.fetch("links", {})["ordered_related_items"]
    end

  private

    def finders_for_facet_group(facet_group_content_id)
      publishing_api.get_linked(facet_group_content_id).to_hash["body"]
    end

    def finder_links(content_id)
      @finder_links ||= publishing_api.get_links(content_id)
    end

    def publishing_api
      Services.publishing_api
    end
  end
end<commit_msg>Return an empty array when they are no pinned items<commit_after>module Facets
  class FinderService
    LINKED_FINDER_CONTENT_ID = "42ce66de-04f3-4192-bf31-8394538e0734".freeze

    def linked_finder_ids(facet_group_content_id)
      Rails.cache.fetch("FinderLinksService/linked_finder_ids", expires_in: 4.hours) do
        finders_for_facet_group(facet_group_content_id).map { |f| f["content_id"] }
      end
    end

    def pinned_item_links(content_id = LINKED_FINDER_CONTENT_ID)
      finder_links(content_id).to_hash.fetch("links", {})["ordered_related_items"] || []
    end

  private

    def finders_for_facet_group(facet_group_content_id)
      publishing_api.get_linked(facet_group_content_id).to_hash["body"]
    end

    def finder_links(content_id)
      @finder_links ||= publishing_api.get_links(content_id)
    end

    def publishing_api
      Services.publishing_api
    end
  end
end
{'fraction_non_alphanumeric': 0.08390022675736962, 'fraction_numerical': 0.02834467120181406, 'mean_word_length': 4.348484848484849, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6185277', 'n_tokens_mistral': 673, 'n_tokens_neox': 629, 'n_words': 86}