Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
a15e9f02
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a15e9f02
编写于
8月 11, 2016
作者:
C
Clement Ho
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce contributions calendar data payload
上级
cd6157d5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
58 addition
and
22 deletion
+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
未找到文件。
CHANGELOG
浏览文件 @
a15e9f02
...
...
@@ -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)
- 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)
- Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
- Add `wiki_page_events` to project hook APIs (Ben Boeckel)
...
...
app/assets/javascripts/lib/utils/datetime_utility.js
浏览文件 @
a15e9f02
...
...
@@ -67,6 +67,14 @@
$
.
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
);
}).
call
(
this
);
app/assets/javascripts/users/calendar.js
浏览文件 @
a15e9f02
...
...
@@ -3,7 +3,6 @@
this
.
Calendar
=
(
function
()
{
function
Calendar
(
timestamps
,
calendar_activities_path
)
{
var
group
,
i
;
this
.
calendar_activities_path
=
calendar_activities_path
;
this
.
clickDay
=
bind
(
this
.
clickDay
,
this
);
this
.
currentSelectedDate
=
''
;
...
...
@@ -13,26 +12,36 @@
this
.
monthNames
=
[
'
Jan
'
,
'
Feb
'
,
'
Mar
'
,
'
Apr
'
,
'
May
'
,
'
Jun
'
,
'
Jul
'
,
'
Aug
'
,
'
Sep
'
,
'
Oct
'
,
'
Nov
'
,
'
Dec
'
];
this
.
months
=
[];
this
.
timestampsTmp
=
[];
i
=
0
;
group
=
0
;
_
.
each
(
timestamps
,
(
function
(
_this
)
{
return
function
(
count
,
date
)
{
var
day
,
innerArray
,
newDate
;
newDate
=
new
Date
(
parseInt
(
date
)
*
1000
);
day
=
newDate
.
getDay
();
if
((
day
===
0
&&
i
!==
0
)
||
i
===
0
)
{
_this
.
timestampsTmp
.
push
([]);
group
++
;
}
innerArray
=
_this
.
timestampsTmp
[
group
-
1
];
innerArray
.
push
({
count
:
count
,
date
:
newDate
,
day
:
day
});
return
i
++
;
};
})(
this
));
var
group
=
0
;
var
today
=
new
Date
()
today
.
setHours
(
0
,
0
,
0
,
0
,
0
);
var
oneYearAgo
=
new
Date
(
today
);
oneYearAgo
.
setFullYear
(
today
.
getFullYear
()
-
1
);
var
days
=
gl
.
utils
.
getDayDifference
(
oneYearAgo
,
today
);
for
(
var
i
=
0
;
i
<=
days
;
i
++
)
{
var
date
=
new
Date
(
oneYearAgo
);
date
.
setDate
(
date
.
getDate
()
+
i
);
var
day
=
date
.
getDay
();
var
count
=
timestamps
[
date
.
getTime
()
*
0.001
];
if
((
day
===
0
&&
i
!==
0
)
||
i
===
0
)
{
this
.
timestampsTmp
.
push
([]);
group
++
;
}
var
innerArray
=
this
.
timestampsTmp
[
group
-
1
];
innerArray
.
push
({
count
:
count
||
0
,
date
:
date
,
day
:
day
});
}
this
.
colorKey
=
this
.
initColorKey
();
this
.
color
=
this
.
initColor
();
this
.
renderSvg
(
group
);
...
...
lib/gitlab/contributions_calendar.rb
浏览文件 @
a15e9f02
...
...
@@ -23,7 +23,6 @@ module Gitlab
dates
.
each
do
|
date
|
date_id
=
date
.
to_time
.
to_i
.
to_s
@timestamps
[
date_id
]
=
0
day_events
=
events
.
find
{
|
day_events
|
day_events
[
"date"
]
==
date
}
if
day_events
...
...
spec/javascripts/datetime_utility_spec.js.coffee
浏览文件 @
a15e9f02
...
...
@@ -29,3 +29,22 @@ describe 'Date time utils', ->
it
'should return Saturday'
,
->
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/23/2016'
))
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录