Module: Dbviewer::PaginationConcern
- Extended by:
- ActiveSupport::Concern
- Included in:
- TablesController
- Defined in:
- app/controllers/concerns/dbviewer/pagination_concern.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#calculate_total_pages(total_count, per_page) ⇒ Object
Calculate the total number of pages.
- #fetch_total_count(table_name, query_params) ⇒ Object
Instance Method Details
#calculate_total_pages(total_count, per_page) ⇒ Object
Calculate the total number of pages
30 31 32 |
# File 'app/controllers/concerns/dbviewer/pagination_concern.rb', line 30 def calculate_total_pages(total_count, per_page) (total_count.to_f / per_page).ceil end |
#fetch_total_count(table_name, query_params) ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/controllers/concerns/dbviewer/pagination_concern.rb', line 21 def fetch_total_count(table_name, query_params) if query_params.column_filters.present? && query_params.column_filters.values.any?(&:present?) fetch_filtered_record_count(table_name, query_params.column_filters) else fetch_table_record_count(table_name) end end |