From 573c0838cd8d66a6d9b25323a6c58d2ac9302ccc Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Tue, 11 Aug 2015 17:44:40 -0300 Subject: [PATCH] Fix date in merit rules script --- script/process_merit_rules.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/script/process_merit_rules.rb b/script/process_merit_rules.rb index 3f78caa..5801cb2 100755 --- a/script/process_merit_rules.rb +++ b/script/process_merit_rules.rb @@ -1,6 +1,18 @@ #!/usr/bin/env ruby # encoding: UTF-8 +class ProcessObserver + def update(changed_data) + #puts changed_data + merit = changed_data[:merit_object] + if merit.kind_of?(Merit::Score::Point) + #puts "FIX" + action = Merit::Action.find(changed_data[:merit_action_id]) + merit.update_attribute(:created_at, YAML.load(action.target_data).created_at) + end + end +end + def create_action(obj, index, count) target_model = obj.class.base_class.name.downcase action = Merit::Action.find_by_target_id_and_target_model_and_action_method(obj.id, target_model, 'create') @@ -12,13 +24,15 @@ end #puts "Destroy all merit actions" #Merit::Action.destroy_all - +# #count = Person.count #Person.all.each.with_index(1) do |person, i| # puts "#{i}/#{count} Remove sash from #{person.identifier}" # person.sash.destroy unless person.sash.nil? #end +Merit.observers << 'ProcessObserver' + Environment.all.each do |environment| Merit::AppPointRules.clear -- libgit2 0.21.2