<commit_before>module DelayedPaperclip
  module Attachment

    def self.included(base)
      base.send :include, InstanceMethods
      base.send :attr_accessor, :job_is_processing
      base.alias_method_chain :post_processing, :delay
      base.alias_method_chain :post_processing=, :delay
      base.alias_method_chain :save, :prepare_enqueueing
    end

    module InstanceMethods

      def delayed_options
        options[:delayed]
      end

      # Attr accessor in Paperclip
      def post_processing_with_delay
        !delay_processing? || split_processing?
      end

      def post_processing_with_delay=(value)
        @post_processing_with_delay = value
      end

      # if nil, returns whether it has delayed options
      # if set, then it returns
      def delay_processing?
        if @post_processing_with_delay.nil?
          !!delayed_options
        else
          !@post_processing_with_delay
        end
      end

      def split_processing?
        options[:only_process] && delayed_options &&
          options[:only_process] != delayed_only_process
      end

      def processing?
        column_name = :"#{@name}_processing?"
        @instance.respond_to?(column_name) && @instance.send(column_name)
      end

      def processing_style?(style)
        return false if !processing?

        !split_processing? || delayed_only_process.include?(style)
      end

      def delayed_only_process
        only_process = delayed_options[:only_process].dup
        only_process = only_process.call(self) if only_process.respond_to?(:call)
        only_process.map(&:to_sym)
      end

      def process_delayed!
        self.job_is_processing = true
        self.post_processing = true
        reprocess!(*delayed_only_process)
        self.job_is_processing = false
        update_processing_column
      end

      def processing_image_url
        processing_image_url = delayed_options[:processing_image_url]
        processing_image_url = processing_image_url.call(self) if processing_image_url.respond_to?(:call)
        processing_image_url<commit_msg>added byebug at attachment file<commit_after>module DelayedPaperclip
  module Attachment

    def self.included(base)
      base.send :include, InstanceMethods
      base.send :attr_accessor, :job_is_processing
      base.alias_method_chain :post_processing, :delay
      base.alias_method_chain :post_processing=, :delay
      base.alias_method_chain :save, :prepare_enqueueing
    end

    module InstanceMethods

      def delayed_options
        byebug
        options[:delayed]
      end

      # Attr accessor in Paperclip
      def post_processing_with_delay
        !delay_processing? || split_processing?
      end

      def post_processing_with_delay=(value)
        @post_processing_with_delay = value
      end

      # if nil, returns whether it has delayed options
      # if set, then it returns
      def delay_processing?
        if @post_processing_with_delay.nil?
          !!delayed_options
        else
          !@post_processing_with_delay
        end
      end

      def split_processing?
        options[:only_process] && delayed_options &&
          options[:only_process] != delayed_only_process
      end

      def processing?
        column_name = :"#{@name}_processing?"
        @instance.respond_to?(column_name) && @instance.send(column_name)
      end

      def processing_style?(style)
        return false if !processing?

        !split_processing? || delayed_only_process.include?(style)
      end

      def delayed_only_process
        byebug
        only_process = delayed_options[:only_process].dup
        byebug
        only_process = only_process.call(self) if only_process.respond_to?(:call)
        byebug
        only_process.map(&:to_sym)
      end

      def process_delayed!
        self.job_is_processing = true
        self.post_processing = true
        reprocess!(*delayed_only_process)
        self.job_is_processing = false
        update_processing_column
      end

      def processing_image_url
        processing_image_url = delayed_options[:processing_image_url]
        processing_image_url = processing_image_url.call(self) if processing_image_url.respond_to?(:call)
        processing_image_url
{'fraction_non_alphanumeric': 0.06685499058380415, 'fraction_numerical': 0.0, 'mean_word_length': 2.73702726473175, 'pattern_counts': {'":': 0, '<': 3, '<?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': '911504', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1184, 'n_words': 241}