<commit_before>class ItemsController < ApplicationController
  def index
    @items = Item.all
  end

  def new
    if current_user && current_user.admin
      @item = Item.new
    else
      redirect_to root_path
    end
  end

  def create
    item_params
    @item = Item.new(item_params)
    if @item.save
      redirect_to @item
    else
      render 'new'
    end
  end

  def show
    find_item
    if !@item
      redirect_to root_path
    end
  end

  def edit
    find_item
  end
<commit_msg>Add conditional so that only admin users can trigger the ItemsController#create<commit_after>class ItemsController < ApplicationController
  def index
    @items = Item.all
  end

  def new
    if current_user && current_user.admin
      @item = Item.new
    else
      redirect_to root_path
    end
  end

  def create
    if current_user && current_user.admin
      item_params
      @item = Item.new(item_params)
      if @item.save
        redirect_to @item
      else
        render 'new'
      end
    else
      redirect_to root_path
    end
  end

  def show
    find_item
    if !@item
      redirect_to root_path
    end
  end

  def edit
    find_item
  end

{'fraction_non_alphanumeric': 0.04611443210930828, 'fraction_numerical': 0.0, 'mean_word_length': 2.1005291005291005, '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': '109735', 'n_tokens_mistral': 378, 'n_tokens_neox': 365, 'n_words': 111}