<commit_before>class Household < ActiveRecord::Base
  include Deactivatable

  belongs_to :community
  has_many :accounts, ->{ joins(:community).includes(:community).order("LOWER(communities.name)") },
    inverse_of: :household
  has_many :signups
  has_many :users, ->{ by_name }, inverse_of: :household

  scope :active, -> { where("deactivated_at IS NULL") }
  scope :by_name, -> { order("LOWER(households.name)") }
  scope :by_active_and_name, -> { order("(CASE WHEN deactivated_at IS NULL THEN 0 ELSE 1 END)").by_name }
  scope :by_commty_and_name, -> { includes(:community).order("LOWER(communities.abbrv)").by_name }
  scope :in_community, ->(c) { where(community_id: c.id) }
  scope :matching, ->(q) { where("households.name ILIKE ?", "%#{q}%") }

  delegate :name, :abbrv, to: :community, prefix: true

  validates :name, presence: true, length: { maximum: 32 },
    uniqueness: { scope: :community_id, message:<commit_msg>Fixed bug in household search<commit_after>class Household < ActiveRecord::Base
  include Deactivatable

  belongs_to :community
  has_many :accounts, ->{ joins(:community).includes(:community).order("LOWER(communities.name)") },
    inverse_of: :household
  has_many :signups
  has_many :users, ->{ by_name }, inverse_of: :household

  scope :active, -> { where("deactivated_at IS NULL") }
  scope :by_name, -> { order("LOWER(households.name)") }
  scope :by_active_and_name, -> { order("(CASE WHEN deactivated_at IS NULL THEN 0 ELSE 1 END)").by_name }
  scope :by_commty_and_name, -> { joins(:community).order("LOWER(communities.abbrv)").by_name }
  scope :in_community, ->(c) { where(community_id: c.id) }
  scope :matching, ->(q) { where("households.name ILIKE ?", "%#{q}%") }

  delegate :name, :abbrv, to: :community, prefix: true

  validates :name, presence: true, length: { maximum: 32 },
    uniqueness: { scope: :community_id, message:
{'fraction_non_alphanumeric': 0.1617881852048962, 'fraction_numerical': 0.004257583821181479, 'mean_word_length': 5.1237785016286646, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '6308067', 'n_tokens_mistral': 682, 'n_tokens_neox': 638, 'n_words': 145}