<commit_before>class Project < ActiveRecord::Base
  acts_as_taggable
  
  belongs_to  :user
  has_many    :comments, :dependent => :destroy
  has_many    :repositories, :order => "repositories.mainline desc, repositories.created_at asc",
    :dependent => :destroy
  has_one     :mainline_repository, :conditions => ["mainline = ?", true], 
    :class_name => "Repository"
  has_many    :repository_clones, :conditions => ["mainline = ?", false],
    :class_name => "Repository"
    
  is_indexed :fields => ["title", "description", "slug"], 
    :concatenate => [
      { :class_name => 'Tag', 
        :field => 'name', 
        :as => 'category',
        :association_sql => "LEFT OUTER JOIN taggings ON taggings.taggable_id = projects.id " + 
                            "AND taggings.taggable_type = 'Project' LEFT OUTER JOIN tags ON taggings.tag_id = tags.id"
      }],
    :include => [{
      :association_name => "user",
      :field => "login",
      :as => "user"
    }]
      
    
  URL_FORMAT_RE = /^(http|https|nntp):\/\//.freeze
  validates_presence_of :title, :user_id, :slug
  validates_uniqueness_of :slug, :case_sensitive => false
  validates_format_of :slug, :with => /^[a-z0-9_\-]+$/i, 
    :message => "must match something in the range of [a-z0-9_\-]+"
  validates_format_of :home_url, :with => URL_FORMAT_RE, 
    :if => proc{|record| !record.home_url.blank? },
    :message => "Must begin with http(s)"
  validates_format_of :mailinglist_url, :with => URL_FORMAT_RE,
    :if => proc{|record| !record.mailinglist_url.blank? },
    :message => "Must begin with http(s)"
  validates_format_of :bugtracker_url, :with => URL_FORMAT_RE, 
    :if => proc{|record| !record.bugtracker_url.blank? },
    :message => "Must begin with http(s)"
    
  before_validation :downcase_slug
  after_create :create_mainline_repository
  
  LICENSES = [
    'MIT License',
    'BSD License',
    'Ruby License',
    'GNU General Public License version 2(GPLv2)',
    'GNU General Public License version 3 (GPLv3)',
    'GNU Lesser General Public License (LGPL)',
    'Mozilla Public License 1.0 (MPL)',
    'Mozilla Public License 1.1 (MPL 1.1)',<commit_msg>Added the AGPL as license option for projects<commit_after>class Project < ActiveRecord::Base
  acts_as_taggable
  
  belongs_to  :user
  has_many    :comments, :dependent => :destroy
  has_many    :repositories, :order => "repositories.mainline desc, repositories.created_at asc",
    :dependent => :destroy
  has_one     :mainline_repository, :conditions => ["mainline = ?", true], 
    :class_name => "Repository"
  has_many    :repository_clones, :conditions => ["mainline = ?", false],
    :class_name => "Repository"
    
  is_indexed :fields => ["title", "description", "slug"], 
    :concatenate => [
      { :class_name => 'Tag', 
        :field => 'name', 
        :as => 'category',
        :association_sql => "LEFT OUTER JOIN taggings ON taggings.taggable_id = projects.id " + 
                            "AND taggings.taggable_type = 'Project' LEFT OUTER JOIN tags ON taggings.tag_id = tags.id"
      }],
    :include => [{
      :association_name => "user",
      :field => "login",
      :as => "user"
    }]
      
    
  URL_FORMAT_RE = /^(http|https|nntp):\/\//.freeze
  validates_presence_of :title, :user_id, :slug
  validates_uniqueness_of :slug, :case_sensitive => false
  validates_format_of :slug, :with => /^[a-z0-9_\-]+$/i, 
    :message => "must match something in the range of [a-z0-9_\-]+"
  validates_format_of :home_url, :with => URL_FORMAT_RE, 
    :if => proc{|record| !record.home_url.blank? },
    :message => "Must begin with http(s)"
  validates_format_of :mailinglist_url, :with => URL_FORMAT_RE,
    :if => proc{|record| !record.mailinglist_url.blank? },
    :message => "Must begin with http(s)"
  validates_format_of :bugtracker_url, :with => URL_FORMAT_RE, 
    :if => proc{|record| !record.bugtracker_url.blank? },
    :message => "Must begin with http(s)"
    
  before_validation :downcase_slug
  after_create :create_mainline_repository
  
  LICENSES = [
    'MIT License',
    'BSD License',
    'Ruby License',
    'GNU General Public License version 2(GPLv2)',
    'GNU General Public License version 3 (GPLv3)',
    'GNU Lesser General Public License (LGPL)',
    'GNU Affero General Public License (AGPLv3)',
    'Mozilla Public License 1.0 (MPL)',
    'Mozilla Public License 1.1 (MPL 1.1)',
{'fraction_non_alphanumeric': 0.1440562613430127, 'fraction_numerical': 0.006578947368421052, 'mean_word_length': 3.3140900195694716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '4514001', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1481, 'n_words': 352}