Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e9c28fd0
Commit
e9c28fd0
authored
6 years ago
by
Jacob Schatz
Committed by
Micaël Bergeron
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated config to take destination for files.
parent
1ac6a03f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
lib/assets/pseudonymity_dump.yml
lib/assets/pseudonymity_dump.yml
+2
-0
lib/pseudonymity/table.rb
lib/pseudonymity/table.rb
+9
-6
No files found.
lib/assets/pseudonymity_dump.yml
View file @
e9c28fd0
output
:
csv
:
'
/tmp/'
tables
:
approvals
:
whitelist
:
...
...
This diff is collapsed.
Click to expand it.
lib/pseudonymity/table.rb
View file @
e9c28fd0
...
...
@@ -24,16 +24,19 @@ module Pseudonymity
end
class
Table
config
=
{}
def
initialize
@config
=
{}
@csv_output
=
""
parse_config
end
def
tables_to_csv
tables
=
@config
[
"tables"
]
@csv_output
=
@config
[
"output"
][
"csv"
]
if
not
File
.
directory?
(
@csv_output
)
puts
"No such directory
#{
@csv_output
}
"
return
end
tables
.
map
do
|
k
,
v
|
table_to_csv
(
k
,
v
[
"whitelist"
],
v
[
"pseudo"
])
end
...
...
@@ -43,7 +46,7 @@ module Pseudonymity
sql
=
"SELECT
#{
whitelist_columns
.
join
(
","
)
}
from
#{
table
}
"
results
=
ActiveRecord
::
Base
.
connection
.
exec_query
(
sql
)
return
if
results
.
empty?
anon
=
Anon
.
new
(
pseudonymity_columns
)
write_to_csv_file
(
table
,
anon
.
anonymize
(
results
))
end
...
...
@@ -53,7 +56,7 @@ module Pseudonymity
end
def
write_to_csv_file
(
title
,
contents
)
file_path
=
"
/tmp/
#{
title
}
.csv"
file_path
=
"
#{
@csv_output
}
/
#{
title
}
_
#{
Time
.
now
.
to_i
}
.csv"
column_names
=
contents
.
first
.
keys
contents
=
CSV
.
generate
do
|
csv
|
csv
<<
column_names
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment