Module: Dbviewer::DatabaseOperations::DatatableOperations
- Extended by:
- ActiveSupport::Concern
- Included in:
- Dbviewer::DatabaseOperations
- Defined in:
- app/controllers/concerns/dbviewer/database_operations/datatable_operations.rb
Instance Method Summary collapse
-
#fetch_datatable_data(table_name, query_params) ⇒ Object
Consolidated method to fetch all datatable-related data in one call Returns a hash containing all necessary datatable information.
- #fetch_table_stats(table_name) ⇒ Object
Instance Method Details
#fetch_datatable_data(table_name, query_params) ⇒ Object
Consolidated method to fetch all datatable-related data in one call Returns a hash containing all necessary datatable information
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/concerns/dbviewer/database_operations/datatable_operations.rb', line 8 def fetch_datatable_data(table_name, query_params) columns = fetch_table_columns(table_name) total_count = fetch_table_record_count(table_name, query_params.column_filters) records = fetch_table_records(table_name, query_params) = (table_name) { columns: columns, records: records, total_count: total_count, total_pages: total_count > 0 ? (total_count.to_f / query_params.per_page).ceil : 0, metadata: , current_page: query_params.page, per_page: query_params.per_page, order_by: query_params.order_by, direction: query_params.direction } end |
#fetch_table_stats(table_name) ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/concerns/dbviewer/database_operations/datatable_operations.rb', line 28 def fetch_table_stats(table_name) { table_name: table_name, columns: fetch_table_columns(table_name), metadata: (table_name) } end |