Commit c88f66e5 authored by Jacob Schatz's avatar Jacob Schatz Committed by Micaël Bergeron

Update with more efficent looping.

parent 0316ea13
......@@ -9,21 +9,16 @@ module Pseudonymity
end
def anonymize(results)
count = 0
results.each do | r |
break if count > 0
count += 1
puts r.inspect
puts @anon_fields
new_hash = r.each_with_object({}) do | (k, v), h |
if @anon_fields.include? k and !v.nil?
h[k] = Digest::SHA2.new(256).hexdigest v
else
h[k] = v
end
columns = results.columns # Assume they all have the same table
to_filter = @anon_fields & columns
results.each do |result|
to_filter.each do |field|
result[field] = Digest::SHA2.new(256).hexdigest(result[field]) unless result[field].nil?
end
new_hash
end
results
end
end
......
......@@ -73,8 +73,6 @@ namespace :gitlab do
desc 'Output pseudonymity dump of selected table'
task :pseudonymity_dump => :environment do
table = Pseudonymity::Table.new
# REMOVE PRODUCTION INFRA SCRIPT AS PART OF MR>
puts table.tables_to_csv
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment