BURs: add processing and failed states.
When a BUR is approved, put it in a `processing` state. After it successfully finishes processing, put it in the `approved` state. If it fails processing, put it in the `failed` state. If approving the BUR fails with a validation error, for example because the alias already exists or an implication lacks a wiki, then leave the BUR in the `pending` state. The `failed` state is only for unexpected errors during processing.
This commit is contained in:
@@ -171,6 +171,11 @@ class BulkUpdateRequestProcessor
|
||||
raise Error, "Unknown command: #{command}"
|
||||
end
|
||||
end
|
||||
|
||||
bulk_update_request.update!(status: "approved")
|
||||
rescue StandardError
|
||||
bulk_update_request.update!(status: "failed")
|
||||
raise
|
||||
end
|
||||
|
||||
# The list of tags in the script. Used for search BURs by tag.
|
||||
|
||||
@@ -146,12 +146,19 @@ class DText
|
||||
embedded_script = "[expand]#{obj.processor.to_dtext}[/expand]"
|
||||
end
|
||||
|
||||
if obj.is_approved?
|
||||
case obj.status
|
||||
when "approved"
|
||||
"The \"bulk update request ##{obj.id}\":#{Routes.bulk_update_request_path(obj)} has been approved by <@#{obj.approver.name}>.\n\n#{embedded_script}"
|
||||
elsif obj.is_pending?
|
||||
when "pending"
|
||||
"The \"bulk update request ##{obj.id}\":#{Routes.bulk_update_request_path(obj)} is pending approval.\n\n#{embedded_script}"
|
||||
elsif obj.is_rejected?
|
||||
when "rejected"
|
||||
"The \"bulk update request ##{obj.id}\":#{Routes.bulk_update_request_path(obj)} has been rejected.\n\n#{embedded_script}"
|
||||
when "processing"
|
||||
"The \"bulk update request ##{obj.id}\":#{Routes.bulk_update_request_path(obj)} is being processed.\n\n#{embedded_script}"
|
||||
when "failed"
|
||||
"The \"bulk update request ##{obj.id}\":#{Routes.bulk_update_request_path(obj)} has failed.\n\n#{embedded_script}"
|
||||
else
|
||||
raise ArgumentError, "unknown bulk update request status"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user