<commit_before>class Admin::BlogPostsController < Admin::BaseController
  def index
    @blog_posts = BlogPost.unscoped
  end

  def new
    @blog_post = BlogPost.new
  end

  def edit
    permitted = slug_params
    @blog_post = BlogPost.unscoped.find_blog_post!(permitted.fetch(:id))
  end

  def create
    @blog_post = BlogPost.new(blog_post_params)
    if @blog_post.save
      flash.notice = t('.flash_notice')
      redirect_to edit_admin_blog_post_path(@blog_post)
    else
      flash.alert = t('.flash_alert')
      render :action => :new
    end
  end

  def update
    permitted = slug_params
    @blog_post = BlogPost.unscoped.find_blog_post!(permitted.fetch(:id))
    if @blog_post.update(blog_post_params)
      flash[:notice] = t('.flash_notice')
      redirect_to admin_blog_posts_path
    else
      flash[:alert] = t('.flash_alert')
      render :action => :edit
    end
  end<commit_msg>refactored admin blog post controller<commit_after>class Admin::BlogPostsController < Admin::BaseController
  def index
    @blog_posts = BlogPost.unscoped
  end

  def new
    @blog_post = BlogPost.new
  end

  def edit
    @blog_post = BlogPost.unscoped.find_blog_post!(slug_params.fetch(:id))
  end

  def create
    @blog_post = BlogPost.new(blog_post_params)
    if @blog_post.save
      flash.notice = t('.flash_notice')
      redirect_to edit_admin_blog_post_path(@blog_post)
    else
      flash.alert = t('.flash_alert')
      render :action => :new
    end
  end

  def update
    @blog_post = BlogPost.unscoped.find_blog_post!(slug_params.fetch(:id))
    if @blog_post.update(blog_post_params)
      flash[:notice] = t('.flash_notice')
      redirect_to admin_blog_posts_path
    else
      flash[:alert] = t('.flash_alert')
      render :action => :edit
    end
  end
{'fraction_non_alphanumeric': 0.1019036954087346, 'fraction_numerical': 0.0, 'mean_word_length': 3.306024096385542, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5208380', 'n_tokens_mistral': 605, 'n_tokens_neox': 594, 'n_words': 115}