<commit_before>class Manufacturer < ActiveRecord::Base

  # default scope
  default_scope { where(:active => true).order('code') }

  def self.search(text, exact = true, **params) # **params is a ruby parameter "hash-splat"
    if exact
      x = where('name = ? OR code = ?', text, text)
      x = x.where(params) if params
    else
      val = "%#{text.upcase}%"
      x = where('UPPER(name) LIKE ? OR UPPER(code) LIKE ?', val, val)
      x = x.where(params) if params
    end
    x.first
  end


  def asset_count(org)
    Asset.where(:organization_id => org.id, :manufacturer_id => id).count
  end

  def full_name
    "#{name} - #{filter.titleize}"
  end

  def to_s
    name
  end

end<commit_msg>DRYing up Manufacturer#search<commit_after>class Manufacturer < ActiveRecord::Base

  # default scope
  default_scope { where(:active => true).order('code') }

  def self.search(text, exact = true, **params) # **params is a ruby parameter "hash-splat"
    if exact
      x = where('name = ? OR code = ?', text, text)
    else
      val = "%#{text.upcase}%"
      x = where('UPPER(name) LIKE ? OR UPPER(code) LIKE ?', val, val)
    end
    x = x.where(params) if params
    x.first
  end


  def asset_count(org)
    Asset.where(:organization_id => org.id, :manufacturer_id => id).count
  end

  def full_name
    "#{name} - #{filter.titleize}"
  end

  def to_s
    name
  end

end
{'fraction_non_alphanumeric': 0.14089595375722544, 'fraction_numerical': 0.0, 'mean_word_length': 2.9014084507042255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7455798', 'n_tokens_mistral': 496, 'n_tokens_neox': 477, 'n_words': 129}