Skip to content

Commit 1f44b2a

Browse files
Merge pull request #1 from MorphoSource/ms_updates
Adds functionality and fixes issues with failed jobs list
2 parents 58ea436 + 4077717 commit 1f44b2a

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

app/assets/stylesheets/resque_web/bootstrap_and_overrides.css.scss.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ body {
123123
.container ul.failed li dl dt {font-size:80%; color:#999; width:60px; float:left; padding-top:1px; text-align:right;}
124124
.container ul.failed li dl dd {margin-bottom:10px; margin-left:70px;}
125125
.container ul.failed li dl dd .retried { float:right; text-align: right; }
126-
.container ul.failed li dl dd .retried .remove { display:none; margin-top: 8px; }
126+
.container ul.failed li dl dd .retried .remove { margin-top: 8px; }
127127
.container ul.failed li.hover dl dd .retried .remove { display:block; }
128-
.container ul.failed li dl dd .controls { display:none; float:right; }
128+
.container ul.failed li dl dd .controls { float:right; }
129129
.container ul.failed li.hover dl dd .controls { display:block; }
130130
.container ul.failed li dl dd code, .container ul.failed li dl dd pre { font-family:Monaco, "Courier New", monospace; font-size:90%; white-space: pre-wrap;}
131131
.container ul.failed li dl dd.error a {font-family:Monaco, "Courier New", monospace; font-size:90%; }

app/controllers/resque_web/failures_controller.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ def retry_all
3838
redirect_to failures_path(redirect_params)
3939
end
4040

41+
def retry_all_for_exception
42+
if params[:exception].present?
43+
exception = params[:exception]
44+
job_ids = []
45+
46+
Resque::Failure.each(0, Resque::Failure.count, params[:queue] || 'failed') do |id, item|
47+
if item['exception'] == exception
48+
job_ids << id
49+
end
50+
end
51+
52+
job_ids.sort.reverse.map { |id| reque_single_job(id) }
53+
else
54+
flash[:error] = "No exception specified for retrying failures."
55+
end
56+
redirect_to failures_path(redirect_params)
57+
end
58+
4159
private
4260

4361
#API agnostic for Resque 2 with duck typing on requeue_and_remove

app/helpers/resque_web/application_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def pagination(options = {})
4343
start = options[:start] || 1
4444
per_page = options[:per_page] || PER_PAGE
4545
total = options[:total] || 0
46+
span_tag = options[:span_tag]
4647
return if total < per_page
4748

4849
markup = ""
@@ -54,7 +55,7 @@ def pagination(options = {})
5455
markup << link_to(raw("more &raquo;"), params.permit!.merge(:start => start + per_page), :class => 'btn more')
5556
end
5657

57-
content_tag :p, raw(markup), :class => 'pagination'
58+
content_tag (span_tag ? :span : :p), raw(markup), :class => (span_tag ? '' : 'pagination')
5859
end
5960

6061
def poll(polling=false)

app/helpers/resque_web/failures_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module ResqueWeb
22
module FailuresHelper
33
def each_failure(&block)
4-
Resque::Failure.each(failure_start_at, failure_per_page, params[:queue], params[:class], &block)
4+
Resque::Failure.each(failure_start_at, failure_per_page, params[:queue], params[:class], 'asc', &block)
55
end
66

77
def failure_date_format

app/views/resque_web/failures/_failed_job.html.erb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<dt>Worker</dt>
88
<dd>
99
<%= job['worker'].split(':')[0...2].join(':') %>
10-
on <b class="label label-info"><%= job['queue'] %></b >
10+
on <b class="label label-info"><%= job['queue'] %></b>
1111
at <b><span class="time"><%= Time.parse(job['failed_at']).strftime(failure_date_format) %></span></b>
1212

1313
<% if job['retried_at'] %>
@@ -36,7 +36,12 @@
3636
<dt>Arguments</dt>
3737
<dd><pre><%= job_arguments(job) %></pre></dd>
3838
<dt>Exception</dt>
39-
<dd><code><%= job['exception'] %></code></dd>
39+
<dd>
40+
<code><%= job['exception'] %></code>
41+
<%= form_tag(retry_all_for_exception_failures_path(exception: job['exception'].to_s), method: :put, style: 'margin-top: 0;') do %>
42+
<%= submit_tag "Retry All Jobs with Exception", data: { confirm: "Are you sure you want to retry ALL #{failure_queue_name.downcase} jobs with this exception?" } %>
43+
<% end %>
44+
</dd>
4045
<dt>Error</dt>
4146
<dd class="error">
4247
<% if job['backtrace'] %>

app/views/resque_web/failures/index.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<%= form_tag(destroy_all_failures_path(queue: params[:queue]), method: :delete) do %>
99
<%= submit_tag "Clear #{failure_queue_name} Jobs", class: 'btn btn-danger', data: { confirm: "Are you sure you want to clear ALL #{failure_queue_name.downcase} jobs?" } %>
1010
<% if failure_size > failure_per_page %>
11+
<%= pagination(start: failure_start_at, total: failure_size, span_tag: true) unless params[:class] %>
1112
<%= link_to "Last page &raquo;".html_safe, { start: (failure_size - failure_per_page) }, class: 'btn' %>
1213
<% end %>
1314
<% end %>
@@ -17,7 +18,7 @@
1718
<% end %>
1819

1920
<% if multiple_failure_queues? && !params[:queue] %>
20-
<p class="sub"><b><%= Resque::Failure.queues.size %></b> failure queues total</sub>
21+
<p class="sub"><b><%= Resque::Failure.queues.size %></b> failure queues total</p>
2122
<%= render partial: 'overview' %>
2223
<% else %>
2324
<p class="sub">Showing <%= failure_start_at %> to <%= failure_end_at %> of <b><%= failure_size %></b> jobs</p>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
end
2222
collection do
2323
put 'retry_all'
24+
put 'retry_all_for_exception'
2425
delete 'destroy_all'
2526
end
2627
end

0 commit comments

Comments
 (0)