<commit_before># -*- encoding : utf-8 -*-
module RademadeAdmin::FieldHelper

  # Display the field of given item
  #
  # @param item [Object]
  # @param data_item [RademadeAdmin::Model::Info::DataItem]
  #
  # @return [String]
  #
  def display_item_value(item, data_item)
    value = raw_item_value(item, data_item)
    return (value ? '✔' : '×') if value.is_a?(::Boolean)
    value
  end

  def display_related_item(data_item, value)
    if data_item.relation.has_many?
      link_to(data_item.label, admin_related_item(item, data_item.getter))
    else
      link_to(value.to_s, admin_edit_uri(value)) unless value.nil?
    end
  end

  def display_upload_item(_, value)
    RademadeAdmin::Upload::PreviewService.new(value).uploaded_file_html
  end

  def pagination_option(number, name = 'paginate')
    hash_params = request.query_parameters.clone
    hash_params.delete(:page)
    hash_params[name.to_sym] = number

    selected = number == request.query_parameters[name.to_sym].to_i
    url_params = request.path_parameters.merge(hash_params)
    content_tag(:option, number.to_s, :selected => selected, :value => admin_url_for(url_params))
  end

  def input_attr(attrs = {})
    attrs.deep_merge(
      wrapper_html: { class: 'form-group' },
      input_html: { class: 'form-input' }
    )
  end

  def raw_item_value(item, data_item)
    return data_item.list_preview_handler.call(item) unless data_item.list_preview_handler.nil?
    value = item.send(data_item.list_preview_accessor)
    return display_upload_item(data_item, value) if data_item.has_uploader?
    return display_related_item(data_item, value) if data_item.has_relation?
    value.to_s.html_safe
  end

end
<commit_msg>Fix for displaying related items<commit_after># -*- encoding : utf-8 -*-
module RademadeAdmin::FieldHelper

  # Display the field of given item
  #
  # @param item [Object]
  # @param data_item [RademadeAdmin::Model::Info::DataItem]
  #
  # @return [String]
  #
  def display_item_value(item, data_item)
    value = raw_item_value(item, data_item)
    return (value ? '✔' : '×') if value.is_a?(::Boolean)
    value
  end

  def display_related_item(data_item, item, value)
    if data_item.relation.has_many?
      link_to(data_item.label, admin_related_item(item, data_item.getter))
    else
      link_to(value.to_s, admin_edit_uri(value)) unless value.nil?
    end
  end

  def display_upload_item(_, value)
    RademadeAdmin::Upload::PreviewService.new(value).uploaded_file_html
  end

  def pagination_option(number, name = 'paginate')
    hash_params = request.query_parameters.clone
    hash_params.delete(:page)
    hash_params[name.to_sym] = number

    selected = number == request.query_parameters[name.to_sym].to_i
    url_params = request.path_parameters.merge(hash_params)
    content_tag(:option, number.to_s, :selected => selected, :value => admin_url_for(url_params))
  end

  def input_attr(attrs = {})
    attrs.deep_merge(
      wrapper_html: { class: 'form-group' },
      input_html: { class: 'form-input' }
    )
  end

  def raw_item_value(item, data_item)
    return data_item.list_preview_handler.call(item) unless data_item.list_preview_handler.nil?
    value = item.send(data_item.list_preview_accessor)
    return display_upload_item(data_item, value) if data_item.has_uploader?
    return display_related_item(data_item, item, value) if data_item.has_relation?
    value.to_s.html_safe
  end

end

{'fraction_non_alphanumeric': 0.10984516505988899, 'fraction_numerical': 0.0005842827928717499, 'mean_word_length': 4.259600614439324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7237641', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1174, 'n_words': 218}