Skip to content

Commit

Permalink
Filter possible collabs by code search results #32
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jun 16, 2020
1 parent 0fa4423 commit 87cd1aa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/models/contributor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,19 @@ def self.find_possible_collabs
end
possible_collabs.values.flatten.uniq - Organization.all.pluck(:name)
end

def self.filter_possible_collabs(search = ENV['DEFAULT_ORG'])
orgs = find_possible_collabs
searches = {}
orgs[127..-1].each do |org|
sleep 5
begin
search = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN']).search_code("org:#{org} #{search}", per_page: 1)
searches[org] = search.total_count
rescue Octokit::UnprocessableEntity
searches[org] = 0
end
end
searches.select{|k,v| v > 10 }
end
end

0 comments on commit 87cd1aa

Please sign in to comment.