<commit_before>defmodule MicrocrawlerWebapp.Couchbase do
  require Logger

  def add(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.add(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/add", json
    end
  end

  def append(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.append(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/append", json
    end
  end

  def get(id) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.get(#{inspect(id)})")
    HTTPoison.get! url_doc_id(id)
  end

  def get!(id) do
    case Poison.decode(get(id).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  def prepend(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.prepend(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/prepend", json
    end
  end

  def remove(id) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.remove(#{inspect(id)})")
    HTTPoison.delete! url_doc_id(id)
  end

  def replace(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.replace(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/replace", json
    end
  end

  def set(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.set(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/set", json
    end
  end

  def upsert(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.upsert(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/upsert", json
    end
  end

  defp bucket do<commit_msg>Add bang! version of functions<commit_after>defmodule MicrocrawlerWebapp.Couchbase do
  require Logger

  def add(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.add(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/add", json
    end
  end

  def add!(id, doc) do
    case Poison.decode(add(id, doc).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  def append(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.append(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/append", json
    end
  end

  def append!(id, doc) do
    case Poison.decode(append(id, doc).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  def get(id) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.get(#{inspect(id)})")
    HTTPoison.get! url_doc_id(id)
  end

  def get!(id) do
    case Poison.decode(get(id).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  def prepend(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.prepend(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/prepend", json
    end
  end

  def prepend!(id, doc) do
    case Poison.decode(prepend(id, doc).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  def remove(id) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.remove(#{inspect(id)})")
    HTTPoison.delete! url_doc_id(id)
  end

  def remove!(id) do
    case Poison.decode(remove(id).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  def replace(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.replace(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/replace", json
    end
  end

  def replace!(id, doc) do
    case Poison.decode(replace(id, doc).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  def set(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.set(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/set", json
    end
  end

  def set!(id, doc) do
    case Poison.decode(set(id, doc).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  def upsert(id, doc) do
    Logger.debug("MicrocrawlerWebapp.Couchbase.upsert(#{inspect(id)})")
    case Poison.encode(doc) do
      {:ok, json} -> HTTPoison.post! "#{url_doc_id(id)}/upsert", json
    end
  end

  def upsert!(id, doc) do
    case Poison.decode(upsert(id, doc).body) do
      {:ok, res} ->
        res
      _ -> nil
    end
  end

  defp bucket do
{'fraction_non_alphanumeric': 0.15667789001122334, 'fraction_numerical': 0.0, 'mean_word_length': 2.844693701466782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '4874938', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1733, 'n_words': 347}