<commit_before># Describes an eMOP batch job
#
class BatchJob < ActiveRecord::Base
  belongs_to :font
  belongs_to :ocr_engine
  belongs_to :job_type
  has_many :job_queues, foreign_key: 'batch_id', dependent: :destroy
  has_many :page_results, foreign_key: 'batch_id', dependent: :destroy
  has_many :postproc_pages, dependent: :destroy
  has_many :work_ocr_results, foreign_key: 'batch_id'

  validates :name, presence: true

  after_initialize :set_defaults

  def self.default_ocr_engine
    OcrEngine.find_by_name('Tesseract')
  end

  def self.default_job_type
    JobType.find_by_name('OCR')
  end

  def set_defaults<commit_msg>Use delete_all for dependent objects which executes a more efficient SQL delete statement<commit_after># Describes an eMOP batch job
#
class BatchJob < ActiveRecord::Base
  belongs_to :font
  belongs_to :ocr_engine
  belongs_to :job_type
  has_many :job_queues, foreign_key: 'batch_id', dependent: :delete_all
  has_many :page_results, foreign_key: 'batch_id', dependent: :delete_all
  has_many :postproc_pages, dependent: :delete_all
  has_many :work_ocr_results, foreign_key: 'batch_id'

  validates :name, presence: true

  after_initialize :set_defaults

  def self.default_ocr_engine
    OcrEngine.find_by_name('Tesseract')
  end

  def self.default_job_type
    JobType.find_by_name('OCR')
  end

  def set_defaults
{'fraction_non_alphanumeric': 0.07663964627855564, 'fraction_numerical': 0.0, 'mean_word_length': 5.5603864734299515, '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': '775938', 'n_tokens_mistral': 470, 'n_tokens_neox': 466, 'n_words': 113}