[#4604] Add a simple rake task to update missing cost caches

This commit is contained in:
Eric Davis
2010-10-06 15:48:55 -07:00
parent c97979bd06
commit 43a8fe27dc
3 changed files with 24 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
require 'lockfile'
namespace :rate_plugin do
namespace :cache do
desc "Update Time Entry cost caches"
task :update_cost_cache => :environment do
Lockfile('update_cost_cache', :retries => 0) do
TimeEntry.all(:conditions => {:cost => nil}).each do |time_entry|
begin
time_entry.save_cached_cost
rescue Rate::InvalidParameterException => ex
puts "Error saving #{time_entry.id}: #{ex.message}"
end
end
end
end
end
end