<commit_before>require 'data_mapper'
require 'bcrypt'

DataMapper.setup(:default, ENV['DATABASE_URL'])

class User
  include DataMapper::Resource

  property :id, Serial
  property :name, String,  { :required => true }
  property :email, String, { :required => true,
                             :unique => true,
                             :format => :email_address }
  property :password, Text

  has n, :restaurants, { :child_key => [:creator_id] }
  has n, :created_restrictions, "Restriction", { :child_key => [:creator_id] }

  def password=(password)
    self.attribute_set(:password, BCrypt::Password.create(password))
  end

  def password
    <PASSWORD>::Password.new(self.attribute_get(:password))
  end
end

class Restaurant
  include DataMapper::Resource

  property :id, Serial
  property :name, String, { :required => true }
  property :address, Text, { :required => true }

  belongs_to :creator, 'User'

  has n, :restaurants_restrictions
  has n, :supported_restrictions, "Restriction", { :through => :restaurants_restrictions }

  def add_supported_restriction(restriction)
    self.restaurants_restrictions.first_or_create(:supported_restriction => restriction)
  end

  def self.search(query)
    all(:name.like => "%#{query}%") |
      all(supported_restrictions.name.like => "%#{query}%") |
      all(:address.like => "%#{query}%")

      # Here we're building 3 queries using symbol-based conditions , and then
      # using the "union" operator to join them different queries:
      # http://datamapper.org/docs/find.html#combining-queries
  end
end
<commit_msg>Remove comments from previous commit<commit_after>require 'data_mapper'
require 'bcrypt'

DataMapper.setup(:default, ENV['DATABASE_URL'])

class User
  include DataMapper::Resource

  property :id, Serial
  property :name, String,  { :required => true }
  property :email, String, { :required => true,
                             :unique => true,
                             :format => :email_address }
  property :password, Text

  has n, :restaurants, { :child_key => [:creator_id] }
  has n, :created_restrictions, "Restriction", { :child_key => [:creator_id] }

  def password=(password)
    self.attribute_set(:password, <PASSWORD>::Password.<PASSWORD>(password))
  end

  def password
    <PASSWORD>(self.attribute_get(:password))
  end
end

class Restaurant
  include DataMapper::Resource

  property :id, Serial
  property :name, String, { :required => true }
  property :address, Text, { :required => true }

  belongs_to :creator, 'User'

  has n, :restaurants_restrictions
  has n, :supported_restrictions, "Restriction", { :through => :restaurants_restrictions }

  def add_supported_restriction(restriction)
    self.restaurants_restrictions.first_or_create(:supported_restriction => restriction)
  end

  def self.search(query)
    all(:name.like => "%#{query}%") |
      all(supported_restrictions.name.like => "%#{query}%") |
      all(:address.like => "%#{query}%")
  end
end

{'fraction_non_alphanumeric': 0.13174656386188402, 'fraction_numerical': 0.00033523298692591353, 'mean_word_length': 3.867862969004894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, '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': '2577121', 'n_tokens_mistral': 947, 'n_tokens_neox': 914, 'n_words': 214}