Created
August 17, 2009 19:45
-
-
Save tobinharris/169332 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'rake' | |
require 'rakesetup' | |
namespace :queue do | |
task :default => [:queue_summary] | |
desc "Show's where the queue is up to." | |
task :summary do | |
UoW.start | |
count_of_failed_items = UoW.Session.create_query("select count(t) from ITask t where t.IsDone = true and t.ExceptionThrown is not null").method(:list).of(Object).call | |
failed_items = UoW.Session.create_query("from ITask t where t.IsDone = true and t.ExceptionThrown is not null").method(:list).of(ITask).call | |
failed_items.each do |t| puts t.exception_thrown end | |
puts "#{count_of_failed_items} tasks failed." | |
UoW.end | |
end | |
desc "Gets rid of everthing in the queue. Best use this only in testing." | |
task :clobber do | |
UoW.start | |
UoW.session.delete("from ITask t") | |
UoW.commit | |
UoW.end | |
end | |
desc "Queue up all the thumbnails tasks." | |
task :thumbs do | |
UoW.start | |
docs = UoW.Session.create_query("from Document d where d.State = 1").method(:list).of(Document).call | |
docs.each do |doc| | |
task = ThumbnailTask.new | |
task.document = doc | |
UoW.session.persist task | |
end | |
UoW.commit | |
UoW.end | |
end | |
desc "Process the queue until Ctrl-C pressed..." | |
task :process do | |
q = TaskQueue.new | |
while(true) | |
UoW.start | |
puts "Processing..." | |
q.process 1 | |
UoW.commit | |
UoW.end | |
sleep 2 | |
end | |
end | |
desc "Make the config match the environment" | |
task :webconfig do | |
indexFolder = ENVIRONMENT == 'production' ? "c:/inetpub/docportal/staging/_shared/Indexes" : "~/App_Data/Indexes" | |
filename = "#{Settings.WebRoot}\\Web.config" | |
doc = REXML::Document.new( File.new(filename) ) | |
REXML::XPath.each( doc, "//search-factory/property[@name='hibernate.search.default.indexBase']") do |element| | |
element.text = indexFolder | |
end | |
doc.write(File.new(filename,"w")) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment