<commit_before>class RequirementsTemplate < ActiveRecord::Base

  include RequirementsTemplateEmail

  belongs_to :institution
  has_many :requirements, dependent: :destroy
  has_many :tags, inverse_of: :requirements_template, dependent: :destroy
  has_many :additional_informations, inverse_of: :requirements_template, dependent: :destroy
  has_many :sample_plans, inverse_of: :requirements_template, dependent: :destroy
  has_many :resource_contexts, dependent: :destroy
  has_many :plans, dependent: :destroy
  
  has_many :statistics, foreign_key: "requirements_template_id", 
                        class_name: "PublicTemplateStatistic"

  accepts_nested_attributes_for :requirements, reject_if: proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }
  accepts_nested_attributes_for :tags, allow_destroy: true, reject_if: proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }
  accepts_nested_attributes_for :sample_plans, allow_destroy: true, reject_if: proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }
  accepts_nested_attributes_for :additional_informations, allow_destroy: true, reject_if: proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }

  validates_columns :visibility, :review_type
  validates :institution_id, presence: true, numericality: true
  validates :visibility, presence: true
  validates :name, presence: true
  validates :name, uniqueness: { scope: :institution_id, message: "already present for this institution."}<commit_msg>fixed typo in satatistics association name<commit_after>class RequirementsTemplate < ActiveRecord::Base

  include RequirementsTemplateEmail

  belongs_to :institution
  has_many :requirements, dependent: :destroy
  has_many :tags, inverse_of: :requirements_template, dependent: :destroy
  has_many :additional_informations, inverse_of: :requirements_template, dependent: :destroy
  has_many :sample_plans, inverse_of: :requirements_template, dependent: :destroy
  has_many :resource_contexts, dependent: :destroy
  has_many :plans, dependent: :destroy
  
  has_many :statistics, foreign_key: "requirements_template_id", 
                        class_name: "RequirementsTemplateStatistic"

  accepts_nested_attributes_for :requirements, reject_if: proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }
  accepts_nested_attributes_for :tags, allow_destroy: true, reject_if: proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }
  accepts_nested_attributes_for :sample_plans, allow_destroy: true, reject_if: proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }
  accepts_nested_attributes_for :additional_informations, allow_destroy: true, reject_if: proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }

  validates_columns :visibility, :review_type
  validates :institution_id, presence: true, numericality: true
  validates :visibility, presence: true
  validates :name, presence: true
  validates :name, uniqueness: { scope: :institution_id, message: "already present for this institution."}
{'fraction_non_alphanumeric': 0.10441767068273092, 'fraction_numerical': 0.0, 'mean_word_length': 6.163716814159292, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '910954', 'n_tokens_mistral': 954, 'n_tokens_neox': 930, 'n_words': 246}