lib/active_scaffold/finder.rb
# returns a Paginator::Page (not from ActiveRecord::Paginator) for the given parameters
# See finder_options for valid options
returns a Paginator::Page (not from ActiveRecord::Paginator) for the given parameters
See finder_options for valid options
returns a Paginator :: Page ( not from ActiveRecord :: Paginator ) for the given parameters See finder_options for valid options
def find_page(options = {})
      options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination, :select
      options[:per_page] ||= 999_999_999
      options[:page] ||= 1
      find_options = finder_options(options)
      query = beginning_of_chain.where(nil) 
      if options[:pagination] && options[:pagination] != :infinite
        count = count_items(query, find_options, options[:count_includes])
      end
      query = append_to_query(query, find_options)
      pager = if options[:sorting]&.sorts_by_method?
                ::Paginator.new(count, options[:per_page]) do |offset, per_page|
                  calculate_last_modified(query)
                  sorted_collection = sort_collection_by_column(query.to_a, *options[:sorting].first)
                  sorted_collection = sorted_collection.slice(offset, per_page) if options[:pagination]
                  sorted_collection
                end
              else
                ::Paginator.new(count, options[:per_page]) do |offset, per_page|
                  query = append_to_query(query, :offset => offset, :limit => per_page) if options[:pagination]
                  calculate_last_modified(query)
                  query
                end
              end
      pager.page(options[:page])
    end
def find_page ( options = { } ) options . assert_valid_keys :sorting , :per_page , :page , :count_includes , :pagination , :select options [ :per_page ] ||= 999_999_999 options [ :page ] ||= 1 find_options = finder_options ( options ) query = beginning_of_chain . where ( nil ) if options [ :pagination ] && options [ :pagination ] != :infinite count = count_items ( query , find_options , options [ :count_includes ] ) end query = append_to_query ( query , find_options ) pager = if options [ :sorting ] &. sorts_by_method? :: Paginator . new ( count , options [ :per_page ] ) do | offset , per_page | calculate_last_modified ( query ) sorted_collection = sort_collection_by_column ( query . to_a , * options [ :sorting ] . first ) sorted_collection = sorted_collection . slice ( offset , per_page ) if options [ :pagination ] sorted_collection end else :: Paginator . new ( count , options [ :per_page ] ) do | offset , per_page | query = append_to_query ( query , :offset => offset , :limit => per_page ) if options [ :pagination ] calculate_last_modified ( query ) query end end pager . page ( options [ :page ] ) end
returns a Paginator::Page (not from ActiveRecord::Paginator) for the given parameters
See finder_options for valid options
returns a Paginator :: Page ( not from ActiveRecord :: Paginator ) for the given parameters See finder_options for valid options
# where(nil) is needed because we need a relation # NOTE: we must use :include in the count query, because some conditions may reference other tables # we build the paginator differently for method- and sql-based sorting
options
<not_specific>