<commit_before>require 'graphviz'

class Experiment < ActiveRecord::Base
  include ArchivableModel, SearchableModel

  belongs_to :project, inverse_of: :experiments
  belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User'
  belongs_to :last_modified_by, foreign_key: :last_modified_by_id, class_name: 'User'
  belongs_to :archived_by, foreign_key: :archived_by_id, class_name: 'User'
  belongs_to :restored_by, foreign_key: :restored_by_id, class_name: 'User'

  has_many :my_modules, inverse_of: :experiment, dependent: :destroy
  has_many :my_module_groups, inverse_of: :experiment, dependent: :destroy
  has_many :report_elements, inverse_of: :experiment, dependent: :destroy

  has_attached_file :workflowimg
  validates_attachment_content_type :workflowimg, content_type: /\Aimage\/.*\Z/

  validates :name,
            presence: true,
            length: { minimum: 4, maximum: 50 },
            uniqueness: { scope: :project, case_sensitive: false }
  validates :description, length: { maximum: 255 }
  validates :project, presence: true
  validates :created_by, presence: true
  validates :last_modified_by, presence: true
  with_options if: :archived do |experiment|
    experiment.validates :archived_by, presence: true
    experiment.validates :archived_on, presence: true
  end

  scope :is_archived, ->(is_archived) { where("archived = ?", is_archived) }
<commit_msg>Change validation for experiment workimg<commit_after>require 'graphviz'

class Experiment < ActiveRecord::Base
  include ArchivableModel, SearchableModel

  belongs_to :project, inverse_of: :experiments
  belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User'
  belongs_to :last_modified_by, foreign_key: :last_modified_by_id, class_name: 'User'
  belongs_to :archived_by, foreign_key: :archived_by_id, class_name: 'User'
  belongs_to :restored_by, foreign_key: :restored_by_id, class_name: 'User'

  has_many :my_modules, inverse_of: :experiment, dependent: :destroy
  has_many :my_module_groups, inverse_of: :experiment, dependent: :destroy
  has_many :report_elements, inverse_of: :experiment, dependent: :destroy

  has_attached_file :workflowimg
  validates_attachment :workflowimg,
    content_type: { content_type: ["image/png"] }

  validates :name,
            presence: true,
            length: { minimum: 4, maximum: 50 },
            uniqueness: { scope: :project, case_sensitive: false }
  validates :description, length: { maximum: 255 }
  validates :project, presence: true
  validates :created_by, presence: true
  validates :last_modified_by, presence: true
  with_options if: :archived do |experiment|
    experiment.validates :archived_by, presence: true
    experiment.validates :archived_on, presence: true
  end

  scope :is_archived, ->(is_archived) { where("archived = ?", is_archived) }

{'fraction_non_alphanumeric': 0.09759547383309759, 'fraction_numerical': 0.004243281471004243, 'mean_word_length': 5.371621621621622, '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': '627676', 'n_tokens_mistral': 930, 'n_tokens_neox': 918, 'n_words': 225}