Skip to content

Commit

Permalink
Fully functional retry item removal
Browse files Browse the repository at this point in the history
  • Loading branch information
morellon committed Dec 28, 2010
1 parent e4dc9ff commit 138bb41
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
11 changes: 5 additions & 6 deletions lib/resque-retry/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ def local_template(path)
def cancel_retry(job)
klass = Resque.constantize(job['class'])
retry_key = retry_key_for_job(job)
puts retry_key
puts Resque.remove_delayed(klass, job['args'])
puts Resque.redis.del("failure_#{retry_key}")
puts Resque.redis.del(retry_key)
Resque.remove_delayed(klass, *job["args"])
Resque.redis.del("failure_#{retry_key}")
Resque.redis.del(retry_key)
end
end

Expand All @@ -51,10 +50,10 @@ def cancel_retry(job)
erb local_template('retry_timestamp.erb')
end

get "/retry/:timestamp/jobs/:id/remove" do
post "/retry/:timestamp/jobs/:id/remove" do
job = Resque.decode(params[:id])
cancel_retry(job)
redirect u('retry')
redirect u("retry/#{params[:timestamp]}")
end
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/resque-retry/server/views/retry.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</tr>
<% timestamps = resque.delayed_queue_peek(start, start+20) %>
<% timestamps.each do |timestamp| %>
<% job = resque.delayed_timestamp_peek(timestamp, 0, 1).first %>
<% job = resque.delayed_timestamp_peek(timestamp, 0, 1).first || {} %>
<% retry_key = retry_key_for_job(job) %>
<tr>
<td>
Expand Down
9 changes: 7 additions & 2 deletions lib/resque-retry/server/views/retry_timestamp.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@
<% end %>
</td>
<% end %>
<td><a href="<%= url "retry/#{timestamp}/jobs/#{CGI.escape(Resque.encode(job))}/remove" %>" class="remove">Remove</a></td>
<td>
<form action="<%= url "retry/#{timestamp}/jobs/#{CGI.escape(Resque.encode(job))}/remove" %>" method="post">
<input type="hidden" name="timestamp" value="<%= timestamp.to_i %>">
<input type="submit" value="Remove">
</form>
</td>
</tr>
<% end %>
<% if jobs.empty? %>
<tr>
<td class="no-data" colspan="5">
<td class="no-data" colspan="6">
There are no pending jobs scheduled for this time.
</td>
</tr>
Expand Down

0 comments on commit 138bb41

Please sign in to comment.