Skip to content

Commit 28d56a8

Browse files
do some api call return value checking. better structure the code
1 parent d027f5f commit 28d56a8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/controllers/organizations_controller.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,25 @@ def index
4848
next
4949
end
5050
# For each set of contributors in the repo
51-
client.contributors(repo[:full_name]).map{ |contributor|
51+
contribs = client.contributors(repo[:full_name])
52+
if !contribs.kind_of?(Array)
53+
logger.warn(contribs)
54+
next
55+
end
56+
57+
contribs.map{ |contributor|
5258
@contributors << contributor[:login]
5359
# Get all possible pairs of contributors
54-
contributor[:login]}.combination(2) {
60+
contributor[:login]
61+
}.combination(2) {
5562
|c1, c2|
5663
# As a set, so they don't double up, avoids (jeff, dave) and
5764
# (dave, jeff) being different entries
5865
link = Set.new [c1, c2]
5966
# Increment the amount of times that pair have appeared in a repo
6067
# together
6168
@occurrences[link] += 1
62-
}
69+
}
6370
}
6471

6572
@contributors_hash = Hash[@contributors.each_with_index.map { |c, i| [ c, i ] }]

0 commit comments

Comments
 (0)