Skip to content

Commit 903ce12

Browse files
authored
Fixing CSV generation. Also add column names to the CSV output. (#309)
1 parent 0689199 commit 903ce12

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

api/ruby/find-inactive-members/find_inactive_members.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,27 @@ def member_activity
210210

211211
# open a new csv for output
212212
CSV.open("inactive_users.csv", "wb") do |csv|
213+
csv << ["login", "email"]
213214
# iterate and print inactive members
214215
@members.each do |member|
215216
if member[:active] == false
216-
member_detail = "#{member[:login]},#{member[:email] unless member[:email].nil?}"
217+
member_detail = []
218+
member_detail << member[:login]
219+
member_detail << member[:email] unless member[:email].nil?
217220
info "#{member_detail} is inactive\n"
218-
csv << [member_detail]
221+
csv << member_detail
219222
end
220223
end
221224
end
222225

223226
CSV.open("unrecognized_authors.csv", "wb") do |csv|
227+
csv << ["name", "email"]
224228
@unrecognized_authors.each do |author|
225-
author_detail = "#{author[:name]},#{author[:email]}"
229+
author_detail = []
230+
author_detail << author[:name]
231+
author_detail << author[:email]
226232
info "#{author_detail} is unrecognized\n"
227-
csv << [author_detail]
233+
csv << author_detail
228234
end
229235
end
230236
end

0 commit comments

Comments
 (0)