<commit_before>module Adminpanel
  class Image < ActiveRecord::Base
    include Adminpanel::Base

    belongs_to :model, polymorphic: true

    before_save :store_file_size_and_content_type
    after_save :delete_old_unused_images
    before_destroy :remove_attachment
  
    private
      def remove_attachment
        self.remove_file!
      end
    
      def store_file_size_and_content_type
        if file.present? && file_changed?
          self.content_type = file.file.content_type
          self.file_size = file.file.size
        end
      end

      def delete_old_unused_images
        self.class.where('`created_at` < (?)', Time.now - 30.minutes).delete_all(
          model_id: nil,
          model_type: nil,
          type: self.type,
        )
      end
  end
end
<commit_msg>Specify the column and table name on callback<commit_after>module Adminpanel
  class Image < ActiveRecord::Base
    include Adminpanel::Base

    belongs_to :model, polymorphic: true

    before_save :store_file_size_and_content_type
    after_save :delete_old_unused_images
    before_destroy :remove_attachment
  
    private
      def remove_attachment
        self.remove_file!
      end
    
      def store_file_size_and_content_type
        if file.present? && file_changed?
          self.content_type = file.file.content_type
          self.file_size = file.file.size
        end
      end

      def delete_old_unused_images
        self.class.where('"adminpanel_images"."created_at" < (?)', Time.now - 30.minutes).delete_all(
          model_id: nil,
          model_type: nil,
          type: self.type,
        )
      end
  end
end

{'fraction_non_alphanumeric': 0.06890243902439025, 'fraction_numerical': 0.0024390243902439024, 'mean_word_length': 2.4258872651356995, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3284652', 'n_tokens_mistral': 505, 'n_tokens_neox': 491, 'n_words': 101}