Commit c4c80899 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq

parents 7a5784ec 95ec0442
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
&.s24 { margin-right: 4px; } &.s24 { margin-right: 4px; }
} }
&.avatar-tile {
@include border-radius(0px);
}
&.s16 { width: 16px; height: 16px; margin-right: 6px; } &.s16 { width: 16px; height: 16px; margin-right: 6px; }
&.s24 { width: 24px; height: 24px; margin-right: 8px; } &.s24 { width: 24px; height: 24px; margin-right: 8px; }
&.s26 { width: 26px; height: 26px; margin-right: 8px; } &.s26 { width: 26px; height: 26px; margin-right: 8px; }
......
...@@ -28,13 +28,10 @@ class UsersController < ApplicationController ...@@ -28,13 +28,10 @@ class UsersController < ApplicationController
def calendar def calendar
visible_projects = ProjectsFinder.new.execute(current_user) visible_projects = ProjectsFinder.new.execute(current_user)
calendar = Gitlab::CommitsCalendar.new(visible_projects, @user)
# Get user repositories and collect timestamps for commits
user_repositories = visible_projects.map(&:repository)
calendar = Gitlab::CommitsCalendar.new(user_repositories, @user)
@timestamps = calendar.timestamps @timestamps = calendar.timestamps
@starting_year = (Time.now - 1.year).strftime("%Y") @starting_year = calendar.starting_year
@starting_month = Date.today.strftime("%m").to_i @starting_month = calendar.starting_month
render 'calendar', layout: false render 'calendar', layout: false
end end
......
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
.dashboard .dashboard
%div %div
= image_tag group_icon(@group.path), class: "avatar s90" = image_tag group_icon(@group.path), class: "avatar avatar-tile s90"
.clearfix .clearfix
%h2 %h2
= @group.name = @group.name
......
%h4 Calendar: %h4 Calendar
#cal-heatmap.calendar #cal-heatmap.calendar
:javascript :javascript
new calendar( new calendar(
......
.row .row
.col-md-8 .col-md-8
%h3.page-title %h3.page-title
= image_tag avatar_icon(@user.email, 90), class: "avatar s90", alt: '' = image_tag avatar_icon(@user.email, 90), class: "avatar avatar-tile s90", alt: ''
= @user.name = @user.name
- if @user == current_user - if @user == current_user
.pull-right .pull-right
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
.clearfix .clearfix
- if @groups.any? - if @groups.any?
%h4 Groups: %h4 Groups
= render 'groups', groups: @groups = render 'groups', groups: @groups
%hr %hr
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
%i.fa.fa-spinner.fa-spin %i.fa.fa-spinner.fa-spin
%hr %hr
%h4 %h4
User Activity: User Activity
- if current_user - if current_user
%span.rss-icon.pull-right %span.rss-icon.pull-right
......
...@@ -2,15 +2,15 @@ module Gitlab ...@@ -2,15 +2,15 @@ module Gitlab
class CommitsCalendar class CommitsCalendar
attr_reader :timestamps attr_reader :timestamps
def initialize(repositories, user) def initialize(projects, user)
@timestamps = {} @timestamps = {}
date_timestamps = [] date_timestamps = []
repositories.select(&:exists?).reject(&:empty?).each do |raw_repository| projects.reject(&:forked?).each do |project|
commits_log = raw_repository.commits_per_day_for_user(user) date_timestamps << ProjectContributions.new(project, user).commits_log
date_timestamps << commits_log
end end
# Sumarrize commits from all projects per days
date_timestamps = date_timestamps.inject do |collection, date| date_timestamps = date_timestamps.inject do |collection, date|
collection.merge(date) { |k, old_v, new_v| old_v + new_v } collection.merge(date) { |k, old_v, new_v| old_v + new_v }
end end
...@@ -21,5 +21,13 @@ module Gitlab ...@@ -21,5 +21,13 @@ module Gitlab
@timestamps[timestamp] = commits if timestamp @timestamps[timestamp] = commits if timestamp
end end
end end
def starting_year
(Time.now - 1.year).strftime("%Y")
end
def starting_month
Date.today.strftime("%m").to_i
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment