<commit_before>class Story < ActiveRecord::Base

  include Flagging

  belongs_to :author, class_name: "User"
  belongs_to :parent, class_name: "Story"
  belongs_to :snippet

  has_many :story_tags
  has_many :tags, through: :story_tags
  has_many :votes
  has_many :children, class_name: "Story", foreign_key: :parent_id

  has_many :flags, as: :flaggable

  has_many :badges


  validates_presence_of :title, :on => :update
  validates_presence_of :content, :on => :update

  searchable do
    text :title, :content
  end

  def vote_count
    self.votes.where(liked: true).count
  end

  def self.most_popular
    stories = Story.all.where(published: true).sort_by(&:vote_count).reverse.take(5)
    stories.map { |story| {story => story.vote_count} }
  end

  def self.most_recent
    Story.all.where(published: true).sort_by(&:created_at).reverse.take(5)
  end
<commit_msg>Raise importance of keywords searched for in titles of stories<commit_after>class Story < ActiveRecord::Base

  include Flagging

  belongs_to :author, class_name: "User"
  belongs_to :parent, class_name: "Story"
  belongs_to :snippet

  has_many :story_tags
  has_many :tags, through: :story_tags
  has_many :votes
  has_many :children, class_name: "Story", foreign_key: :parent_id

  has_many :flags, as: :flaggable

  has_many :badges


  validates_presence_of :title, :on => :update
  validates_presence_of :content, :on => :update

  searchable do
    text :title, boost =>5
    text :content
  end

  def vote_count
    self.votes.where(liked: true).count
  end

  def self.most_popular
    stories = Story.all.where(published: true).sort_by(&:vote_count).reverse.take(5)
    stories.map { |story| {story => story.vote_count} }
  end

  def self.most_recent
    Story.all.where(published: true).sort_by(&:created_at).reverse.take(5)
  end

{'fraction_non_alphanumeric': 0.10867178924259056, 'fraction_numerical': 0.0027442371020856204, 'mean_word_length': 4.284057971014493, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '7087014', 'n_tokens_mistral': 659, 'n_tokens_neox': 636, 'n_words': 150}