<commit_before>class PresentedContentStoreWorker
  attr_reader :params, :request_uuid
  include Sidekiq::Worker
  include PerformAsyncInQueue

  HIGH_QUEUE = "content_store_high".freeze
  LOW_QUEUE = "content_store_low".freeze

  sidekiq_options queue: HIGH_QUEUE

  def perform(args = {})
    assign_attributes(args.deep_symbolize_keys)
    set_headers

    if params[:delete]
      delete_from_content_store
    else
      send_to_content_store
    end

    enqueue_dependencies
  rescue => e
    handle_error(e)
  end

private

  def send_to_content_store
    if content_item_id
      content_item_is_draft = (State.where(content_item_id: content_item_id).pluck(:name) == ["draft"])
      content_store_is_live = (content_store == Adapters::ContentStore)

      if content_item_is_draft && content_store_is_live
        raise CommandError.new(
          code: 500,
          message: "Will not send a draft content item to the live content store",
        )
      end

      base_path = presented_payload.fetch(:base_path)
      content_store.put_content_item(base_path, presented_payload)
    else
      base_path = payload.fetch(:base_path)
      content_store.put_content_item(base_path, payload)
    end<commit_msg>Don't perform safety check for every job<commit_after>class PresentedContentStoreWorker
  attr_reader :params, :request_uuid
  include Sidekiq::Worker
  include PerformAsyncInQueue

  HIGH_QUEUE = "content_store_high".freeze
  LOW_QUEUE = "content_store_low".freeze

  sidekiq_options queue: HIGH_QUEUE

  def perform(args = {})
    assign_attributes(args.deep_symbolize_keys)
    set_headers

    if params[:delete]
      delete_from_content_store
    else
      send_to_content_store
    end

    enqueue_dependencies
  rescue => e
    handle_error(e)
  end

private

  def send_to_content_store
    if content_item_id
      content_store_is_live = (content_store == Adapters::ContentStore)

      if content_store_is_live
        if State.where(content_item_id: content_item_id).pluck(:name) == ["draft"]
          raise CommandError.new(
            code: 500,
            message: "Will not send a draft content item to the live content store",
          )
        end
      end

      base_path = presented_payload.fetch(:base_path)
      content_store.put_content_item(base_path, presented_payload)
    else
      base_path = payload.fetch(:base_path)
      content_store.put_content_item(base_path, payload)
    end
{'fraction_non_alphanumeric': 0.06789366053169735, 'fraction_numerical': 0.00245398773006135, 'mean_word_length': 3.4880733944954128, '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': '4929969', 'n_tokens_mistral': 780, 'n_tokens_neox': 754, 'n_words': 153}