<commit_before>class InviteController < ActivePlayerController
  def index
  end

  def create
    @game = @active_player.games.find(params[:invite][:game_id])
    @player = Player.where(email: params[:invite][:email]).first_or_create
    @game_player = GameService.add_player(@game, @player)
    puts ">>> gp is #{@game_player.inspect}"
    send_invite
respond_to do |format|
    if @game_player
        format.html { redirect_to @game_player, notice: 'Invitation was successfully created.' }
        format.json { render json: @game_player, status: :created }
    else
      format.html { render :new }
      format.json { render json: @game_player.errors, status: :unprocessable_entity }
    end
end
  end

  def accept
    gp = GamePlayer.find_by_token(params[:token])
    gp.update(accepted: true)
    redirect_to play_game_path(gp.game)
  end

  private

  def send_invite
    NotifierMailer.invite(@game_player.player, @game_player.token).deliver_now
    puts "should send invite to #{params[:email]} with invite code of #{@game_player.token}"
  end

end
<commit_msg>default invite to false<commit_after>class InviteController < ActivePlayerController
  def index
  end

  def create
    @game = @active_player.games.find(params[:invite][:game_id])
    @player = Player.where(email: params[:invite][:email]).first_or_create
    @game_player = GameService.add_player(@game, @player)
    @game_player.accepted = false

    if @game_player.new_record?
      send_invite
    end

    respond_to do |format|
      if @game_player
          format.html { redirect_to @game_player, notice: 'Invitation was successfully created.' }
          format.json { render json: @game_player, status: :created }
      else
        format.html { render :new }
        format.json { render json: @game_player.errors, status: :unprocessable_entity }
      end
    end
  end

  def accept
    gp = GamePlayer.find_by_token(params[:token])
    gp.update(accepted: true)
    redirect_to play_game_path(gp.game)
  end

  private

  def send_invite
    NotifierMailer.invite(@game_player.player, @game_player.token).deliver_now
    puts "should send invite to #{params[:email]} with invite code of #{@game_player.token}"
  end

end

{'fraction_non_alphanumeric': 0.10393131495707185, 'fraction_numerical': 0.0, 'mean_word_length': 3.670886075949367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4315225', 'n_tokens_mistral': 711, 'n_tokens_neox': 696, 'n_words': 164}