Add group names to user export csv

This commit is contained in:
Arpit Jalan 2014-09-06 21:11:05 +05:30
parent a2b9251b22
commit f8effbcffe
1 changed files with 11 additions and 0 deletions

View File

@ -25,7 +25,9 @@ module Jobs
user_data.each do |user|
user_array = Array.new
group_names = get_group_names(user).join(';')
user_array.push(user['id']).push(user['name']).push(user['username']).push(user['email'])
user_array.push(group_names) if group_names != ''
data.push(user_array)
end
end
@ -40,6 +42,15 @@ module Jobs
private
def get_group_names(user)
group_names = []
groups = user.custom_groups
groups.each do |group|
group_names.push(group.name)
end
return group_names
end
def set_file_path
@file_name = "export_#{SecureRandom.hex(4)}.csv"
# ensure directory exists