Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ gem "whenever", require: false
gem "hurley"
gem "omniauth-github"
gem "figaro"
gem "githubstats"

group :development, :test do
gem "byebug"
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GEM
autoprefixer-rails (6.0.3)
execjs
json
basiccache (1.0.0)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
Expand Down Expand Up @@ -69,6 +70,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
curb (0.8.8)
database_cleaner (1.5.0)
debug_inspector (0.0.2)
diff-lcs (1.2.5)
Expand All @@ -78,6 +80,10 @@ GEM
multipart-post (>= 1.2, < 3)
figaro (1.1.1)
thor (~> 0.14)
githubstats (1.1.0)
basiccache (~> 1.0.0)
curb (~> 0.8.6)
nokogiri (~> 1.6.5)
globalid (0.3.6)
activesupport (>= 4.1.0)
hashie (3.4.2)
Expand Down Expand Up @@ -224,6 +230,7 @@ DEPENDENCIES
coffee-rails (~> 4.1.0)
database_cleaner
figaro
githubstats
hurley
jbuilder (~> 2.0)
jquery-rails
Expand Down
10 changes: 9 additions & 1 deletion app/presenters/github_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ def organizations
end

def year_commits
list = service.find_user_total_commits(user).map {|data| build_object(data)}
list = service.find_user_total_commits(user)
end

def current_streaks
list = service.find_user_current_streak(user)
end

def longest_streaks
list = service.find_user_longest_streak(user)
end

def starred_repos
Expand Down
13 changes: 11 additions & 2 deletions app/services/github_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ class GithubService
attr_reader :connection

def initialize(user)
@connection = Hurley::Client.new("https://api.github.com")
@connection = Hurley::Client.new("https://api.github.com")
@connection.query[:access_token] = user.token
@stats = GithubStats.new('bad6e')
end

def find_user_repos(user)
Expand All @@ -23,7 +24,15 @@ def find_user_organizations(user)
end

def find_user_total_commits(user)
parse(connection.get("repos/#{user.nickname}/gitcommit/stats/commit_activity"))
@stats.data.scores.reduce(:+)
end

def find_user_current_streak(user)
@stats.streak.count
end

def find_user_longest_streak(user)
@stats.longest_streak.count
end

def total_starred_repos(user)
Expand Down
3 changes: 3 additions & 0 deletions app/views/dashboard/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
<br>
<div class="col-md-4 home">
<h4>Total Commits</h4>
<p><%= @info.year_commits %></pr>
</div>
<div class="col-md-4 home">
<h4>Current Streak</h4>
<p><%= @info.current_streaks %></pr>
</div>
<div class="col-md-4 home">
<h4>Longest Streak</h4>
<p><%= @info.longest_streaks %></pr>
</div>
</div>

Expand Down