Skip to content

Instantly share code, notes, and snippets.

@JacobNinja
Forked from Jimgerneer/ruby
Last active December 15, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JacobNinja/5267561 to your computer and use it in GitHub Desktop.
Save JacobNinja/5267561 to your computer and use it in GitHub Desktop.
class CommitScore
ScoreValue = Struct.new(:email, :score)
def initialize(commit_values)
@commit_values = commit_values
end
def score
grouped_commits_by_email.map {|(email, commits) score_value(email, commits) }
end
private
def grouped_commits_by_email
@commit_values.group_by(&:email)
end
def score_value(email, commits)
ScoreValue.new(email, score_commits(commits))
end
def score_commits(commits)
commits.map {|c| score_date(c.committed_date) }.reduce(:+)
end
def score_date(date)
# algo
1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment