gitlab-org--gitlab-foss/app/models/project_contributions.rb
Dmitriy Zaporozhets f1cf49218f Improve contribution calendar on user page
* cache user contributions for day
* ignore forks in calendar contribtuions
2015-01-29 17:07:44 -08:00

23 lines
451 B
Ruby

class ProjectContributions
attr_reader :project, :user
def initialize(project, user)
@project, @user = project, user
end
def commits_log
repository = project.repository
if !repository.exists? || repository.empty?
return {}
end
Rails.cache.fetch(cache_key) do
repository.commits_per_day_for_user(user)
end
end
def cache_key
"#{Date.today.to_s}-commits-log-#{project.id}-#{user.email}"
end
end