-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented [delayed_jobs] zafu method to list current jobs in the qu…
…eue.
- Loading branch information
Showing
7 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Bricks | ||
module Worker | ||
class Job < ActiveRecord::Base | ||
include RubyLess | ||
set_table_name :delayed_jobs | ||
|
||
safe_method :run_at => Time, :created_at => Time | ||
safe_method :info => String | ||
|
||
def info | ||
obj = YAML.load(self[:handler]) | ||
if obj.respond_to?(:info) | ||
obj.info | ||
else | ||
obj.inspect | ||
end | ||
end | ||
end # Job | ||
|
||
module ViewMethods | ||
include RubyLess | ||
|
||
safe_method :delayed_jobs => [Job] | ||
|
||
def delayed_jobs | ||
Bricks::Worker::Job.find(:all, | ||
# FIXME: find a way to add site_id to delayed_jobs... | ||
#:conditions => ['site_id = ?', current_site.id], | ||
:order => 'run_at ASC' | ||
) | ||
end | ||
end # ViewMethods | ||
end # Worker | ||
end | ||
|
||
# Make sure the class is loaded before first YAML.load | ||
Zena::SiteWorker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
Delayed::Job.const_set("MAX_RUN_TIME", 5.minutes) | ||
end | ||
|
||
Zena::Use.module Bricks::Worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
zena_index: | ||
run_at: 2011-03-21 10:41 | ||
handler: | | ||
--- !ruby/struct:Zena::SiteWorker | ||
site_id: 705790410 | ||
action: :rebuild_index | ||
page: 1 | ||
ocean_vhash: | ||
run_at: 2011-03-21 10:05 | ||
handler: | | ||
--- !ruby/struct:Zena::SiteWorker | ||
site_id: 740511775 | ||
action: :rebuild_vhash | ||
page: 1 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# test_file: ../../../../test/integration/zafu_compiler_test.rb | ||
default: | ||
context: | ||
node: 'status' | ||
visitor: 'anon' | ||
src: "<r:delayed_jobs do='each' join=', '>[<r:run_at format='%Y-%m-%d %H:%M'/> <r:info/>]</r:delayed_jobs>" | ||
tem: "/delayed_jobs/" | ||
res: "[2011-03-21 10:05 -], [2011-03-21 10:41 rebuild_index, page 1/1]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ test: | |
tags: ON | ||
captcha: ON | ||
sphinx: OFF | ||
worker: OFF | ||
worker: ON | ||
|
||
development: | ||
asset_port: 7999 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters