<commit_before>class CheckoutlistsController < ApplicationController
  before_filter :check_librarian
  load_and_authorize_resource

  def index
    @selected_circulation_ids = params[:circulation_status].map{|s| s.to_i} if params[:circulation_status]
    if params[:pdf] || params[:tsv]
      @displist = []
      if params[:circulation_status].blank?
        flash[:notice] = t('item_list.no_list_condition')
        return
      end
      send_data Checkoutlist.get_checkoutlist('pdf', @selected_circulation_ids).generate, :filename => Setting.checkoutlist_report_pdf.filename if params[:pdf]
      send_data Checkoutlist.get_checkoutlist('tsv', @selected_circulation_ids), :filename => Setting.checkoutlist_report_tsv.filename if params[:tsv]
    else
      @circulation_status = CirculationStatus.all
      @item_nums = Hash.new
      selected_circulation_ids = @selected_circulation_ids ||= @circulation_status.map(&:id)
      @circulation_status.each do |c|
        @item_nums[c.display_name.localize] = Item.count_by_sql(["select count(*) from items where circulation_status_id = ?", c.id])
      end
      search = Sunspot.new_search(Item) #.include([:shelf => :library])
      per_page = Item.default_per_page
      set_role_query(current_user, search)
      search.build do
        with(:circulation_status_id).any_of selected_circulation_ids if selected_circulation_ids
        order_by(:circulation_status_id, :asc)
      end
      @items = search.execute.results
    end
  end
end
<commit_msg>refs 5279 paginate for checkoutlists<commit_after>class CheckoutlistsController < ApplicationController
  before_filter :check_librarian
  load_and_authorize_resource

  def index
    @selected_circulation_ids = params[:circulation_status].map{|s| s.to_i} if params[:circulation_status]
    if params[:pdf] || params[:tsv]
      @displist = []
      if params[:circulation_status].blank?
        flash[:notice] = t('item_list.no_list_condition')
        return
      end
      send_data Checkoutlist.get_checkoutlist('pdf', @selected_circulation_ids).generate, :filename => Setting.checkoutlist_report_pdf.filename if params[:pdf]
      send_data Checkoutlist.get_checkoutlist('tsv', @selected_circulation_ids), :filename => Setting.checkoutlist_report_tsv.filename if params[:tsv]
    else
      @circulation_status = CirculationStatus.all
      @item_nums = Hash.new
      selected_circulation_ids = @selected_circulation_ids ||= @circulation_status.map(&:id)
      @circulation_status.each do |c|
        @item_nums[c.display_name.localize] = Item.count_by_sql(["select count(*) from items where circulation_status_id = ?", c.id])
      end
      search = Sunspot.new_search(Item) #.include([:shelf => :library])
      per_page = Item.default_per_page
      page = params[:page].try(:to_i) || 1
      set_role_query(current_user, search)
      search.build do
        with(:circulation_status_id).any_of selected_circulation_ids if selected_circulation_ids
        order_by(:circulation_status_id, :asc)
        paginate :page => page, :per_page => per_page
      end
      @items = search.execute.results
    end
  end
end

{'fraction_non_alphanumeric': 0.10242501595405233, 'fraction_numerical': 0.001595405232929164, 'mean_word_length': 4.207641196013289, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1204086', 'n_tokens_mistral': 1019, 'n_tokens_neox': 972, 'n_words': 170}