Class: Lyra::StateAnalyzer
- Inherits:
-
Object
- Object
- Lyra::StateAnalyzer
- Defined in:
- lib/lyra/dual_view.rb
Overview
Analysis tools
Class Method Summary collapse
Class Method Details
.analyze(model_class, model_id) ⇒ Object
201 202 203 204 205 206 207 208 209 |
# File 'lib/lyra/dual_view.rb', line 201 def self.analyze(model_class, model_id) view = DualView.new(model_class, model_id) { comparison: view.compare, audit_trail: view.audit_trail, recommendations: generate_recommendations(view) } end |
.generate_recommendations(view) ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/lyra/dual_view.rb', line 211 def self.generate_recommendations(view) comparison = view.compare recommendations = [] if comparison[:differences][:exists_mismatch] recommendations << "State existence mismatch - investigate data consistency" end if comparison[:differences] != { no_differences: true } && !comparison[:differences][:exists_mismatch] recommendations << "Attribute differences detected - consider which source is authoritative" recommendations << "Differences: #{comparison[:differences].keys.join(', ')}" end if comparison[:event_sourced_view][:events_count] == 0 && comparison[:crud_view][:exists] recommendations << "CRUD record exists but no events found - may have been created before Lyra was enabled" end recommendations end |