Skip to content

Commit 816bc5e

Browse files
committed
add a flag for email retrieval
1 parent b44856f commit 816bc5e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def initialize(options={})
2525

2626
@date = options[:date]
2727
@organization = options[:organization]
28+
@email = options[:email]
2829

2930
organization_members
3031
organization_repositories
@@ -73,13 +74,17 @@ def info(message)
7374
$stdout.print message
7475
end
7576

77+
def member_email(login)
78+
@email ? @client.user(login)[:email] : ""
79+
end
80+
7681
def organization_members
7782
# get all organization members and place into an array of hashes
7883
@members = @client.organization_members(@organization).collect do |m|
79-
email = @client.user(m[:login])[:email]
84+
email =
8085
{
8186
login: m["login"],
82-
email: email,
87+
email: member_email(m[:login]),
8388
active: false
8489
}
8590
end
@@ -206,6 +211,10 @@ def member_activity
206211
options[:date] = d.to_s
207212
end
208213

214+
opts.on('-e', '--email', "Fetch the user email (can make the script take longer") do |e|
215+
options[:email] = e
216+
end
217+
209218
opts.on('-o', '--organization MANDATORY',String, "Organization to scan for inactive users") do |o|
210219
options[:organization] = o
211220
end

0 commit comments

Comments
 (0)