Class: RailsErrorDashboard::ErrorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_error_dashboard/errors_controller.rb

Constant Summary collapse

FILTERABLE_PARAMS =
%i[
  error_type
  unresolved
  platform
  application_id
  search
  severity
  timeframe
  frequency
  status
  assigned_to
  assignee_name
  priority_level
  hide_snoozed
  hide_muted
  reopened
  sort_by
  sort_direction
].freeze

Instance Method Summary collapse

Instance Method Details

#actioncable_health_summaryObject



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 460

def actioncable_health_summary
  unless RailsErrorDashboard.configuration.enable_actioncable_tracking &&
         RailsErrorDashboard.configuration.enable_breadcrumbs
    flash[:alert] = "ActionCable tracking is not enabled. Enable enable_actioncable_tracking and enable_breadcrumbs in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::ActionCableSummary.call(days, application_id: @current_application_id)
  all_channels = result[:channels]

  # Summary stats (computed before pagination)
  @unique_channels = all_channels.size
  @total_events = all_channels.sum { |c| c[:total_events] }
  @total_rejections = all_channels.sum { |c| c[:rejection_count] }

  @pagy, @channels = pagy(:offset, all_channels, limit: params[:per_page] || 25)
end

#activestorage_health_summaryObject



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 481

def activestorage_health_summary
  unless RailsErrorDashboard.configuration.enable_activestorage_tracking &&
         RailsErrorDashboard.configuration.enable_breadcrumbs
    flash[:alert] = "ActiveStorage tracking is not enabled. Enable enable_activestorage_tracking and enable_breadcrumbs in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::ActiveStorageSummary.call(days, application_id: @current_application_id)
  all_services = result[:services]

  # Summary stats (computed before pagination)
  @unique_services = all_services.size
  @total_operations = all_services.sum { |s| s[:total_operations] }
  @errors_with_storage = all_services.sum { |s| s[:error_count] }

  @pagy, @services = pagy(:offset, all_services, limit: params[:per_page] || 25)
end

#analyticsObject



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 173

def analytics
  days = (params[:days] || 30).to_i
  @days = days

  # Use Query to get analytics data (pass application filter)
  analytics = Queries::AnalyticsStats.call(days, application_id: @current_application_id)

  @error_stats = analytics[:error_stats]
  @errors_over_time = analytics[:errors_over_time]
  @errors_by_type = analytics[:errors_by_type]
  @errors_by_platform = analytics[:errors_by_platform]
  @errors_by_hour = analytics[:errors_by_hour]
  @top_users = analytics[:top_users]
  @resolution_rate = analytics[:resolution_rate]
  @mobile_errors = analytics[:mobile_errors]
  @api_errors = analytics[:api_errors]

  # Get recurring issues data (pass application filter)
  recurring = Queries::RecurringIssues.call(days, application_id: @current_application_id)
  @recurring_data = recurring

  # Get release correlation data (pass application filter)
  correlation = Queries::ErrorCorrelation.new(days: days, application_id: @current_application_id)
  @errors_by_version = correlation.errors_by_version
  @problematic_releases = correlation.problematic_releases
  @release_comparison = calculate_release_comparison

  # Get MTTR data (pass application filter)
  mttr_data = Queries::MttrStats.call(days, application_id: @current_application_id)
  @mttr_stats = mttr_data
  @overall_mttr = mttr_data[:overall_mttr]
  @mttr_by_platform = mttr_data[:mttr_by_platform]
end

#assignObject

Phase 3: Workflow Integration Actions (via Commands)



109
110
111
112
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 109

def assign
  @error = Commands::AssignError.call(params[:id], assigned_to: params[:assigned_to])
  redirect_to error_path(@error, **app_context_params)
end

#batch_actionObject



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 231

def batch_action
  error_ids = params[:error_ids] || []
  action_type = params[:action_type]

  result = case action_type
  when "resolve"
    Commands::BatchResolveErrors.call(
      error_ids,
      resolved_by_name: params[:resolved_by_name],
      resolution_comment: params[:resolution_comment]
    )
  when "mute"
    Commands::BatchMuteErrors.call(error_ids, muted_by: params[:muted_by], reason: params[:reason])
  when "unmute"
    Commands::BatchUnmuteErrors.call(error_ids)
  when "delete"
    Commands::BatchDeleteErrors.call(error_ids)
  else
    { success: false, count: 0, errors: [ "Invalid action type" ] }
  end

  if result[:success]
    flash[:notice] = "Successfully #{action_type}d #{result[:count]} error(s)"
  else
    flash[:alert] = "Batch operation failed: #{result[:errors].join(', ')}"
  end

  redirect_to errors_path(**app_context_params)
end

#cache_health_summaryObject



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 342

def cache_health_summary
  unless RailsErrorDashboard.configuration.enable_breadcrumbs
    flash[:alert] = "Breadcrumbs are not enabled. Enable them in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::CacheHealthSummary.call(days, application_id: @current_application_id)
  all_entries = result[:entries]

  # Summary stats (computed before pagination)
  @errors_with_cache = all_entries.size
  non_nil_rates = all_entries.map { |e| e[:hit_rate] }.compact
  @avg_hit_rate = non_nil_rates.any? ? (non_nil_rates.sum / non_nil_rates.size).round(1) : nil
  @total_cache_ops = all_entries.sum { |e| e[:reads] + e[:writes] }

  @pagy, @entries = pagy(:offset, all_entries, limit: params[:per_page] || 25)
end

#correlationObject



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 261

def correlation
  # Check if feature is enabled
  unless RailsErrorDashboard.configuration.enable_error_correlation
    flash[:alert] = "Error Correlation is not enabled. Enable it in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  correlation = Queries::ErrorCorrelation.new(days: days, application_id: @current_application_id)

  @errors_by_version = correlation.errors_by_version
  @errors_by_git_sha = correlation.errors_by_git_sha
  @problematic_releases = correlation.problematic_releases
  @multi_error_users = correlation.multi_error_users(min_error_types: 2)
  @time_correlated_errors = correlation.time_correlated_errors
  @period_comparison = correlation.period_comparison
  @platform_specific_errors = correlation.platform_specific_errors
end

#create_diagnostic_dumpObject



516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 516

def create_diagnostic_dump
  unless RailsErrorDashboard.configuration.enable_diagnostic_dump
    flash[:alert] = "Diagnostic dumps are not enabled."
    redirect_to errors_path(**app_context_params)
    return
  end

  dump = Services::DiagnosticDumpGenerator.call

  app_name = RailsErrorDashboard.configuration.application_name ||
             ENV["APPLICATION_NAME"] ||
             (defined?(Rails) && Rails.application.class.module_parent_name) ||
             "Unknown"
  app = Commands::FindOrCreateApplication.call(app_name)

  DiagnosticDump.create!(
    application_id: app.id,
    dump_data: dump.to_json,
    captured_at: Time.current,
    note: params[:note].presence
  )

  flash[:notice] = "Diagnostic dump captured successfully."
  redirect_to diagnostic_dumps_errors_path
rescue => e
  flash[:alert] = "Failed to capture diagnostic dump: #{e.message}"
  redirect_to diagnostic_dumps_errors_path
end

#create_issueObject



149
150
151
152
153
154
155
156
157
158
159
160
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 149

def create_issue
  dashboard_url = error_url(params[:id])
  result = Commands::CreateIssue.call(params[:id], dashboard_url: dashboard_url)

  if result[:success]
    flash[:notice] = "Issue created successfully"
    flash[:new_issue_url] = result[:issue_url]
  else
    flash[:alert] = "Failed to create issue: #{result[:error]}"
  end
  redirect_to error_path(params[:id], anchor: "issue-tracking", **app_context_params)
end

#database_health_summaryObject



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 383

def database_health_summary
  unless RailsErrorDashboard.configuration.enable_system_health
    flash[:alert] = "System health is not enabled. Enable it in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days

  # Live database health (display-time only)
  @live_health = Services::DatabaseHealthInspector.call

  # Separate host vs gem tables from live data
  all_tables = @live_health[:tables] || []
  @host_tables = all_tables.reject { |t| t[:gem_table] }
  @gem_tables = all_tables.select { |t| t[:gem_table] }

  # Historical connection pool stats
  result = Queries::DatabaseHealthSummary.call(days, application_id: @current_application_id)
  all_entries = result[:entries]

  # Summary stats (computed before pagination)
  @errors_with_pool = all_entries.size
  @max_utilization = all_entries.map { |e| e[:utilization] }.max || 0
  @total_dead = all_entries.sum { |e| e[:dead] }
  @total_waiting = all_entries.sum { |e| e[:waiting] }

  @pagy, @entries = pagy(:offset, all_entries, limit: params[:per_page] || 25)
end

#deprecationsObject



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 302

def deprecations
  unless RailsErrorDashboard.configuration.enable_breadcrumbs
    flash[:alert] = "Breadcrumbs are not enabled. Enable them in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::DeprecationWarnings.call(days, application_id: @current_application_id)
  all_deprecations = result[:deprecations]

  # Summary stats (computed before pagination)
  @unique_count = all_deprecations.size
  @total_count = all_deprecations.sum { |d| d[:count] }
  @affected_count = all_deprecations.flat_map { |d| d[:error_ids] }.uniq.size

  @pagy, @deprecations = pagy(:offset, all_deprecations, limit: params[:per_page] || 25)
end

#diagnostic_dumpsObject



502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 502

def diagnostic_dumps
  unless RailsErrorDashboard.configuration.enable_diagnostic_dump
    flash[:alert] = "Diagnostic dumps are not enabled. Enable them in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  scope = DiagnosticDump.recent
  scope = scope.where(application_id: @current_application_id) if @current_application_id.present?
  @total_dumps = scope.count

  @pagy, @dumps = pagy(:offset, scope, limit: params[:per_page] || 25)
end

#disable_coverageObject



560
561
562
563
564
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 560

def disable_coverage
  Services::CoverageTracker.disable!
  flash[:notice] = "Code path coverage disabled."
  redirect_back fallback_location: errors_path
end

#enable_coverageObject



545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 545

def enable_coverage
  unless RailsErrorDashboard.configuration.enable_coverage_tracking
    flash[:alert] = "Coverage tracking is not enabled in configuration."
    redirect_to errors_path(**app_context_params)
    return
  end

  if Services::CoverageTracker.enable!
    flash[:notice] = "Code path coverage enabled. Reproduce the error, then view source code to see executed lines."
  else
    flash[:alert] = "Could not enable coverage. Requires Ruby 3.2+."
  end
  redirect_back fallback_location: errors_path
end

#indexObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 59

def index
  # Use Query to get filtered errors
  errors_query = Queries::ErrorsList.call(filter_params)

  # Paginate with Pagy. raise_range_error makes pagy 43.x raise Pagy::RangeError
  # on out-of-range pages (e.g. ?page=999999) so application_controller.rb's
  # rescue_from can redirect to a valid page. Without this, pagy 43.x silently
  # returns an empty result and users see "All clear!" instead of their data.
  @pagy, @errors = pagy(:offset, errors_query, limit: params[:per_page] || 25, raise_range_error: true)

  # Get dashboard stats using Query (pass application filter)
  @stats = Queries::DashboardStats.call(application_id: @current_application_id)

  # Get filter options using Query (pass application filter)
  filter_options = Queries::FilterOptions.call(application_id: @current_application_id)
  @error_types = filter_options[:error_types]
  @platforms = filter_options[:platforms]
  @assignees = filter_options[:assignees]
end

#job_health_summaryObject



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 363

def job_health_summary
  unless RailsErrorDashboard.configuration.enable_system_health
    flash[:alert] = "System health is not enabled. Enable it in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::JobHealthSummary.call(days, application_id: @current_application_id)
  all_entries = result[:entries]

  # Summary stats (computed before pagination)
  @errors_with_jobs = all_entries.size
  @total_failed = all_entries.sum { |e| e[:failed] || e[:errored] || 0 }
  @adapters_detected = all_entries.map { |e| e[:adapter] }.uniq

  @pagy, @entries = pagy(:offset, all_entries, limit: params[:per_page] || 25)
end


162
163
164
165
166
167
168
169
170
171
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 162

def link_issue
  result = Commands::LinkExistingIssue.call(params[:id], issue_url: params[:issue_url])

  if result[:success]
    flash[:notice] = "Issue linked successfully"
  else
    flash[:alert] = "Failed to link issue: #{result[:error]}"
  end
  redirect_to error_path(params[:id], anchor: "issue-tracking", **app_context_params)
end

#muteObject



134
135
136
137
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 134

def mute
  @error = Commands::MuteError.call(params[:id], muted_by: params[:muted_by], reason: params[:reason])
  redirect_to error_path(@error, **app_context_params)
end

#n_plus_one_summaryObject



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 322

def n_plus_one_summary
  unless RailsErrorDashboard.configuration.enable_breadcrumbs
    flash[:alert] = "Breadcrumbs are not enabled. Enable them in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::NplusOneSummary.call(days, application_id: @current_application_id)
  all_patterns = result[:patterns]

  # Summary stats (computed before pagination)
  @unique_count = all_patterns.size
  @total_count = all_patterns.sum { |p| p[:count] }
  @affected_count = all_patterns.flat_map { |p| p[:error_ids] }.uniq.size

  @pagy, @patterns = pagy(:offset, all_patterns, limit: params[:per_page] || 25)
end

#overviewObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 29

def overview
  # Get dashboard stats using Query (pass application filter)
  @stats = Queries::DashboardStats.call(application_id: @current_application_id)

  # Get platform health summary (if enabled, pass application filter)
  if RailsErrorDashboard.configuration.enable_platform_comparison
    comparison = Queries::PlatformComparison.new(days: 7, application_id: @current_application_id)
    @platform_health = comparison.platform_health_summary
    @platform_scores = comparison.platform_stability_scores
  else
    @platform_health = {}
    @platform_scores = {}
  end

  # Get correlation summary (if enabled, pass application filter)
  if RailsErrorDashboard.configuration.enable_error_correlation
    correlation = Queries::ErrorCorrelation.new(days: 7, application_id: @current_application_id)
    @problematic_releases = correlation.problematic_releases.first(3)
    @time_correlated_errors = correlation.time_correlated_errors.first(3)
    @multi_error_users = correlation.multi_error_users(min_error_types: 2).first(5)
  else
    @problematic_releases = []
    @time_correlated_errors = []
    @multi_error_users = []
  end

  # Get critical alerts using Query
  @critical_alerts = Queries::CriticalAlerts.call(application_id: @current_application_id)
end

#platform_comparisonObject



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 207

def platform_comparison
  # Check if feature is enabled
  unless RailsErrorDashboard.configuration.enable_platform_comparison
    flash[:alert] = "Platform Comparison is not enabled. Enable it in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 7).to_i
  @days = days

  # Use Query to get platform comparison data (pass application filter)
  comparison = Queries::PlatformComparison.new(days: days, application_id: @current_application_id)

  @error_rate_by_platform = comparison.error_rate_by_platform
  @severity_distribution = comparison.severity_distribution_by_platform
  @resolution_times = comparison.resolution_time_by_platform
  @top_errors_by_platform = comparison.top_errors_by_platform
  @stability_scores = comparison.platform_stability_scores
  @cross_platform_errors = comparison.cross_platform_errors
  @daily_trends = comparison.daily_trend_by_platform
  @platform_health = comparison.platform_health_summary
end

#rack_attack_summaryObject



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 439

def rack_attack_summary
  unless RailsErrorDashboard.configuration.enable_rack_attack_tracking &&
         RailsErrorDashboard.configuration.enable_breadcrumbs
    flash[:alert] = "Rack Attack tracking is not enabled. Enable enable_rack_attack_tracking and enable_breadcrumbs in config/initializers/rails_error_dashboard.rb"
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::RackAttackSummary.call(days, application_id: @current_application_id)
  all_events = result[:events]

  # Summary stats (computed before pagination)
  @unique_rules = all_events.size
  @total_events = all_events.sum { |e| e[:count] }
  @unique_ips = all_events.flat_map { |e| e[:ips] }.uniq.size

  @pagy, @events = pagy(:offset, all_events, limit: params[:per_page] || 25)
end

#releasesObject



282
283
284
285
286
287
288
289
290
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 282

def releases
  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::ReleaseTimeline.call(days, application_id: @current_application_id)
  all_releases = result[:releases]
  @summary = result[:summary]

  @pagy, @releases = pagy(:offset, all_releases, limit: params[:per_page] || 25)
end

#resolveObject



95
96
97
98
99
100
101
102
103
104
105
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 95

def resolve
  # Use Command to resolve error
  @error = Commands::ResolveError.call(
    params[:id],
    resolved_by_name: params[:resolved_by_name],
    resolution_comment: params[:resolution_comment],
    resolution_reference: params[:resolution_reference]
  )

  redirect_to error_path(@error, **app_context_params)
end

#settingsObject



583
584
585
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 583

def settings
  @config = RailsErrorDashboard.configuration
end

#showObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 79

def show
  # Eagerly load associations to avoid N+1 queries
  # - comments: Audit trail (workflow comments from snooze/mute/status changes)
  # - parent_cascade_patterns/child_cascade_patterns: Used if cascade detection is enabled
  @error = ErrorLog.includes(:comments, :parent_cascade_patterns, :child_cascade_patterns).find(params[:id])
  @related_errors = @error.related_errors(limit: 5, application_id: @current_application_id)
  @error_markdown = Services::MarkdownErrorFormatter.call(@error, related_errors: @related_errors)

  # Fetch platform issue state and comments if linked
  @platform_issue = fetch_platform_issue(@error)
  @platform_comments = fetch_platform_comments(@error)

  # Dispatch plugin event for error viewed
  RailsErrorDashboard::PluginRegistry.dispatch(:on_error_viewed, @error)
end

#snoozeObject



124
125
126
127
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 124

def snooze
  @error = Commands::SnoozeError.call(params[:id], hours: params[:hours].to_i, reason: params[:reason])
  redirect_to error_path(@error, **app_context_params)
end

#swallowed_exceptionsObject



414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 414

def swallowed_exceptions
  unless RailsErrorDashboard.configuration.detect_swallowed_exceptions
    # On Ruby < 3.3, validate! auto-disables this feature — tell the user why
    if RUBY_VERSION < "3.3"
      flash[:alert] = "Swallowed exception detection requires Ruby 3.3+ (you have #{RUBY_VERSION}). Upgrade Ruby to use this feature."
    else
      flash[:alert] = "Swallowed exception detection is not enabled. Enable it in config/initializers/rails_error_dashboard.rb"
    end
    redirect_to errors_path(**app_context_params)
    return
  end

  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::SwallowedExceptionSummary.call(days, application_id: @current_application_id)
  all_entries = result[:entries]

  # Summary stats (computed before pagination)
  @unique_count = all_entries.size
  @total_rescue_count = all_entries.sum { |e| e[:rescue_count] }
  @total_raise_count = all_entries.sum { |e| e[:raise_count] }

  @pagy, @entries = pagy(:offset, all_entries, limit: params[:per_page] || 25)
end

#test_errorObject



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 566

def test_error
  exception = RailsErrorDashboard::TestError.new(
    "[RED Test] This is a test error sent from the dashboard to verify " \
    "that error capture and notification delivery are working correctly. " \
    "It is safe to resolve or delete this error."
  )
  exception.set_backtrace(caller)

  Commands::LogError.call(exception, { request: request, source: "dashboard.test_error" })

  flash[:notice] = "Test error logged successfully. Check your notification channels (Slack, Discord, email, etc.) to confirm delivery."
  redirect_to errors_path(**app_context_params)
rescue => e
  flash[:alert] = "Failed to log test error: #{e.message}"
  redirect_to settings_path(**app_context_params)
end

#unassignObject



114
115
116
117
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 114

def unassign
  @error = Commands::UnassignError.call(params[:id])
  redirect_to error_path(@error, **app_context_params)
end

#unmuteObject



139
140
141
142
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 139

def unmute
  @error = Commands::UnmuteError.call(params[:id])
  redirect_to error_path(@error, **app_context_params)
end

#unsnoozeObject



129
130
131
132
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 129

def unsnooze
  @error = Commands::UnsnoozeError.call(params[:id])
  redirect_to error_path(@error, **app_context_params)
end

#update_priorityObject



119
120
121
122
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 119

def update_priority
  @error = Commands::UpdateErrorPriority.call(params[:id], priority_level: params[:priority_level])
  redirect_to error_path(@error, **app_context_params)
end

#update_statusObject



144
145
146
147
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 144

def update_status
  result = Commands::UpdateErrorStatus.call(params[:id], status: params[:status], comment: params[:comment])
  redirect_to error_path(result[:error], **app_context_params)
end

#user_impactObject



292
293
294
295
296
297
298
299
300
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 292

def user_impact
  days = (params[:days] || 30).to_i
  @days = days
  result = Queries::UserImpactSummary.call(days, application_id: @current_application_id)
  all_entries = result[:entries]
  @summary = result[:summary]

  @pagy, @entries = pagy(:offset, all_entries, limit: params[:per_page] || 25)
end