Last active
December 28, 2015 08:08
-
-
Save gmcinnes/7468977 to your computer and use it in GitHub Desktop.
Find broken data
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
column :reason, 4 | |
column :account_id, 5 | |
column :contact_id, 6 | |
column :closed_date, 7 | |
column :total_value_mars_resource_usage, 8 | |
column :total_value_mars_resources, 9 | |
column :last_modified_date, 10 | |
column :eir_case_date, 11 | |
end | |
autfull_objs = aut_schema.conform(autfull, :skip_first => true).to_a | |
# Get prod data: Select Id, CaseNumber, CGT__c, Case_Grand_Total_2__c, | |
# U_of_T_Case_Total__c, T_V__c,LastModifiedDate,EIR_Case_Date_cpa__c from Case where Case.RecordTypeId = | |
# '01250000000UGi5' OR Case.RecordTypeId = '012500000005D0y' | |
production = CSV.read('production.csv') | |
production_schema = Conformist.new do | |
column :the_id, 0 | |
column :case_number, 1 | |
column :case_grand_total, 2 | |
column :case_grand_total_2, 3 do |x| x.to_i end | |
column :u_of_t_case_total, 4 | |
column :total_value, 5 do |x| x.to_i end | |
column :last_modified_date, 6 do |x| Time.parse(x) end | |
end | |
production_objs = production_schema.conform(production, :skip_first => true).to_a | |
puts "Id,Current Total Value,New Total Value,Case Number,Diff" | |
@total_borked = [] | |
@total_borked = Parallel.map(autfull_objs, :in_processes => 8) do |new| | |
@old = production_objs.find {|x| x.the_id == new.the_id } | |
next if @old.nil? #We didn't have that data at AUT cut time | |
next if @old.last_modified_date.year < 2013 | |
next if @old.last_modified_date > Time.gm(2013,10,30) | |
diff = new.total_value_resources - @old.case_grand_total_2 | |
unless new.total_value_resources == @old.case_grand_total_2 | |
"#{@old.the_id},#{@old.case_grand_total_2},#{new.total_value_resources}, #{@old.case_number}, #{diff}" | |
end | |
end | |
@total_borked.compact! | |
puts @total_borked.length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment