Class: RailsErrorDashboard::Commands::BatchDeleteErrors
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Commands::BatchDeleteErrors
- Defined in:
- lib/rails_error_dashboard/commands/batch_delete_errors.rb
Overview
Command: Delete multiple errors at once This is a write operation that destroys multiple ErrorLog records
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(error_ids) ⇒ BatchDeleteErrors
constructor
A new instance of BatchDeleteErrors.
Constructor Details
#initialize(error_ids) ⇒ BatchDeleteErrors
Returns a new instance of BatchDeleteErrors.
12 13 14 |
# File 'lib/rails_error_dashboard/commands/batch_delete_errors.rb', line 12 def initialize(error_ids) @error_ids = Array(error_ids).compact end |
Class Method Details
.call(error_ids) ⇒ Object
8 9 10 |
# File 'lib/rails_error_dashboard/commands/batch_delete_errors.rb', line 8 def self.call(error_ids) new(error_ids).call end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rails_error_dashboard/commands/batch_delete_errors.rb', line 16 def call return { success: false, count: 0, errors: [ "No error IDs provided" ] } if @error_ids.empty? errors = ErrorLog.where(id: @error_ids) count = errors.count error_ids_to_delete = errors.pluck(:id) errors.destroy_all # Dispatch plugin event for batch deleted errors PluginRegistry.dispatch(:on_errors_batch_deleted, error_ids_to_delete) if error_ids_to_delete.any? { success: true, count: count, total: @error_ids.size, errors: [] } rescue => e RailsErrorDashboard::Logger.error("Batch delete failed: #{e.}") { success: false, count: 0, total: @error_ids.size, errors: [ e. ] } end |