Class: RailsConsolePro::Services::IndexAnalyzer
- Inherits:
-
Object
- Object
- RailsConsolePro::Services::IndexAnalyzer
- Defined in:
- lib/rails_console_pro/services/index_analyzer.rb
Overview
Service for analyzing database index usage
Class Method Summary collapse
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(connection, table_name) ⇒ IndexAnalyzer
constructor
A new instance of IndexAnalyzer.
Constructor Details
#initialize(connection, table_name) ⇒ IndexAnalyzer
Returns a new instance of IndexAnalyzer.
11 12 13 14 |
# File 'lib/rails_console_pro/services/index_analyzer.rb', line 11 def initialize(connection, table_name) @connection = connection @table_name = table_name end |
Class Method Details
.analyze(connection, table_name) ⇒ Object
7 8 9 |
# File 'lib/rails_console_pro/services/index_analyzer.rb', line 7 def self.analyze(connection, table_name) new(connection, table_name).analyze end |
Instance Method Details
#analyze ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails_console_pro/services/index_analyzer.rb', line 16 def analyze return {} unless @table_name adapter_name = @connection.adapter_name.downcase index_usage = {} case adapter_name when /postgresql/ analyze_postgresql(index_usage) when /mysql/ analyze_mysql(index_usage) else analyze_fallback(index_usage) end index_usage rescue => e {} # Return empty hash on any error end |