Skip to content

Commit 0102eee

Browse files
committed
Merge pull request resque#675 from KensoDev/master
Work I have done on Resque, into a single Pull Request
2 parents 7024f42 + df2adb5 commit 0102eee

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Table Of Contents
5858
* [Mysql::Error: MySQL server has gone away](#section_Workers_Mysql_Error_MySQL_server_has_gone_away)
5959
* [The Front End](#section_The_Front_End)
6060
* [Standalone](#section_The_Front_End_Standalone)
61+
* [Using the front end for failure review](#section_Using_The_Front_End_For_Review)
6162
* [Passenger](#section_The_Front_End_Passenger)
6263
* [Rack::URLMap](#section_The_Front_End_Rack_URLMap)
6364
* [Rails 3](#section_The_Front_End_Rails_3)
@@ -535,7 +536,21 @@ or set the Redis connection string if you need to do something like select a dif
535536

536537
$ resque-web -p 8282 -r localhost:6379:2
537538

539+
<a name='section_Using_The_Front_End_For_Review'></a>
540+
541+
### Using The front end for failures review
542+
543+
Using the front end to review what's happening in the queue
544+
-----------------------------------------------------------
545+
After using Resque for a while, you may have quite a few failed jobs.
546+
Reviewing them by going over pages when showing 20 a page can be a bit hard.
547+
548+
You can change the param in the url (in the failed view only for now), just add per_page=100 and you will see 100 per page.
549+
for example: http://www.your_domain.com/resque/failed?start=20&per_page=200.
550+
551+
538552
<a name='section_The_Front_End_Passenger'></a>
553+
539554
### Passenger
540555

541556
Using Passenger? Resque ships with a `config.ru` you can use. See

lib/resque/failure.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def self.clear
6262
def self.requeue(index)
6363
backend.requeue(index)
6464
end
65+
66+
def self.requeue_to(index, queue_name)
67+
backend.requeue(index, queue_name)
68+
end
6569

6670
def self.remove(index)
6771
backend.remove(index)

lib/resque/failure/redis.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ def self.requeue(index)
3535
Resque.redis.lset(:failed, index, Resque.encode(item))
3636
Job.create(item['queue'], item['payload']['class'], *item['payload']['args'])
3737
end
38+
39+
def self.requeue_to(index, queue_name)
40+
item = all(index)
41+
item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
42+
Resque.redis.lset(:failed, index, Resque.encode(item))
43+
Job.create(queue_name, item['payload']['class'], *item['payload']['args'])
44+
end
3845

3946
def self.remove(index)
4047
id = rand(0xffffff)

lib/resque/server/views/failed.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<%start = params[:start].to_i %>
2-
<%failed = Resque::Failure.all(start, 20)%>
1+
<% start = params[:start].to_i %>
2+
<% per_page = (params[:per_page].to_i > 0) ? params[:per_page].to_i : 20 %>
3+
<% failed = Resque::Failure.all(start, per_page) %>
34
<% index = 0 %>
45
<% date_format = "%Y/%m/%d %T %z" %>
56

@@ -13,7 +14,7 @@
1314
</form>
1415
<%end%>
1516
16-
<p class='sub'>Showing <%=start%> to <%= start + 20 %> of <b><%= size = Resque::Failure.count %></b> jobs</p>
17+
<p class='sub'>Showing <%=start%> to <%= start + per_page %> of <b><%= size = Resque::Failure.count %></b> jobs</p>
1718

1819
<ul class='failed'>
1920
<%for job in failed%>
@@ -63,5 +64,4 @@
6364
<%end%>
6465
</ul>
6566

66-
<%= partial :next_more, :start => start, :size => size %>
67-
67+
<%= partial :next_more, :start => start, :size => size, :per_page => per_page %>

lib/resque/server/views/next_more.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%if start - 20 >= 0 || start + 20 <= size%>
1+
<% if start - 20 >= 0 || start + 20 <= size %>
22
<p class='pagination'>
33
<% if start - 20 >= 0 %>
44
<a href="<%= current_page %>?start=<%= start - 20 %>" class='less'>&laquo; less</a>

0 commit comments

Comments
 (0)