<commit_before>class ItemSerializer < ActiveModel::Serializer
  attributes :id, :created_at, :created_at_i, :type, :author, :title, :url, :text, :points

  has_many :children
  has_many :options

  def type
    object.item_type
  end

  def created_at_i
    created_at.to_i
  end

  def children
    object.children.order(points: :desc).where.not(item_type_cd: Item.pollopt)
  end

  def options
    object.children.where(deleted: false).where(dead: false).where(item_type_cd: Item.pollopt)
  end

  def filter(keys)
    return [:id, :children] if object.deleted || object.dead
    keys -= [:url, :title] if object.item_type == 'comment' || object.item_type == 'pollopt'
    keys -= [:options] if object.item_type != 'poll'
    keys -= [:children, :author, :created_at] if object.item_type == 'pollopt'
    keys
  end

end<commit_msg>/items API now includes parent_id and story_id attributes<commit_after>class ItemSerializer < ActiveModel::Serializer
  attributes :id, :created_at, :created_at_i, :type, :author, :title, :url, :text, :points, :parent_id, :story_id

  has_many :children
  has_many :options

  def type
    object.item_type
  end

  def created_at_i
    created_at.to_i
  end

  def children
    object.children.order(points: :desc).where.not(item_type_cd: Item.pollopt)
  end

  def options
    object.children.where(deleted: false).where(dead: false).where(item_type_cd: Item.pollopt)
  end

  def filter(keys)
    return [:id, :children] if object.deleted || object.dead
    keys -= [:parent_id, :story_id] if object.item_type == 'story' || object.item_type == 'poll'
    keys -= [:url, :title] if object.item_type == 'comment' || object.item_type == 'pollopt'
    keys -= [:options] if object.item_type != 'poll'
    keys -= [:children, :author, :created_at] if object.item_type == 'pollopt'
    keys
  end

end
{'fraction_non_alphanumeric': 0.1299126637554585, 'fraction_numerical': 0.0, 'mean_word_length': 4.008196721311475, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6795374', 'n_tokens_mistral': 635, 'n_tokens_neox': 626, 'n_words': 154}