<commit_before>class Project
  include Mongoid::Document
  include Mongoid::Slugify

  field :name
  field :vcs_url
  field :ssh_private_key
  field :ssh_public_key
  field :visible, :type => Boolean, :default => false

  has_and_belongs_to_many :users
  has_many :jobs # TECHNICAL_DEBT: s/jobs/builds/

  attr_accessible :name, :vcs_url


  after_validation :generate_slug
  def generate_slug
    # This has a '/' in it, so the constraints also needed to be loosened in config/routes.rb
    self.slug = github_project_name
  end


  def github_project_name
    result = vcs_url.sub("https://github.com/", "")
    if result[-1] == "/" then
      result = result[0..-2]
    end
    result
  end

end<commit_msg>Clean URLs can be done with just to_param, we don't need slugify for it.<commit_after>class Project
  include Mongoid::Document

  field :name
  field :vcs_url
  field :ssh_private_key
  field :ssh_public_key
  field :visible, :type => Boolean, :default => false

  has_and_belongs_to_many :users
  has_many :jobs # TECHNICAL_DEBT: s/jobs/builds/

  attr_accessible :name, :vcs_url

  # TECHNICAL_DEBT - TODO - WARNING - HACK - BEWARE
  # I can't quite figure out how this looks the project up, so it must be a linear search!
  def to_param
    github_project_name
  end

  def github_project_name
    result = vcs_url.sub("https://github.com/", "")
    if result[-1] == "/" then
      result = result[0..-2]
    end
    result
  end

end
{'fraction_non_alphanumeric': 0.09392265193370165, 'fraction_numerical': 0.004143646408839779, 'mean_word_length': 3.3513513513513513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '4971613', 'n_tokens_mistral': 523, 'n_tokens_neox': 495, 'n_words': 143}