<commit_before>require_relative 'job_serializer'

module Workerholic
  class JobProcessingError < StandardError; end

  class JobProcessor
    def initialize(serialized_job)
      @serialized_job = serialized_job
    end

    def process
      job_info = JobSerializer.deserialize(@serialized_job)
      job_class = job_info[:class]
      job_args = job_info[:arguments]
      job_stats = job_info[:statistics]

      begin
        job_stats[:started_at] = Time.now
        finished_job = job_class.new.perform(*job_args)
        job_stats[:completed_at] = Time.now
        finished_job
      rescue Exception => e
        job_stats[:errors].push(e)
        raise JobProcessingError, e.message
      end

      # Push job into some collection
      # def record
      #
      # end
    end
  end
end<commit_msg>Minor clean-up, and adding increment retry count on failure<commit_after>require_relative 'job_serializer'

module Workerholic
  class JobProcessingError < StandardError; end

  class JobProcessor
    def initialize(serialized_job)
      @serialized_job = serialized_job
    end

    def process
      job_info = JobSerializer.deserialize(@serialized_job)
      job_class = job_info[:class]
      job_args = job_info[:arguments]
      job_stats = job_info[:statistics]

      begin
        job_stats[:started_at] = Time.now
        finished_job = job_class.new.perform(*job_args)
        job_stats[:completed_at] = Time.now
        finished_job
      rescue Exception => e
        job_stats[:errors].push(e)
        job_stats[:retry_count] += 1
        raise JobProcessingError, e.message
      end

      # Push job into some collection
    end
  end
end
{'fraction_non_alphanumeric': 0.07202881152460984, 'fraction_numerical': 0.0006002400960384153, 'mean_word_length': 2.832183908045977, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1960419', 'n_tokens_mistral': 496, 'n_tokens_neox': 485, 'n_words': 110}