<commit_before>defmodule RemoteRetroWeb.RetroController do
  use RemoteRetroWeb, :controller
  alias RemoteRetro.{Retro, Participation, Idea, User}
  alias RemoteRetroWeb.ErrorView
  alias Phoenix.Token

  plug :verify_retro_id_param_is_uuid when action in [:show]

  def index(conn, _params) do
    current_user_id = get_session(conn, "current_user_id")
    current_user = Repo.get!(User, current_user_id)

    render(conn, "index.html", %{
      current_user: current_user,
      retros: recent_retros_with_action_items_preloaded(current_user),
    })
  end

  def show(conn, params) do
    current_user_id = get_session(conn, "current_user_id")
    current_user = Repo.get!(User, current_user_id)

    soft_insert_participation_record!(current_user.id, params["id"])

    render(conn, "show.html", %{
      user_token: Token.sign(conn, "user", current_user),
      retro_uuid: params["id"],
      include_js: true,
    })
  end

  def create(conn, params) do
    current_user_id = get_session(conn, "current_user_id")
<commit_msg>Perf: remove redundant db calls for current_user in RetroController actions<commit_after>defmodule RemoteRetroWeb.RetroController do
  use RemoteRetroWeb, :controller
  alias RemoteRetro.{Retro, Participation, Idea}
  alias RemoteRetroWeb.ErrorView
  alias Phoenix.Token

  plug :verify_retro_id_param_is_uuid when action in [:show]

  def index(conn, _params) do
    %{current_user: current_user} = conn.assigns

    render(conn, "index.html", %{
      current_user: current_user,
      retros: recent_retros_with_action_items_preloaded(current_user),
    })
  end

  def show(conn, params) do
    %{current_user: current_user} = conn.assigns

    soft_insert_participation_record!(current_user.id, params["id"])

    render(conn, "show.html", %{
      user_token: Token.sign(conn, "user", current_user),
      retro_uuid: params["id"],
      include_js: true,
    })
  end

  def create(conn, params) do
    current_user_id = get_session(conn, "current_user_id")

{'fraction_non_alphanumeric': 0.1031031031031031, 'fraction_numerical': 0.0, 'mean_word_length': 4.537396121883656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6608983', 'n_tokens_mistral': 684, 'n_tokens_neox': 665, 'n_words': 138}