<commit_before>class Spree::BlogEntriesController < Spree::StoreController
  helper 'spree/blog_entries' 
 
  rescue_from ActiveRecord::RecordNotFound, with: :render_404

  def show
    permalink = [params[:slug], params[:year], params[:month], params[:permalink]].join('/')
    if try_spree_current_user.try(:has_spree_role?, 'admin')
      @blog_entry = Spree::BlogEntry.find_by_permalink!(permalink)
    else
      # takes care of non-admin and logged out users
      @blog_entry = Spree::BlogEntry.includes(:blog).visible.published.find_by(permalink: permalink,
                                                                              spree_blogs: { enabled: true,
                                                                                             private: false } )
    end
    @title = @blog_entry.title
  end
end
<commit_msg>render 404 if blog post is not found + adding meta data<commit_after>class Spree::BlogEntriesController < Spree::StoreController
  helper 'spree/blog_entries' 
 
  rescue_from ActiveRecord::RecordNotFound, with: :render_404

  def show
    permalink = [params[:slug], params[:year], params[:month], params[:permalink]].join('/')
    if try_spree_current_user.try(:has_spree_role?, 'admin')
      @blog_entry = Spree::BlogEntry.find_by_permalink!(permalink)
    else
      # takes care of non-admin and logged out users
      @blog_entry = Spree::BlogEntry.includes(:blog).visible.published.find_by(permalink: permalink,
                                                                              spree_blogs: { enabled: true,
                                                                                             private: false } )
    end
    render_404 and return if @blog_entry.blank?
    @meta_title = @blog_entry.meta_title
    @meta_description = @blog_entry.meta_description
    @meta_keywords = @blog_entry.meta_keywords
  end
end

{'fraction_non_alphanumeric': 0.09398099260823653, 'fraction_numerical': 0.006335797254487857, 'mean_word_length': 2.127062706270627, '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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2005396', 'n_tokens_mistral': 522, 'n_tokens_neox': 500, 'n_words': 105}