Module: Dbviewer::TableOperations
- Extended by:
- ActiveSupport::Concern
- Included in:
- DatabaseOperations
- Defined in:
- app/controllers/concerns/dbviewer/table_operations.rb
Instance Method Summary collapse
-
#fetch_filtered_record_count(table_name, column_filters) ⇒ Object
Get filtered record count for a table.
-
#fetch_table_columns(table_name) ⇒ Object
Get column information for a specific table.
-
#fetch_table_metadata(table_name) ⇒ Object
Get table metadata for display (e.g., primary key, foreign keys, indexes).
-
#fetch_table_record_count(table_name) ⇒ Object
Get the total number of records in a table.
-
#fetch_table_records(table_name, query_params) ⇒ Object
Fetch records for a table with pagination and sorting.
-
#fetch_tables(include_record_counts = false) ⇒ Object
Fetch all tables with their stats By default, don’t include record counts for better performance on sidebar.
-
#safe_quote_table_name(table_name) ⇒ Object
Safely quote a table name, with fallback.
Instance Method Details
#fetch_filtered_record_count(table_name, column_filters) ⇒ Object
Get filtered record count for a table
33 34 35 |
# File 'app/controllers/concerns/dbviewer/table_operations.rb', line 33 def fetch_filtered_record_count(table_name, column_filters) database_manager.filtered_record_count(table_name, column_filters) end |
#fetch_table_columns(table_name) ⇒ Object
Get column information for a specific table
18 19 20 |
# File 'app/controllers/concerns/dbviewer/table_operations.rb', line 18 def fetch_table_columns(table_name) database_manager.table_columns(table_name) end |
#fetch_table_metadata(table_name) ⇒ Object
Get table metadata for display (e.g., primary key, foreign keys, indexes)
43 44 45 |
# File 'app/controllers/concerns/dbviewer/table_operations.rb', line 43 def (table_name) database_manager.(table_name) end |
#fetch_table_record_count(table_name) ⇒ Object
Get the total number of records in a table
23 24 25 |
# File 'app/controllers/concerns/dbviewer/table_operations.rb', line 23 def fetch_table_record_count(table_name) database_manager.table_count(table_name) end |
#fetch_table_records(table_name, query_params) ⇒ Object
Fetch records for a table with pagination and sorting
28 29 30 |
# File 'app/controllers/concerns/dbviewer/table_operations.rb', line 28 def fetch_table_records(table_name, query_params) database_manager.table_records(table_name, query_params) end |
#fetch_tables(include_record_counts = false) ⇒ Object
Fetch all tables with their stats By default, don’t include record counts for better performance on sidebar
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/concerns/dbviewer/table_operations.rb', line 7 def fetch_tables(include_record_counts = false) database_manager.tables.map do |table_name| table_stats = { name: table_name } table_stats[:record_count] = database_manager.record_count(table_name) if include_record_counts table_stats end end |
#safe_quote_table_name(table_name) ⇒ Object
Safely quote a table name, with fallback
38 39 40 |
# File 'app/controllers/concerns/dbviewer/table_operations.rb', line 38 def safe_quote_table_name(table_name) database_manager.connection.quote_table_name(table_name) rescue table_name.to_s end |