Class: RailsErrorDashboard::Application
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- RailsErrorDashboard::Application
- Defined in:
- app/models/rails_error_dashboard/application.rb
Class Method Summary collapse
-
.find_or_create_by_name(name) ⇒ Object
Class method for finding or creating with caching Only caches successful finds, not creates (to avoid caching nil on creation failures).
Instance Method Summary collapse
-
#error_count ⇒ Object
Instance methods.
- #unresolved_error_count ⇒ Object
Class Method Details
.find_or_create_by_name(name) ⇒ Object
Class method for finding or creating with caching Only caches successful finds, not creates (to avoid caching nil on creation failures)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/rails_error_dashboard/application.rb', line 16 def self.find_or_create_by_name(name) # Try to find in cache or database first cached = Rails.cache.read("error_dashboard/application/#{name}") return cached if cached # Try to find existing found = find_by(name: name) if found Rails.cache.write("error_dashboard/application/#{name}", found, expires_in: 1.hour) return found end # Create if not found (don't cache until successful) created = create!(name: name) Rails.cache.write("error_dashboard/application/#{name}", created, expires_in: 1.hour) created end |
Instance Method Details
#error_count ⇒ Object
Instance methods
35 36 37 |
# File 'app/models/rails_error_dashboard/application.rb', line 35 def error_count error_logs.count end |
#unresolved_error_count ⇒ Object
39 40 41 |
# File 'app/models/rails_error_dashboard/application.rb', line 39 def unresolved_error_count error_logs.unresolved.count end |