Class: RailsErrorDashboard::ErrorsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RailsErrorDashboard::ErrorsController
- Includes:
- Pagy::Backend
- 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 sort_by sort_direction ].freeze
Instance Method Summary collapse
- #add_comment ⇒ Object
- #analytics ⇒ Object
-
#assign ⇒ Object
Phase 3: Workflow Integration Actions.
- #batch_action ⇒ Object
- #correlation ⇒ Object
- #index ⇒ Object
- #overview ⇒ Object
- #platform_comparison ⇒ Object
- #resolve ⇒ Object
- #settings ⇒ Object
- #show ⇒ Object
- #snooze ⇒ Object
- #unassign ⇒ Object
- #unsnooze ⇒ Object
- #update_priority ⇒ Object
- #update_status ⇒ Object
Instance Method Details
#add_comment ⇒ Object
165 166 167 168 169 170 171 172 173 174 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 165 def add_comment @error = ErrorLog.find(params[:id]) @error.comments.create!( author_name: params[:author_name], body: params[:body] ) redirect_to error_path(@error) rescue => e redirect_to error_path(@error) end |
#analytics ⇒ Object
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 206 207 208 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 176 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 |
#assign ⇒ Object
Phase 3: Workflow Integration Actions
114 115 116 117 118 119 120 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 114 def assign @error = ErrorLog.find(params[:id]) @error.assign_to!(params[:assigned_to]) redirect_to error_path(@error) rescue => e redirect_to error_path(@error) end |
#batch_action ⇒ Object
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 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 234 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
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 260 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, 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. @period_comparison = correlation.period_comparison @platform_specific_errors = correlation.platform_specific_errors end |
#index ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 64 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 (pass application filter) @stats = Queries::DashboardStats.call(application_id: @current_application_id) # Get filter options using Query (pass application filter) = Queries::FilterOptions.call(application_id: @current_application_id) @error_types = [:error_types] @platforms = [:platforms] # Get all distinct assignees for the assignee filter dropdown assignee_query = ErrorLog.where.not(assigned_to: nil) # Filter by application if specified assignee_query = assignee_query.where(application_id: @current_application_id) if @current_application_id.present? @assignees = assignee_query.select(:assigned_to) .distinct .pluck(:assigned_to) .sort end |
#overview ⇒ Object
28 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 58 59 60 61 62 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 28 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..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 (critical/high severity errors from last hour) # Filter by priority_level in database instead of loading all records into memory @critical_alerts = ErrorLog .where("occurred_at >= ?", 1.hour.ago) .where(resolved_at: nil) .where(priority_level: [ 3, 4 ]) # 3 = high, 4 = critical (based on severity enum) @critical_alerts = @critical_alerts.where(application_id: @current_application_id) if @current_application_id.present? @critical_alerts = @critical_alerts.order(occurred_at: :desc).limit(10) end |
#platform_comparison ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 210 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 (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 |
#resolve ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 100 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 |
#settings ⇒ Object
281 282 283 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 281 def settings @config = RailsErrorDashboard.configuration end |
#show ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 89 def show # Eagerly load associations to avoid N+1 queries # - comments: Used in the comments section (@error.comments.count, @error.comments.recent_first) # - 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.(limit: 5, application_id: @current_application_id) # Dispatch plugin event for error viewed RailsErrorDashboard::PluginRegistry.dispatch(:on_error_viewed, @error) end |
#snooze ⇒ Object
138 139 140 141 142 143 144 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 138 def snooze @error = ErrorLog.find(params[:id]) @error.snooze!(params[:hours].to_i, reason: params[:reason]) redirect_to error_path(@error) rescue => e redirect_to error_path(@error) end |
#unassign ⇒ Object
122 123 124 125 126 127 128 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 122 def unassign @error = ErrorLog.find(params[:id]) @error.unassign! redirect_to error_path(@error) rescue => e redirect_to error_path(@error) end |
#unsnooze ⇒ Object
146 147 148 149 150 151 152 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 146 def unsnooze @error = ErrorLog.find(params[:id]) @error.unsnooze! redirect_to error_path(@error) rescue => e redirect_to error_path(@error) end |
#update_priority ⇒ Object
130 131 132 133 134 135 136 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 130 def update_priority @error = ErrorLog.find(params[:id]) @error.update!(priority_level: params[:priority_level]) redirect_to error_path(@error) rescue => e redirect_to error_path(@error) end |
#update_status ⇒ Object
154 155 156 157 158 159 160 161 162 163 |
# File 'app/controllers/rails_error_dashboard/errors_controller.rb', line 154 def update_status @error = ErrorLog.find(params[:id]) if @error.update_status!(params[:status], comment: params[:comment]) redirect_to error_path(@error) else redirect_to error_path(@error) end rescue => e redirect_to error_path(@error) end |