<commit_before>class Version < ActiveRecord::Base
  belongs_to :rubygem
  has_many :dependencies, :dependent => :destroy

  before_save      :update_prerelease
  after_validation :join_authors
  after_create     :full_nameify!
  after_save       :reorder_versions

  validates_format_of :number, :with => /\A#{Gem::Version::VERSION_PATTERN}\z/
  validate :platform_and_number_are_unique, :on => :create
  validate :authors_format, :on => :create

  def self.owned_by(user)
    where(:rubygem_id => user.rubygem_ids)
  end

  def self.subscribed_to_by(user)
    where(:rubygem_id => user.subscribed_gem_ids).
      by_created_at
  end

  def self.with_deps
    includes(:dependencies)
  end

  def self.latest
    where(:latest => true)
  end

  def self.prerelease
    where(:prerelease => true)
  end

  def self.release
    where(:prerelease => false)
  end

  def self.indexed
    where(:indexed => true)
  end

  def self.by_position
    order('position')
  end

  def self.by_built_at
    order("versions.built_at desc")
  end

  def self.by_created_at
    order('created_at desc')
  end

  def self.with_indexed(reverse = false)
    order_str =  "rubygems.name asc"
    order_str << ", position desc" if reverse

    indexed.includes(:rubygem).order(order_str)<commit_msg>lock down created at for versions<commit_after>class Version < ActiveRecord::Base
  belongs_to :rubygem
  has_many :dependencies, :dependent => :destroy

  before_save      :update_prerelease
  after_validation :join_authors
  after_create     :full_nameify!
  after_save       :reorder_versions

  validates_format_of :number, :with => /\A#{Gem::Version::VERSION_PATTERN}\z/
  validate :platform_and_number_are_unique, :on => :create
  validate :authors_format, :on => :create

  def self.owned_by(user)
    where(:rubygem_id => user.rubygem_ids)
  end

  def self.subscribed_to_by(user)
    where(:rubygem_id => user.subscribed_gem_ids).
      by_created_at
  end

  def self.with_deps
    includes(:dependencies)
  end

  def self.latest
    where(:latest => true)
  end

  def self.prerelease
    where(:prerelease => true)
  end

  def self.release
    where(:prerelease => false)
  end

  def self.indexed
    where(:indexed => true)
  end

  def self.by_position
    order('position')
  end

  def self.by_built_at
    order("versions.built_at desc")
  end

  def self.by_created_at
    order('versions.created_at desc')
  end

  def self.with_indexed(reverse = false)
    order_str =  "rubygems.name asc"
    order_str << ", position desc" if reverse

    indexed.includes(:rubygem).order(order_str)
{'fraction_non_alphanumeric': 0.10019342359767891, 'fraction_numerical': 0.0, 'mean_word_length': 3.6594594594594594, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '7421555', 'n_tokens_mistral': 912, 'n_tokens_neox': 866, 'n_words': 184}