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
Jérome Perrin
gitlab-ce
Commits
a147b43d
Commit
a147b43d
authored
Sep 13, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace contributions calendar timezone payload with dates
parent
1c2aa4f8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
13 deletions
+52
-13
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/users/calendar.js
app/assets/javascripts/users/calendar.js
+1
-1
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+1
-1
app/views/users/calendar.html.haml
app/views/users/calendar.html.haml
+2
-2
lib/gitlab/contributions_calendar.rb
lib/gitlab/contributions_calendar.rb
+8
-9
spec/features/calendar_spec.rb
spec/features/calendar_spec.rb
+39
-0
No files found.
CHANGELOG
View file @
a147b43d
...
@@ -30,6 +30,7 @@ v 8.12.0 (unreleased)
...
@@ -30,6 +30,7 @@ v 8.12.0 (unreleased)
- Fix file permissions change when updating a file on the Gitlab UI !5979
- Fix file permissions change when updating a file on the Gitlab UI !5979
- Change merge_error column from string to text type
- Change merge_error column from string to text type
- Reduce contributions calendar data payload (ClemMakesApps)
- Reduce contributions calendar data payload (ClemMakesApps)
- Replace contributions calendar timezone payload with dates (ClemMakesApps)
- Add `web_url` field to issue, merge request, and snippet API objects (Ben Boeckel)
- Add `web_url` field to issue, merge request, and snippet API objects (Ben Boeckel)
- Enable pipeline events by default !6278
- Enable pipeline events by default !6278
- Move parsing of sidekiq ps into helper !6245 (pascalbetz)
- Move parsing of sidekiq ps into helper !6245 (pascalbetz)
...
...
app/assets/javascripts/users/calendar.js
View file @
a147b43d
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
date
.
setDate
(
date
.
getDate
()
+
i
);
date
.
setDate
(
date
.
getDate
()
+
i
);
var
day
=
date
.
getDay
();
var
day
=
date
.
getDay
();
var
count
=
timestamps
[
date
.
getTime
()
*
0.001
];
var
count
=
timestamps
[
date
Format
(
date
,
'
yyyy-mm-dd
'
)
];
// Create a new group array if this is the first day of the week
// Create a new group array if this is the first day of the week
// or if is first object
// or if is first object
...
...
app/controllers/users_controller.rb
View file @
a147b43d
...
@@ -73,7 +73,7 @@ class UsersController < ApplicationController
...
@@ -73,7 +73,7 @@ class UsersController < ApplicationController
def
calendar
def
calendar
calendar
=
contributions_calendar
calendar
=
contributions_calendar
@
timestamps
=
calendar
.
timestamp
s
@
activity_dates
=
calendar
.
activity_date
s
render
'calendar'
,
layout:
false
render
'calendar'
,
layout:
false
end
end
...
...
app/views/users/calendar.html.haml
View file @
a147b43d
...
@@ -4,6 +4,6 @@
...
@@ -4,6 +4,6 @@
Summary of issues, merge requests, and push events
Summary of issues, merge requests, and push events
:javascript
:javascript
new
Calendar
(
new
Calendar
(
#{
@
timestamp
s
.
to_json
}
,
#{
@
activity_date
s
.
to_json
}
,
'
#{
user_calendar_activities_path
}
'
'
#{
user_calendar_activities_path
}
'
);
);
\ No newline at end of file
lib/gitlab/contributions_calendar.rb
View file @
a147b43d
module
Gitlab
module
Gitlab
class
ContributionsCalendar
class
ContributionsCalendar
attr_reader
:
timestamp
s
,
:projects
,
:user
attr_reader
:
activity_date
s
,
:projects
,
:user
def
initialize
(
projects
,
user
)
def
initialize
(
projects
,
user
)
@projects
=
projects
@projects
=
projects
@user
=
user
@user
=
user
end
end
def
timestamp
s
def
activity_date
s
return
@
timestamps
if
@timestamp
s
.
present?
return
@
activity_dates
if
@activity_date
s
.
present?
@
timestamp
s
=
{}
@
activity_date
s
=
{}
date_from
=
1
.
year
.
ago
date_from
=
1
.
year
.
ago
events
=
Event
.
reorder
(
nil
).
contributions
.
where
(
author_id:
user
.
id
).
events
=
Event
.
reorder
(
nil
).
contributions
.
where
(
author_id:
user
.
id
).
...
@@ -19,18 +19,17 @@ module Gitlab
...
@@ -19,18 +19,17 @@ module Gitlab
select
(
'date(created_at) as date, count(id) as total_amount'
).
select
(
'date(created_at) as date, count(id) as total_amount'
).
map
(
&
:attributes
)
map
(
&
:attributes
)
dates
=
(
1
.
year
.
ago
.
to_date
..
Date
.
today
).
to_a
activity_
dates
=
(
1
.
year
.
ago
.
to_date
..
Date
.
today
).
to_a
dates
.
each
do
|
date
|
activity_dates
.
each
do
|
date
|
date_id
=
date
.
to_time
.
to_i
.
to_s
day_events
=
events
.
find
{
|
day_events
|
day_events
[
"date"
]
==
date
}
day_events
=
events
.
find
{
|
day_events
|
day_events
[
"date"
]
==
date
}
if
day_events
if
day_events
@
timestamps
[
date_id
]
=
day_events
[
"total_amount"
]
@
activity_dates
[
date
]
=
day_events
[
"total_amount"
]
end
end
end
end
@
timestamp
s
@
activity_date
s
end
end
def
events_by_date
(
date
)
def
events_by_date
(
date
)
...
...
spec/features/calendar_spec.rb
0 → 100644
View file @
a147b43d
require
'spec_helper'
feature
'Contributions Calendar'
,
js:
true
,
feature:
true
do
include
WaitForAjax
let
(
:contributed_project
)
{
create
(
:project
,
:public
)
}
before
do
login_as
:user
issue_params
=
{
title:
'Bug in old browser'
}
Issues
::
CreateService
.
new
(
contributed_project
,
@user
,
issue_params
).
execute
# Push code contribution
push_params
=
{
project:
contributed_project
,
action:
Event
::
PUSHED
,
author_id:
@user
.
id
,
data:
{
commit_count:
3
}
}
Event
.
create
(
push_params
)
visit
@user
.
username
wait_for_ajax
end
it
'displays calendar'
,
js:
true
do
expect
(
page
).
to
have_css
(
'.js-contrib-calendar'
)
end
it
'displays calendar activity log'
,
js:
true
do
expect
(
find
(
'.content_list .event-note'
)).
to
have_content
"Bug in old browser"
end
it
'displays calendar activity square color'
,
js:
true
do
expect
(
page
).
to
have_selector
(
'.user-contrib-cell[fill=\'#acd5f2\']'
,
count:
1
)
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