<commit_before>class Test < ActiveRecord::Base
  after_initialize :default_values
  after_create :create_key
  belongs_to :run
  default_scope { order('created_at ASC') }
  dragonfly_accessor :screenshot
  dragonfly_accessor :screenshot_baseline
  dragonfly_accessor :screenshot_diff
  validates :name, :browser, :platform, :width, :run, presence: true

  def self.find_by_key
    where(key: key)
  end

  def self.find_baseline_by_key(key)
    where(key: key, baseline: true).first
  end


  def pass?
    pass
  end

  def url
    "#{run.url}#test_#{id}"
  end

  def create_key
    self.key = "#{run.suite.project.name} #{run.suite.name} #{name} #{browser} #{platform} #{width}".parameterize
    self.save
  end

  private

  def default_values
    self.diff ||= 0
    self.baseline ||= false
    self.dimensions_changed ||= false
    self.pass ||= false
  end
end
<commit_msg>Add URL to model's JSON output<commit_after>class Test < ActiveRecord::Base
  after_initialize :default_values
  after_create :create_key
  belongs_to :run
  default_scope { order('created_at ASC') }
  dragonfly_accessor :screenshot
  dragonfly_accessor :screenshot_baseline
  dragonfly_accessor :screenshot_diff
  validates :name, :browser, :platform, :width, :run, presence: true

  def self.find_by_key
    where(key: key)
  end

  def self.find_baseline_by_key(key)
    where(key: key, baseline: true).first
  end

  def as_json(options)
    run = super(options)
    run[:url] = self.url
    return run
  end

  def pass?
    pass
  end

  def url
    "#{run.url}#test_#{id}"
  end

  def create_key
    self.key = "#{run.suite.project.name} #{run.suite.name} #{name} #{browser} #{platform} #{width}".parameterize
    self.save
  end

  private

  def default_values
    self.diff ||= 0
    self.baseline ||= false
    self.dimensions_changed ||= false
    self.pass ||= false
  end
end

{'fraction_non_alphanumeric': 0.11063602351683592, 'fraction_numerical': 0.0010689470871191875, 'mean_word_length': 3.656716417910448, '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': '4395266', 'n_tokens_mistral': 666, 'n_tokens_neox': 650, 'n_words': 154}