<commit_before># frozen_string_literal: true

# Glossary of mycological terms, with illustrations
class GlossaryTerm < AbstractModel
  require "acts_as_versioned"

  belongs_to(:thumb_image,
             class_name: "Image",
             foreign_key: "thumb_image_id",
             inverse_of: :best_glossary_terms)
  belongs_to :user
  belongs_to :rss_log
  has_and_belongs_to_many :images, -> { order "vote_cache DESC" }

  validates :name, presence: {
    message: proc { :glossary_error_name_blank.t }
  }
  # rubocop disable:Rails/UniqueValidationWithoutIndex
  # It's not worth indexing :name in the db;
  # Uniqueness of this attribute is nice, but not critical
  validates :name, uniqueness: {
    case_sensitive: false,
    message: proc { :glossary_error_duplicate_name.t }
  }
  # rubocop enable:Rails/UniqueValidationWithoutIndex
  validate :must_have_description_or_image

  after_destroy(:destroy_unused_images)

  ALL_TERM_FIELDS = [:name, :description].freeze
  acts_as_versioned(<commit_msg>Fix typo in cop disablement/enablement<commit_after># frozen_string_literal: true

# Glossary of mycological terms, with illustrations
class GlossaryTerm < AbstractModel
  require "acts_as_versioned"

  belongs_to(:thumb_image,
             class_name: "Image",
             foreign_key: "thumb_image_id",
             inverse_of: :best_glossary_terms)
  belongs_to :user
  belongs_to :rss_log
  has_and_belongs_to_many :images, -> { order "vote_cache DESC" }

  validates :name, presence: {
    message: proc { :glossary_error_name_blank.t }
  }
  # rubocop:disable Rails/UniqueValidationWithoutIndex
  # It's not worth indexing :name in the db;
  # Uniqueness of this attribute is nice, but not critical
  validates :name, uniqueness: {
    case_sensitive: false,
    message: proc { :glossary_error_duplicate_name.t }
  }
  # rubocop:enable Rails/UniqueValidationWithoutIndex
  validate :must_have_description_or_image

  after_destroy(:destroy_unused_images)

  ALL_TERM_FIELDS = [:name, :description].freeze
  acts_as_versioned(
{'fraction_non_alphanumeric': 0.0788829005389515, 'fraction_numerical': 0.0, 'mean_word_length': 4.430851063829787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4410603', 'n_tokens_mistral': 680, 'n_tokens_neox': 662, 'n_words': 147}