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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a15e9f02
Commit
a15e9f02
authored
Aug 11, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce contributions calendar data payload
parent
cd6157d5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
22 deletions
+58
-22
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+8
-0
app/assets/javascripts/users/calendar.js
app/assets/javascripts/users/calendar.js
+30
-21
lib/gitlab/contributions_calendar.rb
lib/gitlab/contributions_calendar.rb
+0
-1
spec/javascripts/datetime_utility_spec.js.coffee
spec/javascripts/datetime_utility_spec.js.coffee
+19
-0
No files found.
CHANGELOG
View file @
a15e9f02
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.12.0 (unreleased)
v 8.12.0 (unreleased)
- Change merge_error column from string to text type
- Change merge_error column from string to text type
- Reduce contributions calendar data payload (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)
- Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
- Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
- Add `wiki_page_events` to project hook APIs (Ben Boeckel)
- Add `wiki_page_events` to project hook APIs (Ben Boeckel)
...
...
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
a15e9f02
...
@@ -67,6 +67,14 @@
...
@@ -67,6 +67,14 @@
$
.
timeago
.
settings
.
strings
=
tmpLocale
;
$
.
timeago
.
settings
.
strings
=
tmpLocale
;
};
};
w
.
gl
.
utils
.
getDayDifference
=
function
(
a
,
b
)
{
var
millisecondsPerDay
=
1000
*
60
*
60
*
24
;
var
date1
=
Date
.
UTC
(
a
.
getFullYear
(),
a
.
getMonth
(),
a
.
getDate
());
var
date2
=
Date
.
UTC
(
b
.
getFullYear
(),
b
.
getMonth
(),
b
.
getDate
());
return
Math
.
floor
((
date2
-
date1
)
/
millisecondsPerDay
);
}
})(
window
);
})(
window
);
}).
call
(
this
);
}).
call
(
this
);
app/assets/javascripts/users/calendar.js
View file @
a15e9f02
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
this
.
Calendar
=
(
function
()
{
this
.
Calendar
=
(
function
()
{
function
Calendar
(
timestamps
,
calendar_activities_path
)
{
function
Calendar
(
timestamps
,
calendar_activities_path
)
{
var
group
,
i
;
this
.
calendar_activities_path
=
calendar_activities_path
;
this
.
calendar_activities_path
=
calendar_activities_path
;
this
.
clickDay
=
bind
(
this
.
clickDay
,
this
);
this
.
clickDay
=
bind
(
this
.
clickDay
,
this
);
this
.
currentSelectedDate
=
''
;
this
.
currentSelectedDate
=
''
;
...
@@ -13,26 +12,36 @@
...
@@ -13,26 +12,36 @@
this
.
monthNames
=
[
'
Jan
'
,
'
Feb
'
,
'
Mar
'
,
'
Apr
'
,
'
May
'
,
'
Jun
'
,
'
Jul
'
,
'
Aug
'
,
'
Sep
'
,
'
Oct
'
,
'
Nov
'
,
'
Dec
'
];
this
.
monthNames
=
[
'
Jan
'
,
'
Feb
'
,
'
Mar
'
,
'
Apr
'
,
'
May
'
,
'
Jun
'
,
'
Jul
'
,
'
Aug
'
,
'
Sep
'
,
'
Oct
'
,
'
Nov
'
,
'
Dec
'
];
this
.
months
=
[];
this
.
months
=
[];
this
.
timestampsTmp
=
[];
this
.
timestampsTmp
=
[];
i
=
0
;
var
group
=
0
;
group
=
0
;
_
.
each
(
timestamps
,
(
function
(
_this
)
{
var
today
=
new
Date
()
return
function
(
count
,
date
)
{
today
.
setHours
(
0
,
0
,
0
,
0
,
0
);
var
day
,
innerArray
,
newDate
;
newDate
=
new
Date
(
parseInt
(
date
)
*
1000
);
var
oneYearAgo
=
new
Date
(
today
);
day
=
newDate
.
getDay
();
oneYearAgo
.
setFullYear
(
today
.
getFullYear
()
-
1
);
if
((
day
===
0
&&
i
!==
0
)
||
i
===
0
)
{
_this
.
timestampsTmp
.
push
([]);
var
days
=
gl
.
utils
.
getDayDifference
(
oneYearAgo
,
today
);
group
++
;
}
for
(
var
i
=
0
;
i
<=
days
;
i
++
)
{
innerArray
=
_this
.
timestampsTmp
[
group
-
1
];
var
date
=
new
Date
(
oneYearAgo
);
innerArray
.
push
({
date
.
setDate
(
date
.
getDate
()
+
i
);
count
:
count
,
date
:
newDate
,
var
day
=
date
.
getDay
();
day
:
day
var
count
=
timestamps
[
date
.
getTime
()
*
0.001
];
});
return
i
++
;
if
((
day
===
0
&&
i
!==
0
)
||
i
===
0
)
{
};
this
.
timestampsTmp
.
push
([]);
})(
this
));
group
++
;
}
var
innerArray
=
this
.
timestampsTmp
[
group
-
1
];
innerArray
.
push
({
count
:
count
||
0
,
date
:
date
,
day
:
day
});
}
this
.
colorKey
=
this
.
initColorKey
();
this
.
colorKey
=
this
.
initColorKey
();
this
.
color
=
this
.
initColor
();
this
.
color
=
this
.
initColor
();
this
.
renderSvg
(
group
);
this
.
renderSvg
(
group
);
...
...
lib/gitlab/contributions_calendar.rb
View file @
a15e9f02
...
@@ -23,7 +23,6 @@ module Gitlab
...
@@ -23,7 +23,6 @@ module Gitlab
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
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
...
...
spec/javascripts/datetime_utility_spec.js.coffee
View file @
a15e9f02
...
@@ -29,3 +29,22 @@ describe 'Date time utils', ->
...
@@ -29,3 +29,22 @@ describe 'Date time utils', ->
it
'should return Saturday'
,
->
it
'should return Saturday'
,
->
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/23/2016'
))
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/23/2016'
))
expect
(
day
).
toBe
(
'Saturday'
)
expect
(
day
).
toBe
(
'Saturday'
)
describe
'get day difference'
,
->
it
'should return 7'
,
->
firstDay
=
new
Date
(
'07/01/2016'
)
secondDay
=
new
Date
(
'07/08/2016'
)
difference
=
gl
.
utils
.
getDayDifference
(
firstDay
,
secondDay
)
expect
(
difference
).
toBe
(
7
)
it
'should return 31'
,
->
firstDay
=
new
Date
(
'07/01/2016'
)
secondDay
=
new
Date
(
'08/01/2016'
)
difference
=
gl
.
utils
.
getDayDifference
(
firstDay
,
secondDay
)
expect
(
difference
).
toBe
(
31
)
it
'should return 365'
,
->
firstDay
=
new
Date
(
'07/02/2015'
)
secondDay
=
new
Date
(
'07/01/2016'
)
difference
=
gl
.
utils
.
getDayDifference
(
firstDay
,
secondDay
)
expect
(
difference
).
toBe
(
365
)
\ No newline at end of file
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