[#4604] Add a method and rake task to clear and update all TimeEntry cost caches

This commit is contained in:
Eric Davis
2010-10-06 17:35:28 -07:00
parent 16a7a3146f
commit fb3b0a41ae
3 changed files with 48 additions and 1 deletions
+13
View File
@@ -82,6 +82,19 @@ class Rate < ActiveRecord::Base
end
store_cache_timestamp('last_caching_run', Time.now.to_s)
end
def self.update_all_time_entries_to_refresh_cache
Lockfile('refresh_cache', :retries => 0) do
TimeEntry.find_each do |time_entry| # batch find
begin
time_entry.save_cached_cost
rescue Rate::InvalidParameterException => ex
puts "Error saving #{time_entry.id}: #{ex.message}"
end
end
end
store_cache_timestamp('last_cache_clearing_run', Time.now.to_s)
end
private
def self.for_user_project_and_date(user, project, date)