<commit_before>class BooksController < ApplicationController
  before_action :set_book, only: [:show, :edit, :update, :destroy, :loan, :renew]

  # GET /books
  # GET /books.json
  def index
    @books = Book.all
  end

  # GET /books/1
  # GET /books/1.json
  def show
  end

  # GET /books/new
  def new
    @book = Book.new
  end

  # GET /books/1/edit
  def edit
  end

  # POST /books
  # POST /books.json
  def create
    @book = Book.new(book_params)

    respond_to do |format|
      if @book.save
        format.html { redirect_to "/administrator", notice: 'Book was successfully created.' }
        format.json { render :show, status: :created, location: @book }
      else
        format.html { render :new }
        format.json { render json: @book.errors, status: :unprocessable_entity }
      end
    end
  end
  
  def renew
      return_date = @book.return + 30
      @book.update_attributes(return: @book.return + 30)
      respond_to do |format|
        if @book.update(book_params)
          format.html { redirect_to member_path notice: 'Book was successfully updated.' }
          format.json { render :show, status: :ok, location: @book }
        else
          format.html { render :edit }
          format.json { render json: @book.errors, status: :unprocessable_entity }
        end
      end
  end      
  
  def loan<commit_msg>fix bug<commit_after>class BooksController < ApplicationController
  before_action :set_book, only: [:show, :edit, :update, :destroy, :loan, :renew]

  # GET /books
  # GET /books.json
  def index
    @books = Book.all
  end

  # GET /books/1
  # GET /books/1.json
  def show
  end

  # GET /books/new
  def new
    @book = Book.new
  end

  # GET /books/1/edit
  def edit
  end

  # POST /books
  # POST /books.json
  def create
    @book = Book.new(book_params)
    @book.update_attributes(userid: -1)
    respond_to do |format|
      if @book.save
        format.html { redirect_to "/administrator", notice: 'Book was successfully created.' }
        format.json { render :show, status: :created, location: @book }
      else
        format.html { render :new }
        format.json { render json: @book.errors, status: :unprocessable_entity }
      end
    end
  end
  
  def renew
      return_date = @book.return + 30
      @book.update_attributes(return: @book.return + 30)
      respond_to do |format|
        if @book.update(book_params)
          format.html { redirect_to member_path notice: 'Book was successfully updated.' }
          format.json { render :show, status: :ok, location: @book }
        else
          format.html { render :edit }
          format.json { render json: @book.errors, status: :unprocessable_entity }
        end
      end
  end      
  
  def loan
{'fraction_non_alphanumeric': 0.10499453153481589, 'fraction_numerical': 0.005468465184104995, 'mean_word_length': 2.302045728038508, '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': '1062141', 'n_tokens_mistral': 890, 'n_tokens_neox': 862, 'n_words': 250}