@@ -83,19 +83,23 @@ def process_warning!
8383
8484 # A log entry is only interesting if the warning contains
8585 # custom text from someone. Otherwise it's just noise.
86+
8687 log_action ( :create , warning ) if warning . text . present?
8788 end
8889
8990 def process_reports!
90- return if report_id . blank?
91+ # If we're doing "mark as resolved" on a single report,
92+ # then we want to keep other reports open in case they
93+ # contain new actionable information.
94+ #
95+ # Otherwise, we will mark all unresolved reports about
96+ # the account as resolved.
9197
92- authorize ( report , :update? )
98+ reports . each { | report | authorize ( report , :update? ) }
9399
94- if type == 'none'
100+ reports . each do | report |
95101 log_action ( :resolve , report )
96102 report . resolve! ( current_account )
97- else
98- Report . where ( target_account : target_account ) . unresolved . update_all ( action_taken : true , action_taken_by_account_id : current_account . id )
99103 end
100104 end
101105
@@ -141,6 +145,16 @@ def status_ids
141145 @report . status_ids if @report && include_statuses
142146 end
143147
148+ def reports
149+ @reports ||= begin
150+ if type == 'none' && with_report?
151+ [ report ]
152+ else
153+ Report . where ( target_account : target_account ) . unresolved
154+ end
155+ end
156+ end
157+
144158 def warning_preset
145159 @warning_preset ||= AccountWarningPreset . find ( warning_preset_id ) if warning_preset_id . present?
146160 end
0 commit comments