diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-21 23:48:08 -0700 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-21 23:48:08 -0700 |
commit | 64891c6c40c6b670c2b50aab8ba56e3d47e30076 (patch) | |
tree | c0c02058708644a7b0287bdff10b30e23568bd3d /app/controllers | |
parent | 29f6b01d6343c08dc9fe1f6bdf95a645dd4e4cc0 (diff) | |
download | gitlab-ce-64891c6c40c6b670c2b50aab8ba56e3d47e30076.tar.gz |
Replace commits calendar with contributions calendar
* count opening of issues and merge requests
* dont trigger git repository - use events from database
* much-much faster since does not affected by repository size
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/users_controller.rb | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 68130eb128c..f39c820626f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -31,9 +31,7 @@ class UsersController < ApplicationController end def calendar - projects = Project.where(id: authorized_projects_ids & @user.contributed_projects_ids) - - calendar = Gitlab::CommitsCalendar.new(projects, @user) + calendar = contributions_calendar @timestamps = calendar.timestamps @starting_year = calendar.starting_year @starting_month = calendar.starting_month @@ -42,20 +40,13 @@ class UsersController < ApplicationController end def calendar_activities - projects = Project.where(id: authorized_projects_ids & @user.contributed_projects_ids) + @calendar_date = Date.parse(params[:date]) rescue nil + @events = [] - date = Date.parse(params[:date]) rescue nil - if date - @calendar_activities = Gitlab::CommitsCalendar.get_commits_for_date(projects, @user, date) - else - @calendar_activities = {} + if @calendar_date + @events = contributions_calendar.events_by_date(@calendar_date) end - # get the total number of unique commits - @commit_count = @calendar_activities.values.flatten.map(&:id).uniq.count - - @calendar_date = date - render 'calendar_activities', layout: false end @@ -82,4 +73,14 @@ class UsersController < ApplicationController @authorized_projects_ids ||= ProjectsFinder.new.execute(current_user).pluck(:id) end + + def contributed_projects + @contributed_projects = Project. + where(id: authorized_projects_ids & @user.contributed_projects_ids).reject(&:forked?) + end + + def contributions_calendar + @contributions_calendar ||= Gitlab::ContributionsCalendar. + new(contributed_projects, @user) + end end |