Skip to content
Browse files

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

  • Loading branch information...
1 parent c97979b commit 43a8fe27dca8e711b980b8a0e9034dd57bf142f2 @edavis10 committed Oct 6, 2010
Showing with 24 additions and 0 deletions.
  1. +2 −0 README.rdoc
  2. +2 −0 init.rb
  3. +20 −0 lib/tasks/cache.rake
View
2 README.rdoc
@@ -27,6 +27,7 @@ There are two sets of steps to install this plugin. The first one should be don
These installation instructions are very specific because the Rate plugin adjusts data inside the Budget plugin so several data integrity checks are needed.
0. Backup up your data! Backup your data!
+0. Install the Lockfile gem
1. Follow the Redmine plugin installation steps a http://www.redmine.org/wiki/redmine/Plugins Make sure the plugin is installed to +vendor/plugins/redmine_rate+
2. Make sure you are running the 0.1.0 version of the Budget plugin and 0.0.1 version of the Billing plugin
3. Run the pre_install_export to export your current budget and billing data to file +rake rate_plugin:pre_install_export+
@@ -40,6 +41,7 @@ These installation instructions are very specific because the Rate plugin adjust
=== Option #2: If you do not have any data from Budget or Billing
+0. Install the Lockfile gem
1. Follow the Redmine plugin installation steps a http://www.redmine.org/wiki/redmine/Plugins Make sure the plugin is installed to +vendor/plugins/redmine_rate+
2. Run the plugin migrations +rake db:migrate_plugins+ in order to get the new tables for Rates
3. Restart your Redmine web servers (e.g. mongrel, thin, mod_rails)
View
2 init.rb
@@ -4,6 +4,8 @@
require 'dispatcher'
Dispatcher.to_prepare :redmine_rate do
+ gem 'lockfile'
+
require_dependency 'sort_helper'
SortHelper.send(:include, RateSortHelperPatch)
View
20 lib/tasks/cache.rake
@@ -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

0 comments on commit 43a8fe2

Please sign in to comment.
Something went wrong with that request. Please try again.