Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
54aca18c
Commit
54aca18c
authored
Mar 22, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Contribution calendar will use events instead of commits to count contributions
parent
43afe46b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
14 deletions
+12
-14
app/views/users/calendar.html.haml
app/views/users/calendar.html.haml
+4
-1
features/steps/user.rb
features/steps/user.rb
+1
-1
lib/gitlab/contributions_calendar.rb
lib/gitlab/contributions_calendar.rb
+7
-12
No files found.
app/views/users/calendar.html.haml
View file @
54aca18c
%h4
Contributions calendar
%h4
Contributions calendar
.pull-right
%small
Issues, merge requests and push events
#cal-heatmap
.calendar
#cal-heatmap
.calendar
:javascript
:javascript
new
calendar
(
new
calendar
(
...
...
features/steps/user.rb
View file @
54aca18c
...
@@ -35,7 +35,7 @@ class Spinach::Features::User < Spinach::FeatureSteps
...
@@ -35,7 +35,7 @@ class Spinach::Features::User < Spinach::FeatureSteps
step
'I should see contributions calendar'
do
step
'I should see contributions calendar'
do
within
'.calendar'
do
within
'.calendar'
do
page
.
should
have_css
(
'.graph-rect.r
2.q2
'
)
page
.
should
have_css
(
'.graph-rect.r
3.q3
'
)
end
end
end
end
...
...
lib/gitlab/contributions_calendar.rb
View file @
54aca18c
...
@@ -15,25 +15,20 @@ module Gitlab
...
@@ -15,25 +15,20 @@ module Gitlab
date_to
=
Date
.
today
date_to
=
Date
.
today
events
=
Event
.
contributions
.
where
(
author_id:
user
.
id
).
events
=
Event
.
contributions
.
where
(
author_id:
user
.
id
).
where
(
"created_at > ?"
,
date_from
).
where
(
project_id:
projects
)
where
(
"created_at > ?"
,
date_from
).
where
(
project_id:
projects
).
group
(
'date(created_at)'
).
select
(
'date(created_at), count(id) as total_amount'
).
reorder
(
nil
).
map
(
&
:attributes
)
grouped_events
=
events
.
to_a
.
group_by
{
|
event
|
event
.
created_at
.
to_date
.
to_s
}
dates
=
(
1
.
year
.
ago
.
to_date
..
(
Date
.
today
+
1
.
day
)).
to_a
dates
=
(
1
.
year
.
ago
.
to_date
..
(
Date
.
today
+
1
.
day
)).
to_a
dates
.
each
do
|
date
|
dates
.
each
do
|
date
|
date_id
=
date
.
to_time
.
to_i
.
to_s
date_id
=
date
.
to_time
.
to_i
.
to_s
@timestamps
[
date_id
]
=
0
@timestamps
[
date_id
]
=
0
day_events
=
events
.
find
{
|
day_events
|
day_events
[
"date"
]
==
date
}
if
grouped_events
.
has_key?
(
date
.
to_s
)
if
day_events
grouped_events
[
date
.
to_s
].
each
do
|
event
|
@timestamps
[
date_id
]
=
day_events
[
"total_amount"
]
if
event
.
created_at
.
to_date
==
date
if
event
.
issue?
||
event
.
merge_request?
@timestamps
[
date_id
]
+=
1
elsif
event
.
push?
@timestamps
[
date_id
]
+=
event
.
commits_count
end
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment