Skip to content

Commit b44856f

Browse files
committed
slightly better error handling
1 parent 46b7eed commit b44856f

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

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

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,33 +118,45 @@ def commit_activity(repository)
118118
def issue_activity(repo, date=@date)
119119
# get all issues after specified date and iterate
120120
info "...issues"
121-
@client.list_issues(repo, { :since => date }).each do |issue|
122-
# if creator is a member of the org and not active, make active
123-
if t = @members.find {|member| member[:login] == issue["user"]["login"] && member[:active] == false }
124-
make_active(t[:login])
121+
begin
122+
@client.list_issues(repo, { :since => date }).each do |issue|
123+
# if creator is a member of the org and not active, make active
124+
if t = @members.find {|member| member[:login] == issue["user"]["login"] && member[:active] == false }
125+
make_active(t[:login])
126+
end
125127
end
128+
rescue
129+
info "... no issues to check"
126130
end
127131
end
128132

129133
def issue_comment_activity(repo, date=@date)
130134
# get all issue comments after specified date and iterate
131135
info "...issue comments"
132-
@client.issues_comments(repo, { :since => date}).each do |comment|
133-
# if commenter is a member of the org and not active, make active
134-
if t = @members.find {|member| member[:login] == comment["user"]["login"] && member[:active] == false }
135-
make_active(t[:login])
136+
begin
137+
@client.issues_comments(repo, { :since => date}).each do |comment|
138+
# if commenter is a member of the org and not active, make active
139+
if t = @members.find {|member| member[:login] == comment["user"]["login"] && member[:active] == false }
140+
make_active(t[:login])
141+
end
136142
end
143+
rescue
144+
info "...no issues comments to check"
137145
end
138146
end
139147

140148
def pr_activity(repo, date=@date)
141149
# get all pull request comments comments after specified date and iterate
142150
info "...pr comments"
143-
@client.pull_requests_comments(repo, { :since => date}).each do |comment|
144-
# if commenter is a member of the org and not active, make active
145-
if t = @members.find {|member| member[:login] == comment["user"]["login"] && member[:active] == false }
146-
make_active(t[:login])
151+
begin
152+
@client.pull_requests_comments(repo, { :since => date}).each do |comment|
153+
# if commenter is a member of the org and not active, make active
154+
if t = @members.find {|member| member[:login] == comment["user"]["login"] && member[:active] == false }
155+
make_active(t[:login])
156+
end
147157
end
158+
rescue
159+
info "...no pr comments to check"
148160
end
149161
end
150162

0 commit comments

Comments
 (0)