<commit_before>class Link < ActiveRecord::Base
  @@minimum_length = Rails.application.config.server_name[:host].length +
        Rails.application.config.hash_length + "http:///".length
  @@hostname = Rails.application.config.server_name[:host]

  # Input original must be a http(s) or ftp valid link
  validates_presence_of :original
  validates_format_of :original, :with => URI::regexp(%w(http https ftp))  
  # ..it must be longer than shorter link, otherwise is useless
  validates_length_of :original, :minimum => @@minimum_length
  # ... must not be recursive
  validate :original_must_not_be_recursive
  # ... no blast
  validate :original_no_blast
  
  public

  def complete_hashed_url
    return "http://" + Rails.application.config.server_name[:host] + "/" + self.hashed
  end

  def original_length
    return self.original.length
  end

  private

  def original_must_not_be_recursive
    errors.add(:original, "recursive") if original.include?(Rails.application.config.server_name[:host].to_s)
  end

  # XXX
  # Still doesn't check if from same IP source
  def original_no_blast
    seconds_of_delay = 10
    @count = Link.where("original = ?", original).
      where("created_at > ?", Time.now.ago(seconds_of_delay)).count
    errors.add(:original, "blast") if @count > 0
  end
end
<commit_msg>foo method<commit_after>class Link < ActiveRecord::Base
  @@minimum_length = Rails.application.config.server_name[:host].length +
        Rails.application.config.hash_length + "http:///".length
  @@hostname = Rails.application.config.server_name[:host]

  # Input original must be a http(s) or ftp valid link
  validates_presence_of :original
  validates_format_of :original, :with => URI::regexp(%w(http https ftp))  
  # ..it must be longer than shorter link, otherwise is useless
  validates_length_of :original, :minimum => @@minimum_length
  # ... must not be recursive
  validate :original_must_not_be_recursive
  # ... no blast
  validate :original_no_blast
  
  public

  def complete_hashed_url
    return "http://" + Rails.application.config.server_name[:host] + "/" + self.hashed
  end

  def original_length
    return self.original.length
  end

  private

  def original_must_not_be_recursive
    errors.add(:original, "recursive") if original.include?(Rails.application.config.server_name[:host].to_s)
  end

  # XXX
  # Still doesn't check if from same IP source
  def original_no_blast
    seconds_of_delay = 10
    @count = Link.where("original = ?", original).
      where("created_at > ?", Time.now.ago(seconds_of_delay)).count
    errors.add(:original, "blast") if @count > 0
  end

  def foo
  end
end

{'fraction_non_alphanumeric': 0.11229135053110774, 'fraction_numerical': 0.002276176024279211, 'mean_word_length': 3.956766917293233, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '4848163', 'n_tokens_mistral': 872, 'n_tokens_neox': 822, 'n_words': 198}