diff options
Diffstat (limited to 'lib/shogun/github_score.rb')
| -rw-r--r-- | lib/shogun/github_score.rb | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/lib/shogun/github_score.rb b/lib/shogun/github_score.rb index 48947a0..22019ec 100644 --- a/lib/shogun/github_score.rb +++ b/lib/shogun/github_score.rb @@ -1,8 +1,5 @@ module Shogun - class UserNotFound < ArgumentError - end - - class GithubScore + class GitHubScore DEFAULT_POINTS = { "IssuesEvent" => 1, "IssueCommentEvent" => 2, @@ -18,7 +15,9 @@ module Shogun end def score - calculate_score_for(events) + events.sum do |event| + points.fetch(event["type"], 1) + end end private @@ -35,17 +34,5 @@ module Shogun JSON.parse(response.body) end - - def calculate_score_for(events) - grouped = events.group_by { |h| h["type"] }.values - score = grouped.map { |g| - event_type = g.first["type"].strip - event_score = points[event_type] || 1 - event_score * g.count - }.sum - score - end end - - end |
