Created
October 16, 2017 06:46
-
-
Save umar-siddiqui/6d3fcd951f63d23950b5ce9cf6b5e651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mongoid.override_database 'sterlite_resustain_io' | |
Mongoid::Multitenancy.current_tenant = Client.first | |
callbacks = IndicatorRecord._save_callbacks.select { |cb| cb.kind == :before }.map { |cb| cb.as_json["key"] }.map(&:to_sym) | |
indi = Indicator.find('5910150062cee9ae1a000002') | |
indicator_attri = indi.indicator_attributes.where(attribute_type: 'formula') | |
IndicatorRecord.skip_callback(:save, :before, *callbacks) | |
IndicatorRecord.where(indicator_id: '5910150062cee9ae1a000002', grade: '6th', :start_date.gte => 'June 1,2015', type_of_set: 'Sample', :start_date.lte => 'March 1,2016').each_with_index do |ir,i| | |
puts i | |
indicator_attri.each {|ia| ir.recalc_formula(ia) } | |
ir.save! | |
end | |
IndicatorRecord.set_callback(:save, :before, *callbacks) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment