<commit_before>class Version < ActiveRecord::Base
  include Pacecar

  default_scope :order => 'position'

  belongs_to :rubygem, :counter_cache => true
  has_many :dependencies, :dependent => :destroy
  has_many :downloads, :dependent => :destroy

  validates_format_of :number, :with => /^#{Gem::Version::VERSION_PATTERN}$/

  named_scope :owned_by, lambda { |user|
    { :conditions => { :rubygem_id => user.rubygem_ids } }
  }

  named_scope :subscribed_to_by, lambda { |user|
    { :conditions => { :rubygem_id => user.subscribed_gem_ids } }
  }

  named_scope :with_associated, { :conditions => ["rubygems.versions_count > 1"], :include => :rubygem, :order => "versions.built_at desc" }
  named_scope :prerelease,      { :conditions => { :prerelease => true  }}
  named_scope :release,         { :conditions => { :prerelease => false }}

  named_scope :latest, { :group => 'rubygem_id, platform', :having => 'position = MIN(position)', :include => :rubygem }<commit_msg>Revert "Version.latest should use the lowest position rather than assuming 0"<commit_after>class Version < ActiveRecord::Base
  include Pacecar

  default_scope :order => 'position'

  belongs_to :rubygem, :counter_cache => true
  has_many :dependencies, :dependent => :destroy
  has_many :downloads, :dependent => :destroy

  validates_format_of :number, :with => /^#{Gem::Version::VERSION_PATTERN}$/

  named_scope :owned_by, lambda { |user|
    { :conditions => { :rubygem_id => user.rubygem_ids } }
  }

  named_scope :subscribed_to_by, lambda { |user|
    { :conditions => { :rubygem_id => user.subscribed_gem_ids } }
  }

  named_scope :with_associated, { :conditions => ["rubygems.versions_count > 1"], :include => :rubygem, :order => "versions.built_at desc" }
  named_scope :latest,          { :conditions => { :position   => 0     }, :include => :rubygem }
  named_scope :prerelease,      { :conditions => { :prerelease => true  }}
  named_scope :release,         { :conditions => { :prerelease => false }}
{'fraction_non_alphanumeric': 0.1495983935742972, 'fraction_numerical': 0.002008032128514056, 'mean_word_length': 4.35752688172043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5591341', 'n_tokens_mistral': 667, 'n_tokens_neox': 640, 'n_words': 143}