<commit_before>class GamesController < ApplicationController

  before_action :authenticate_user!
  def index
    @games = Game.paginate(page: params[:page], per_page: 20)
  end

  def new
    response = params[:selectImage]
    if response
      response.each do |igdb_game|
        game = json(igdb_game)
        @game = Game.new(game_params)
        @game.user = current_user
        @game.title= game['name']
        @game.url = game['cover']
        if current_user.games.where(:igdb_id => game['id']).present?
          flash[:error] = "You already have #{game['name']}"
        else
          @game.igdb_id = game['id']
          if @game.save
            flash[:success] = "Saved successfully"
          else
            flash[:error] = "Games not saved"
            redirect_to request.env["HTTP_REFERER"]
          end
        end<commit_msg>Show only available games at game index page<commit_after>class GamesController < ApplicationController

  before_action :authenticate_user!
  def index
    @games = Game.where(:mooch_user_id => nil).order("created_at").reverse_order.paginate(page: params[:page], per_page: 20)
  end

  def new
    response = params[:selectImage]
    if response
      response.each do |igdb_game|
        game = json(igdb_game)
        @game = Game.new(game_params)
        @game.user = current_user
        @game.title= game['name']
        @game.url = game['cover']
        if current_user.games.where(:igdb_id => game['id']).present?
          flash[:error] = "You already have #{game['name']}"
        else
          @game.igdb_id = game['id']
          if @game.save
            flash[:success] = "Saved successfully"
          else
            flash[:error] = "Games not saved"
            redirect_to request.env["HTTP_REFERER"]
          end
        end
{'fraction_non_alphanumeric': 0.11902113459399333, 'fraction_numerical': 0.002224694104560623, 'mean_word_length': 2.4007561436672966, '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': '4209915', 'n_tokens_mistral': 548, 'n_tokens_neox': 533, 'n_words': 121}