<commit_before>require 'node_presenter'
require 'gds_api/helpers'

class SmartAnswerPresenter
  include GdsApi::Helpers
  extend Forwardable
  include Rails.application.routes.url_helpers

  attr_reader :request, :params, :flow

  def_delegators :@flow, :need_id

  def initialize(request, flow)
    @request = request
    @params = request.params
    @flow = flow
  end

  def artefact
    @artefact ||= content_api.artefact(@flow.name.to_s)
  end

  def i18n_prefix
    "flow.#{@flow.name}"
  end

  def lookup_translation(key)
    I18n.translate!("#{i18n_prefix}.#{key}")
  rescue I18n::MissingTranslationData
    nil
  end

  def markdown_for(key)
    markdown = lookup_translation(key)
    markdown && GovspeakPresenter.new(markdown).html
  end

  def title
    lookup_translation(:title) || @flow.name.to_s.humanize<commit_msg>Don't blow up when Content API is unavailable<commit_after>require 'node_presenter'
require 'gds_api/helpers'

class SmartAnswerPresenter
  include GdsApi::Helpers
  extend Forwardable
  include Rails.application.routes.url_helpers

  attr_reader :request, :params, :flow

  def_delegators :@flow, :need_id

  def initialize(request, flow)
    @request = request
    @params = request.params
    @flow = flow
  end

  def artefact
    @artefact ||= content_api.artefact(@flow.name.to_s)
  rescue GdsApi::HTTPErrorResponse
    {}
  end

  def i18n_prefix
    "flow.#{@flow.name}"
  end

  def lookup_translation(key)
    I18n.translate!("#{i18n_prefix}.#{key}")
  rescue I18n::MissingTranslationData
    nil
  end

  def markdown_for(key)
    markdown = lookup_translation(key)
    markdown && GovspeakPresenter.new(markdown).html
  end

  def title
    lookup_translation(:title) || @flow.name.to_s.humanize
{'fraction_non_alphanumeric': 0.1028735632183908, 'fraction_numerical': 0.009195402298850575, 'mean_word_length': 4.105571847507331, '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': '3211387', 'n_tokens_mistral': 610, 'n_tokens_neox': 594, 'n_words': 120}