<commit_before>class MephistoController < ApplicationController
  session :off
  caches_page_with_references :list, :search, :show, :date

  def list
    if params[:sections].blank?
      @section = Section.find_by_name('home')
      list_section_articles_with(:main)
    else
      @section, page_name = Section.find_section_and_page_name(params[:sections])
      @section.show_paged_articles? ? show_section_page_with(page_name, :page) : list_section_articles_with(:section)
    end
  end

  def search
    conditions     = ['published_at <= :now AND title LIKE :q OR excerpt LIKE :q OR body LIKE :q', 
                     { :now => Time.now.utc, :q => "%#{params[:q]}%" }]
    @article_pages = Paginator.new self, Article.count(conditions), 15, params[:page]
    @articles      = Article.find(:all, :conditions => conditions, :order => 'published_at DESC',
                       :include => [:user, :sections],
                       :limit   =>  @article_pages.items_per_page,
                       :offset  =>  @article_pages.current.offset)

    render_liquid_template_for(:search, 'articles'      => @articles,
                                        'previous_page' => paged_search_url_for(@article_pages.current.previous),
                                        'next_page'     => paged_search_url_for(@article_pages.current.next))
  end

  def show
    @article  = Article.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
    @comments = @article.comments.collect { |c| c.to_liquid }
    self.cached_references << @article
    @article  = @article.to_liquid(:single)
    render_liquid_template_for(:single, 'articles' => [@article], 'article' => @article, 'comments' => @comments)
  end

  def day
    @articles = Article.find_all_by_published_date(params[:year], params[:month], params[:day], :include => [:user, :sections])
    render_liquid_template_for(:archive, 'articles' => @articles)
  end

  def month
    count = Article.count_by_published_date(params[:year], params[:month], params[:day])
    @article_pages = Paginator.new self, count, 15, params[:page]
    @articles = Article.find_all_by_published_date(params[:year], params[:month], params[:day],
                  :include => [:user, :sections],
                  :limit   =>  @article_pages.items_per_page,
                  :offset  =>  @article_pages.current.offset)
    render_liquid_template_for(:archive, 'articles'      => @articles,
                                         'previous_page' => paged_monthly_url_for(@article_pages.current.previous),
                                         'next_page'     => paged_monthly_url_for(@article_pages.current.next))
  end

  protected
  def list_section_articles_with(template_type)
    @article_pages = Paginator.new self, @section.articles.size, 15, params[:page]
    @articles      = @section.articles.find_by_date(
                       #:include => [:user, :sections],
                       :limit   =>  @article_pages.items_per_page,
                       :offset  =>  @article_pages.current.offset)

    self.cached_references << @section
    render_liquid_template_for(template_type, 'section'       => @section.name, 
                                              'section_title' => @section.title,
                                              'articles'      => @articles,
                                              'previous_page' => paged_section_url_for(@article_pages.current.previous),
                                              'next_page'     => paged_section_url_for(@article_pages.current.next))
  end

  def show_section_page_with(page_name, template_type)
    @article = page_name.nil? ? @section.articles.find_by_position : @section.articles.find_by_permalink(page_name)

    self.cached_references << @section << @article
    render_liquid_template_for(template_type, 'section'       => @section.name, 
                                              'section_title' => @section.title,
                                              'pages'         => @section.articles.collect { |a| a.to_liquid },
                                              'article'       => @article.to_liquid(:single))
  end
<commit_msg>eagerly load users on the homepage<commit_after>class MephistoController < ApplicationController
  session :off
  caches_page_with_references :list, :search, :show, :date

  def list
    if params[:sections].blank?
      @section = Section.find_by_name('home')
      list_section_articles_with(:main)
    else
      @section, page_name = Section.find_section_and_page_name(params[:sections])
      @section.show_paged_articles? ? show_section_page_with(page_name, :page) : list_section_articles_with(:section)
    end
  end

  def search
    conditions     = ['published_at <= :now AND title LIKE :q OR excerpt LIKE :q OR body LIKE :q', 
                     { :now => Time.now.utc, :q => "%#{params[:q]}%" }]
    @article_pages = Paginator.new self, Article.count(conditions), 15, params[:page]
    @articles      = Article.find(:all, :conditions => conditions, :order => 'published_at DESC',
                       :include => [:user, :sections],
                       :limit   =>  @article_pages.items_per_page,
                       :offset  =>  @article_pages.current.offset)

    render_liquid_template_for(:search, 'articles'      => @articles,
                                        'previous_page' => paged_search_url_for(@article_pages.current.previous),
                                        'next_page'     => paged_search_url_for(@article_pages.current.next))
  end

  def show
    @article  = Article.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
    @comments = @article.comments.collect { |c| c.to_liquid }
    self.cached_references << @article
    @article  = @article.to_liquid(:single)
    render_liquid_template_for(:single, 'articles' => [@article], 'article' => @article, 'comments' => @comments)
  end

  def day
    @articles = Article.find_all_by_published_date(params[:year], params[:month], params[:day], :include => [:user, :sections])
    render_liquid_template_for(:archive, 'articles' => @articles)
  end

  def month
    count = Article.count_by_published_date(params[:year], params[:month], params[:day])
    @article_pages = Paginator.new self, count, 15, params[:page]
    @articles = Article.find_all_by_published_date(params[:year], params[:month], params[:day],
                  :include => [:user, :sections],
                  :limit   =>  @article_pages.items_per_page,
                  :offset  =>  @article_pages.current.offset)
    render_liquid_template_for(:archive, 'articles'      => @articles,
                                         'previous_page' => paged_monthly_url_for(@article_pages.current.previous),
                                         'next_page'     => paged_monthly_url_for(@article_pages.current.next))
  end

  protected
  def list_section_articles_with(template_type)
    @article_pages = Paginator.new self, @section.articles.size, 15, params[:page]
    @articles      = @section.articles.find_by_date(
                       :include => [:user],
                       :limit   =>  @article_pages.items_per_page,
                       :offset  =>  @article_pages.current.offset)

    self.cached_references << @section
    render_liquid_template_for(template_type, 'section'       => @section.name, 
                                              'section_title' => @section.title,
                                              'articles'      => @articles,
                                              'previous_page' => paged_section_url_for(@article_pages.current.previous),
                                              'next_page'     => paged_section_url_for(@article_pages.current.next))
  end

  def show_section_page_with(page_name, template_type)
    @article = page_name.nil? ? @section.articles.find_by_position : @section.articles.find_by_permalink(page_name)

    self.cached_references << @section << @article
    render_liquid_template_for(template_type, 'section'       => @section.name, 
                                              'section_title' => @section.title,
                                              'pages'         => @section.articles.collect { |a| a.to_liquid },
                                              'article'       => @article.to_liquid(:single))
  end

{'fraction_non_alphanumeric': 0.11857566765578635, 'fraction_numerical': 0.00142433234421365, 'mean_word_length': 2.303018424147393, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5510606', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2274, 'n_words': 398}