<commit_before>class VersesController < ApplicationController

  def index
    @verses = Verse.paginate(
      :order => 'book, chapter, verse',
      :select => '*, (select count(*) from people_verses where verse_id = verses.id) as people_count',
      :page => params[:page]
    )
    @tags = Verse.tag_counts
  end
  
  def show
    @verse = Verse.find(params[:id])
  end

  def create
    if @verse = Verse.find(params[:id]) rescue nil
      unless @verse.people.include? @logged_in
        @verse.people << @logged_in
        @verse.create_as_stream_item(@logged_in)
      end
      expire_fragment(%r{views/people/#{@logged_in.id}_})
      redirect_to params[:redirect_to] || @verse
    else
      render :text => 'That verse could not be found. Did you type the reference correctly?', :layout => true, :status => 404
    end
  end
  
  def update
    @verse = Verse.find(params[:id])
    @verse.tag_list.remove(params[:remove_tag]) if params[:remove_tag]
    @verse.tag_list.add(*params[:add_tags].split) if params[:add_tags]
    @verse.save
    redirect_to @verse<commit_msg>Fix bug when invalid verse reference entered.<commit_after>class VersesController < ApplicationController

  def index
    @verses = Verse.paginate(
      :order => 'book, chapter, verse',
      :select => '*, (select count(*) from people_verses where verse_id = verses.id) as people_count',
      :page => params[:page]
    )
    @tags = Verse.tag_counts
  end
  
  def show
    @verse = Verse.find(params[:id])
  end

  def create
    if @verse = Verse.find(params[:id]) rescue nil and @verse.valid?
      unless @verse.people.include? @logged_in
        @verse.people << @logged_in
        @verse.create_as_stream_item(@logged_in)
      end
      expire_fragment(%r{views/people/#{@logged_in.id}_})
      redirect_to params[:redirect_to] || @verse
    else
      render :text => 'That verse could not be found. Did you type the reference correctly?', :layout => true, :status => 404
    end
  end
  
  def update
    @verse = Verse.find(params[:id])
    @verse.tag_list.remove(params[:remove_tag]) if params[:remove_tag]
    @verse.tag_list.add(*params[:add_tags].split) if params[:add_tags]
    @verse.save
    redirect_to @verse
{'fraction_non_alphanumeric': 0.12815884476534295, 'fraction_numerical': 0.002707581227436823, 'mean_word_length': 3.288201160541586, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '1992081', 'n_tokens_mistral': 731, 'n_tokens_neox': 718, 'n_words': 173}