<commit_before>class MyModule < ActiveRecord::Base
  include ArchivableModel, SearchableModel

  before_create :create_blank_protocol

  validates :name,
    presence: true,
    length: { minimum: 2, maximum: 50 }
  validates :x, :y, :workflow_order, presence: true
  validates :experiment, presence: true
  validates :my_module_group, presence: true, if: "!my_module_group_id.nil?"

  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'
  belongs_to :experiment, inverse_of: :my_modules
  belongs_to :my_module_group, inverse_of: :my_modules
  has_many :results, inverse_of: :my_module, :dependent => :destroy
  has_many :my_module_tags, inverse_of: :my_module, :dependent => :destroy
  has_many :tags, through: :my_module_tags
  has_many :my_module_comments, inverse_of: :my_module, :dependent => :destroy
  has_many :comments, through: :my_module_comments
  has_many :inputs, :class_name => 'Connection', :foreign_key => "input_id", inverse_of: :to, :dependent => :destroy
  has_many :outputs, :class_name => 'Connection', :foreign_key => "output_id", inverse_of: :from, :dependent => :destroy
  has_many :my_modules, through: :outputs, source: :to
  has_many :my_module_antecessors, through: :inputs, source: :from, class_name: 'MyModule'
  has_many :sample_my_modules, inverse_of: :my_module, :dependent => :destroy
  has_many :samples, through: :sample_my_modules
  has_many :user_my_modules, inverse_of: :my_module, :dependent => :destroy
  has_many :users, through: :user_my_modules
  has_many :activities, inverse_of: :my_module
  has_many :report_elements, inverse_of: :my_module, :dependent => :destroy
  has_many :protocols, inverse_of: :my_module, dependent: :destroy

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

  def self.search(user, include_archived, query = nil, page = 1)
    exp_ids =
      Experiment
      .search(user, include_archived, nil, SHOW_ALL_RESULTS)
      .select("id")

    if query
      a_query = query.strip<commit_msg>Double quotes -> single quotes (#hound)<commit_after>class MyModule < ActiveRecord::Base
  include ArchivableModel, SearchableModel

  before_create :create_blank_protocol

  validates :name,
    presence: true,
    length: { minimum: 2, maximum: 50 }
  validates :x, :y, :workflow_order, presence: true
  validates :experiment, presence: true
  validates :my_module_group, presence: true, if: "!my_module_group_id.nil?"

  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'
  belongs_to :experiment, inverse_of: :my_modules
  belongs_to :my_module_group, inverse_of: :my_modules
  has_many :results, inverse_of: :my_module, :dependent => :destroy
  has_many :my_module_tags, inverse_of: :my_module, :dependent => :destroy
  has_many :tags, through: :my_module_tags
  has_many :my_module_comments, inverse_of: :my_module, :dependent => :destroy
  has_many :comments, through: :my_module_comments
  has_many :inputs, :class_name => 'Connection', :foreign_key => "input_id", inverse_of: :to, :dependent => :destroy
  has_many :outputs, :class_name => 'Connection', :foreign_key => "output_id", inverse_of: :from, :dependent => :destroy
  has_many :my_modules, through: :outputs, source: :to
  has_many :my_module_antecessors, through: :inputs, source: :from, class_name: 'MyModule'
  has_many :sample_my_modules, inverse_of: :my_module, :dependent => :destroy
  has_many :samples, through: :sample_my_modules
  has_many :user_my_modules, inverse_of: :my_module, :dependent => :destroy
  has_many :users, through: :user_my_modules
  has_many :activities, inverse_of: :my_module
  has_many :report_elements, inverse_of: :my_module, :dependent => :destroy
  has_many :protocols, inverse_of: :my_module, dependent: :destroy

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

  def self.search(user, include_archived, query = nil, page = 1)
    exp_ids =
      Experiment
      .search(user, include_archived, nil, SHOW_ALL_RESULTS)
      .select("id")

    if query
      a_query = query.strip
{'fraction_non_alphanumeric': 0.11589403973509933, 'fraction_numerical': 0.0017660044150110375, 'mean_word_length': 6.046656298600311, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '775948', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1545, 'n_words': 371}