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 ...@@ -9,21 +9,16 @@ module Pseudonymity
end end
def anonymize(results) def anonymize(results)
count = 0 columns = results.columns # Assume they all have the same table
results.each do | r | to_filter = @anon_fields & columns
break if count > 0
count += 1 results.each do |result|
puts r.inspect to_filter.each do |field|
puts @anon_fields result[field] = Digest::SHA2.new(256).hexdigest(result[field]) unless result[field].nil?
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
end end
new_hash
end end
results
end end
end end
......
...@@ -73,8 +73,6 @@ namespace :gitlab do ...@@ -73,8 +73,6 @@ namespace :gitlab do
desc 'Output pseudonymity dump of selected table' desc 'Output pseudonymity dump of selected table'
task :pseudonymity_dump => :environment do task :pseudonymity_dump => :environment do
table = Pseudonymity::Table.new table = Pseudonymity::Table.new
# REMOVE PRODUCTION INFRA SCRIPT AS PART OF MR>
puts table.tables_to_csv
end end
end 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