<commit_before>module Jellyfish
  class Provisioner
    attr_reader :order_item

    def self.provision(order_item_id)
      perform(order_item_id, :critical_error) { |order_item| new(order_item).provision }
    end

    def self.retire(order_item_id)
      perform(order_item_id, :warning_retirement_error) { |order_item| new(order_item).retire }
    end

    def initialize(order_item)
      @order_item = order_item
    end

    # private

    def self.perform(order_item_id, error_method)
      order_item = OrderItem.find(order_item_id)
      yield order_item
    rescue => e
      send(error_method, order_item, e.message)
      raise
    ensure
      order_item.save!
    end

    def self.warning_retirement_error(order_item, message)
      order_item.provision_status = :warning
      order_item.status_msg = "Retirement failed: #{message}"[0..254]
    end

    def self.critical_error(order_item, message)
      order_item.provision_status = :critical
      order_item.status_msg = message
    end
  end
end
<commit_msg>add details to jellyfish provisioner<commit_after>module Jellyfish
  class Provisioner
    attr_reader :order_item

    def self.provision(order_item_id)
      perform(order_item_id, :critical_error) { |order_item| new(order_item).provision }
    end

    def self.retire(order_item_id)
      perform(order_item_id, :warning_retirement_error) { |order_item| new(order_item).retire }
    end

    def initialize(order_item)
      @order_item = order_item
    end

    def details
      order_item.answers
    end

    def self.perform(order_item_id, error_method)
      order_item = OrderItem.find(order_item_id)
      yield order_item
    rescue => e
      send(error_method, order_item, e.message)
      raise
    ensure
      order_item.save!
    end

    def self.warning_retirement_error(order_item, message)
      order_item.provision_status = :warning
      order_item.status_msg = "Retirement failed: #{message}"[0..254]
    end

    def self.critical_error(order_item, message)
      order_item.provision_status = :critical
      order_item.status_msg = message
    end
  end
end

{'fraction_non_alphanumeric': 0.07743153918791312, 'fraction_numerical': 0.003777148253068933, 'mean_word_length': 3.3069105691056913, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1664015', 'n_tokens_mistral': 710, 'n_tokens_neox': 685, 'n_words': 131}