Skip to content

Commit

Permalink
[#4604] Add a simple rake task to update missing cost caches
Browse files Browse the repository at this point in the history
  • Loading branch information
edavis10 committed Oct 6, 2010
1 parent c97979b commit 43a8fe2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.rdoc
Expand Up @@ -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+
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions init.rb
Expand Up @@ -4,6 +4,8 @@
require 'dispatcher'

Dispatcher.to_prepare :redmine_rate do
gem 'lockfile'

require_dependency 'sort_helper'
SortHelper.send(:include, RateSortHelperPatch)

Expand Down
20 changes: 20 additions & 0 deletions 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.