<commit_before>require 'cgi'

def index_response(resource, count)
  {
    :total_count => count,
    :has_more => false,
    :object => 'list',
    :data => build_list(resource.to_sym, count)
  }.to_json
end

def handle_test_response(stub)
  if BlockScore::StubbedResponse::Error::MAP.key?(stub.id)
    BlockScore::StubbedResponse::Error.new(stub.id).response
  else
    status = response_status stub.action, stub.http_method
    body = response_body stub.id, stub.action, stub.factory_name, stub.query_params, stub.http_method

    build_test_response status, body
  end
end

def response_status(action, http_method)
  if http_method == :post && action.nil?
    201
  else
    200
  end
end<commit_msg>fixup! Refactor list stubbed responses<commit_after>def handle_test_response(stub)
  if BlockScore::StubbedResponse::Error::MAP.key?(stub.id)
    BlockScore::StubbedResponse::Error.new(stub.id).response
  else
    status = response_status stub.action, stub.http_method
    body = response_body stub.id, stub.action, stub.factory_name, stub.query_params, stub.http_method

    build_test_response status, body
  end
end

def response_status(action, http_method)
  if http_method == :post && action.nil?
    201
  else
    200
  end
end
{'fraction_non_alphanumeric': 0.10509296685529507, 'fraction_numerical': 0.009700889248181084, 'mean_word_length': 4.477876106194691, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1040799', 'n_tokens_mistral': 416, 'n_tokens_neox': 415, 'n_words': 87}