<commit_before>class Photo < ActiveRecord::Base

  IMAGE_OPTIONS = {
    :styles => { :tiny => "48x48#", :thumb => "128x128#", :brief => "256x256#", :full => "900x600" },
    :url    => "/assets/photos/:photo_id/:style.jpg",
    :path   => ":rails_root/public/assets/photos/:photo_id/:style.jpg" }

  belongs_to :album, :counter_cache => true
  has_attached_file :image, IMAGE_OPTIONS

  acts_as_commentable

  scope :with_image, where("image_file_name IS NOT NULL")
  scope :unnotified, where(:notified => false)

  before_save :normalize_title
  after_save :destroy_original

  private

  def notified!
    self.notified = true
    save!
  end
  
  def normalize_title
    self.title = "Untitled" if self.title.blank?
  end

  def destroy_original
    File.unlink(self.image.path)
  end
  
end<commit_msg>Removing originals only if they are present<commit_after>class Photo < ActiveRecord::Base

  IMAGE_OPTIONS = {
    :styles => { :tiny => "48x48#", :thumb => "128x128#", :brief => "256x256#", :full => "900x600" },
    :url    => "/assets/photos/:photo_id/:style.jpg",
    :path   => ":rails_root/public/assets/photos/:photo_id/:style.jpg" }

  belongs_to :album, :counter_cache => true
  has_attached_file :image, IMAGE_OPTIONS

  acts_as_commentable

  scope :with_image, where("image_file_name IS NOT NULL")
  scope :unnotified, where(:notified => false)

  before_save :normalize_title
  after_save :destroy_original

  def notified!
    self.notified = true
    save!
  end
  
  private

  def normalize_title
    self.title = "Untitled" if self.title.blank?
  end

  def destroy_original
    File.unlink(self.image.path) if File.exists?(self.image.path)
  end
  
end
{'fraction_non_alphanumeric': 0.12999403697078116, 'fraction_numerical': 0.02623732856290996, 'mean_word_length': 3.7942857142857145, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 21, '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': '7616402', 'n_tokens_mistral': 634, 'n_tokens_neox': 588, 'n_words': 123}