Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get contributions count from Octocoder

The previous approach isn't available in v3 of the API
  • Loading branch information...
commit bbe69a3746da09fe80093f6a90b8b586e3cc3d2c 1 parent f9f5c94
Andy Waite andyw8 authored
Showing with 10 additions and 2 deletions.
  1. +3 −1 app.rb
  2. +7 −1 lib/Repo.rb
4 app.rb
View
@@ -150,13 +150,15 @@ def get_high_scores(user, repo)
repository_contributors = JSON.parse(contributors)
contributors_array = Array.new
repository_contributors.each do |repository_contributor|
+
user_hash = Hash.new
user_hash[:login] = repository_contributor['login']
user_hash[:name] = repository_contributor['name']
user_hash[:email] = repository_contributor['email']
user_hash[:gravatar_id] = repository_contributor['gravatar_id']
user_hash[:location] = repository_contributor['location']
- user_hash[:contributions] = repository_contributor['contributions'].to_i
+
+ user_hash[:contributions] = stored_repo.contributions(user_hash[:login])
contributors_array << user_hash
end
return contributors_array
8 lib/Repo.rb
View
@@ -40,7 +40,7 @@ def self.create_from_username_and_repo(username, repo)
repo_data_response = get_json_response(repo_data_url)
repo_data = JSON.parse(repo_data_response.body)
- repo.owner = repo_data['owner']
+ repo.owner = repo_data['owner']['login']
repo.name = repo_data['name']
repo.url = repo_data['url']
repo.homepage = repo_data['homepage']
@@ -67,6 +67,12 @@ def self.get_json_response(url)
def self.get_repo_data_url(username, repo)
return REPO_BASE_URL + username + '/' + repo
end
+
+ def contributions(contributor)
+ uri = "http://octocoder.heroku.com/#{owner}/#{name}/#{contributor}"
+ response = RestClient.get(uri)
+ JSON.parse(response)['count']
+ end
end
DataMapper.auto_upgrade!
Please sign in to comment.
Something went wrong with that request. Please try again.