diff options
| author | mo khan <mo@mokhan.ca> | 2021-12-21 11:05:45 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2021-12-21 11:05:45 -0700 |
| commit | 1bddcfef7b451fcf2282d4cf87bbd2f3ec922081 (patch) | |
| tree | 42d4d166145faa84d47d6f4463769e77da79f723 /lib | |
| parent | 1da7737f8970000fc7bd592c19aa6c647d49c347 (diff) | |
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/shogun.rb | 5 | ||||
| -rw-r--r-- | lib/shogun/github_score.rb | 21 |
2 files changed, 9 insertions, 17 deletions
diff --git a/lib/shogun.rb b/lib/shogun.rb index 818e0a5..05b1a6a 100644 --- a/lib/shogun.rb +++ b/lib/shogun.rb @@ -3,3 +3,8 @@ require "uri" require "json" require "shogun/github_score" + +module Shogun + class UserNotFound < ArgumentError + end +end 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 |
