diff --git a/app/helpers/uploads_helper.rb b/app/helpers/uploads_helper.rb
index f4f8250f5..8840d6103 100644
--- a/app/helpers/uploads_helper.rb
+++ b/app/helpers/uploads_helper.rb
@@ -1,2 +1,17 @@
module UploadsHelper
+ def render_status(upload)
+ case upload.status
+ when /duplicate: (\d+)/
+ dup_post_id = $1
+ link_to(upload.status.gsub(/error: RuntimeError - /, ""), post_path(dup_post_id))
+
+ when /\Aerror: /
+ search_params = params[:search].permit!
+ link_to(upload.sanitized_status, uploads_path(search: search_params.merge({ status: upload.sanitized_status })))
+
+ else
+ search_params = params[:search].permit!
+ link_to(upload.status, uploads_path(search: search_params.merge({ status: upload.status })))
+ end
+ end
end
diff --git a/app/models/upload.rb b/app/models/upload.rb
index 8e0cefacf..1a59188db 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -117,6 +117,14 @@ class Upload < ApplicationRecord
status =~ /error:/
end
+ def sanitized_status
+ if is_errored?
+ status.sub(/DETAIL:.+/m, "...")
+ else
+ status
+ end
+ end
+
def duplicate_post_id
@duplicate_post_id ||= status[/duplicate: (\d+)/, 1]
end
diff --git a/app/presenters/upload_presenter.rb b/app/presenters/upload_presenter.rb
index 36f9babd3..44a1cce2e 100644
--- a/app/presenters/upload_presenter.rb
+++ b/app/presenters/upload_presenter.rb
@@ -2,18 +2,4 @@ class UploadPresenter < Presenter
def initialize(upload)
@upload = upload
end
-
- def status(template)
- case @upload.status
- when /duplicate: (\d+)/
- dup_post_id = $1
- template.link_to(@upload.status.gsub(/error: RuntimeError - /, ""), template.__send__(:post_path, dup_post_id))
-
- when /\Aerror: /
- @upload.status.gsub(/DETAIL:.+/m, "...")
-
- else
- @upload.status
- end
- end
end
diff --git a/app/views/uploads/index.html.erb b/app/views/uploads/index.html.erb
index f41568d3f..16c59d2e0 100644
--- a/app/views/uploads/index.html.erb
+++ b/app/views/uploads/index.html.erb
@@ -67,7 +67,7 @@
<%= time_ago_in_words_tagged upload.created_at %>
This upload is a duplicate: <%= link_to "post ##{@upload.duplicate_post_id}", post_path(@upload.duplicate_post_id) %>
<% else %> -An error occurred: <%= @upload.presenter.status(self) %>
+An error occurred: <%= render_status(@upload) %>
<% if CurrentUser.user.is_builder? %>