<commit_before>class ProjectsController < ApplicationController
  before_action :find_project_friendly, only: [ :show, :edit, :update, :destroy, :popup_content, :new_secret ]
  before_action :authenticate_user!,    only: [ :create, :new ]
  before_action :authenticate_owner!,   only: [ :edit, :update, :destroy, :new_secret ]

  def index
    @page_title = t('nav.projects')
    @q = params[:q] unless params[:q].nil? or params[:q].empty?

    unless @q or (params[:page] and params[:page].to_i > 1)
      @welcome_textblock = TextBlock.block_for("welcome")
    end

    if (@q)
      projects = Project.publicly_visible
                              .includes(:participations, :owner, :category, :messages, category: [ :translations ])
                              .ransack(title_cont: @q,
                                       description_cont: @q,
                                       public: true,
                                       m: 'or',
                                       sort: 'date')
                              .result(distinct: true)
    else
      projects = Project.publicly_visible
                              .includes(:participations, :owner, :messages, category: [ :translations ])
                              .order(:date)
    end

    @projects = projects.paginate(page: params[:page])
  end
<commit_msg>projects: paginate with 20 objects per page<commit_after>class ProjectsController < ApplicationController
  before_action :find_project_friendly, only: [ :show, :edit, :update, :destroy, :popup_content, :new_secret ]
  before_action :authenticate_user!,    only: [ :create, :new ]
  before_action :authenticate_owner!,   only: [ :edit, :update, :destroy, :new_secret ]

  def index
    @page_title = t('nav.projects')
    @q = params[:q] unless params[:q].nil? or params[:q].empty?

    unless @q or (params[:page] and params[:page].to_i > 1)
      @welcome_textblock = TextBlock.block_for("welcome")
    end

    if (@q)
      projects = Project.publicly_visible
                              .includes(:participations, :owner, :category, :messages, category: [ :translations ])
                              .ransack(title_cont: @q,
                                       description_cont: @q,
                                       public: true,
                                       m: 'or',
                                       sort: 'date')
                              .result(distinct: true)
    else
      projects = Project.publicly_visible
                              .includes(:participations, :owner, :messages, category: [ :translations ])
                              .order(:date)
    end

    @projects = projects.paginate(page: params[:page], per_page: 20)
  end

{'fraction_non_alphanumeric': 0.1123718887262079, 'fraction_numerical': 0.0021961932650073207, 'mean_word_length': 1.7859327217125383, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '234653', 'n_tokens_mistral': 757, 'n_tokens_neox': 718, 'n_words': 168}