<commit_before>module ItemListsHelper
  def item_list_link(list, item, offset, label=nil, &block)
    item_list_presenter(list, item, offset).item_link(label, &block)
  end

  def item_list_has_images?(list)
    first = list.items.to_a.first
    first.try(:image?)
  end

  def render_item_list(list, params=nil, container=nil)
    partial = item_list_has_images?(list) ? ItemList::STYLES["thumb"] : ItemList::STYLES["list"]
    partial = ItemList::STYLES["list"] if favorites_scoped?
    partial = ItemList::STYLES[params[:style]] if style_param?(params)
    render(partial, :item_list => list, container: container)
  end

  def render_item_list_nav(list, item)
    item_list_presenter(list, item, params[:offset]).render_nav
  end

  def item_list_title(item, item_type)
    return item_type.name_plural + " (#{item.default_display_name})" if item.present?

    item_type.name_plural
  end

  private

  def item_list_presenter(list, item, offset)
    klass = "#{list.class.name}Presenter".constantize
    klass.new(self, item, offset, list)
  end

  def style_param?(params)
    return false if params.blank?
    return false if params[:style].blank?
    return false unless ItemList::STYLES.include?(params[:style])

    true
  end

  def define_sort_direction(sort)
    # Define direction
    direction = Container::Sort.direction(sort) || sort

    # Check if direction is valid (ASC|DESC), otherwise default to ASC
    return ItemList::Sort.ascending unless ItemList::Sort.included?(direction)

    direction
  end

  def item_list_is_valid?(container)
    return false unless container.is_a?(Container::ItemList)

    return true if container.style.eql?("line")

    return true if container.sort.empty?

    return true unless Container::Sort.field_choices.key?(container.sort)

    it = ItemType.find(container.item_type)
    return true if it&.field_for_select&.sortable?

    false
  end
end
<commit_msg>Fix container issue<commit_after>module ItemListsHelper
  def item_list_link(list, item, offset, label=nil, &block)
    item_list_presenter(list, item, offset).item_link(label, &block)
  end

  def item_list_has_images?(list)
    first = list.items.to_a.first
    first.try(:image?)
  end

  def render_item_list(list, params=nil, container=nil)
    partial = item_list_has_images?(list) ? ItemList::STYLES["thumb"] : ItemList::STYLES["list"]
    partial = ItemList::STYLES["list"] if favorites_scoped?
    partial = ItemList::STYLES[params[:style]] if style_param?(params)
    render(partial, :item_list => list, container: container)
  end

  def render_item_list_nav(list, item)
    item_list_presenter(list, item, params[:offset]).render_nav
  end

  def item_list_title(item, item_type)
    return item_type.name_plural + " (#{item.default_display_name})" if item.present?

    item_type.name_plural
  end

  private

  def item_list_presenter(list, item, offset)
    klass = "#{list.class.name}Presenter".constantize
    klass.new(self, item, offset, list)
  end

  def style_param?(params)
    return false if params.blank?
    return false if params[:style].blank?
    return false unless ItemList::STYLES.include?(params[:style])

    true
  end

  def define_sort_direction(sort)
    # Define direction
    direction = Container::Sort.direction(sort) || sort

    # Check if direction is valid (ASC|DESC), otherwise default to ASC
    return ItemList::Sort.ascending unless ItemList::Sort.included?(direction)

    direction
  end

  def item_list_is_valid?(container)
    return false unless container.is_a?(Container::ItemList)

    return true if container.style.eql?("line")

    return true unless container.sort

    return true unless Container::Sort.field_choices.key?(container.sort)

    it = ItemType.find(container.item_type)
    return true if it&.field_for_select&.sortable?

    false
  end
end

{'fraction_non_alphanumeric': 0.10893927547563201, 'fraction_numerical': 0.0, 'mean_word_length': 4.451704545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1341799', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1227, 'n_words': 274}