Class: RailsErrorDashboard::ErrorsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RailsErrorDashboard::ErrorsController
- Includes:
- Pagy::Backend
- Defined in:
- app/controllers/rails_error_dashboard/errors_controller.rb
Instance Method Summary collapse
- #analytics ⇒ Object
- #batch_action ⇒ Object
- #correlation ⇒ Object
- #index ⇒ Object
- #platform_comparison ⇒ Object
- #resolve ⇒ Object
- #show ⇒ Object
Instance Method Details
#analytics ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 45 def analytics days = (params[:days] || 30).to_i @days = days # Use Query to get analytics data analytics = Queries::AnalyticsStats.call(days) @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] end |
#batch_action ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 87 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 "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 end |
#correlation ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 113 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 return end days = (params[:days] || 30).to_i @days = days correlation = Queries::ErrorCorrelation.new(days: days) @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. @period_comparison = correlation.period_comparison @platform_specific_errors = correlation.platform_specific_errors end |
#index ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 9 def index # Use Query to get filtered errors errors_query = Queries::ErrorsList.call(filter_params) # Paginate with Pagy @pagy, @errors = pagy(errors_query, items: params[:per_page] || 25) # Get dashboard stats using Query @stats = Queries::DashboardStats.call # Get filter options using Query = Queries::FilterOptions.call @error_types = [:error_types] @platforms = [:platforms] end |
#platform_comparison ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 63 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 return end days = (params[:days] || 7).to_i @days = days # Use Query to get platform comparison data comparison = Queries::PlatformComparison.new(days: days) @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 |
#resolve ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 33 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) end |
#show ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 25 def show @error = ErrorLog.find(params[:id]) @related_errors = @error.(limit: 5) # Dispatch plugin event for error viewed RailsErrorDashboard::PluginRegistry.dispatch(:on_error_viewed, @error) end |