Class: RailsAiContext::Introspectors::PerformanceIntrospector
- Inherits:
-
Object
- Object
- RailsAiContext::Introspectors::PerformanceIntrospector
- Defined in:
- lib/rails_ai_context/introspectors/performance_introspector.rb
Overview
Static analysis for common performance anti-patterns: N+1 query risks, missing counter_cache, Model.all in controllers, missing foreign key indexes.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(app) ⇒ PerformanceIntrospector
constructor
A new instance of PerformanceIntrospector.
Constructor Details
#initialize(app) ⇒ PerformanceIntrospector
Returns a new instance of PerformanceIntrospector.
11 12 13 |
# File 'lib/rails_ai_context/introspectors/performance_introspector.rb', line 11 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
9 10 11 |
# File 'lib/rails_ai_context/introspectors/performance_introspector.rb', line 9 def app @app end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_ai_context/introspectors/performance_introspector.rb', line 15 def call schema_data = load_schema_data model_data = load_model_data { n_plus_one_risks: detect_n_plus_one(model_data), missing_counter_cache: detect_missing_counter_cache(model_data, schema_data), missing_fk_indexes: detect_missing_fk_indexes(schema_data), model_all_in_controllers: detect_model_all_in_controllers, eager_load_candidates: detect_eager_load_candidates, summary: nil # populated below }.tap { |result| result[:summary] = build_summary(result) } rescue => e { error: e. } end |