<commit_before>class PlayersController < ApplicationController
  def index
    @game = Game.find(player_params[:game_id])
    @players = @game.players.all

    render json: @players
  end

  def create
    @game = Game.find(player_params[:game_id])

    join_game = JoinGame.new(@game, player_params[:handle])

    if join_game.call
      render json: @game, status: :created
    else
      render json: @game.errors, status: :unprocessable_entity
    end
  end
  private

  def player_params
    params.permit(:game_id, :handle)
  end
end
<commit_msg>Add players#show<commit_after>class PlayersController < ApplicationController
  def index
    @game = Game.find(player_params[:game_id])
    @players = @game.players.all

    render json: @players
  end

  def show
    @player = Player.find(params[:id])

    if @player.user == current_user
      render json: @player
    else
      render json: { error: "you are not authorized to view this player" }
    end
  end

  def create
    @game = Game.find(player_params[:game_id])

    join_game = JoinGame.new(@game, player_params[:handle])

    if join_game.call
      render json: @game, status: :created
    else
      render json: @game.errors, status: :unprocessable_entity
    end
  end
  private

  def player_params
    params.permit(:game_id, :handle)
  end
end

{'fraction_non_alphanumeric': 0.09772727272727273, 'fraction_numerical': 0.0, 'mean_word_length': 3.261290322580645, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1671882', 'n_tokens_mistral': 429, 'n_tokens_neox': 416, 'n_words': 109}