<commit_before>class Snippet < ActiveRecord::Base

  belongs_to :user

  has_many :stories

  def self.most_recent
    Snippet.all.sort_by(&:created_at).reverse.take(10)
  end

  def self.most_popular
    Snippet.all.sort_by(&:score).reverse.take(10)
  end

  def self.random
    Snippet.all.shuffle
  end<commit_msg>Rewrite method to get most popular snippets by story count<commit_after>class Snippet < ActiveRecord::Base

  belongs_to :user

  has_many :stories

  def self.most_recent
    Snippet.all.sort_by(&:created_at).reverse.take(10)
  end

  def self.most_popular
    Snippet.all.map { |snippet| {snippet => snippet.stories.count} }.take(10)
  end

  def self.random
    Snippet.all.shuffle
  end
{'fraction_non_alphanumeric': 0.10042432814710042, 'fraction_numerical': 0.011315417256011316, 'mean_word_length': 3.816326530612245, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '3702679', 'n_tokens_mistral': 269, 'n_tokens_neox': 248, 'n_words': 50}