I've created a method to group all the commits of a user per month into a hash:
def calculate_month_ranking(commits)
rank = Hash.new(Hash.new(0))
commits.each do |commit_yml|
commit = YAML.load commit_yml.data
commit[:commits].each do |local_commit|
time = Time.parse(local_commit[:timestamp])
month = "#{time.month}/#{time.year}"
rank[month][commit[:user_name]]+= 1
binding.pry # para debug
end
end
rank
end
The result is that when retrieving data by month the data appears, but the rank
variable is empty as you can see in the debug below
[1] pry(main)> rank[month]
=> {"user1"=>4, "user2"=>1}
[2] pry(main)> rank
=> {}