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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
382e8cfe
Commit
382e8cfe
authored
May 20, 2016
by
Jonas Weber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Infinity Bug in Commit Statistics
fixes #1548
parent
c5a5d548
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
lib/gitlab/graphs/commits.rb
lib/gitlab/graphs/commits.rb
+1
-1
spec/lib/gitlab/graphs/commits_spec.rb
spec/lib/gitlab/graphs/commits_spec.rb
+39
-0
No files found.
lib/gitlab/graphs/commits.rb
View file @
382e8cfe
...
@@ -18,7 +18,7 @@ module Gitlab
...
@@ -18,7 +18,7 @@ module Gitlab
end
end
def
commit_per_day
def
commit_per_day
@commit_per_day
||=
(
@commits
.
size
.
to_f
/
@duration
).
round
(
1
)
@commit_per_day
||=
@commits
.
size
/
(
@duration
+
1
)
end
end
def
collect_data
def
collect_data
...
...
spec/lib/gitlab/graphs/commits_spec.rb
0 → 100644
View file @
382e8cfe
require
'spec_helper'
describe
Gitlab
::
Graphs
::
Commits
,
lib:
true
do
let!
(
:project
)
{
create
(
:project
,
:public
,
:empty_repo
)
}
let!
(
:commit1
)
{
create
(
:commit
,
git_commit:
RepoHelpers
.
sample_commit
,
project:
project
,
committed_date:
Time
.
now
)
}
let!
(
:commit1_yesterday
)
{
create
(
:commit
,
git_commit:
RepoHelpers
.
sample_commit
,
project:
project
,
committed_date:
1
.
day
.
ago
)}
let!
(
:commit2
)
{
create
(
:commit
,
git_commit:
RepoHelpers
.
another_sample_commit
,
project:
project
,
committed_date:
Time
.
now
)
}
describe
'#commit_per_day'
do
context
'when range is only commits from today'
do
subject
{
described_class
.
new
([
commit2
,
commit1
]).
commit_per_day
}
it
{
is_expected
.
to
eq
2
}
end
end
context
'when range is only commits from today'
do
subject
{
described_class
.
new
([
commit2
,
commit1
])
}
describe
'#commit_per_day'
do
it
{
expect
(
subject
.
commit_per_day
).
to
eq
2
}
end
describe
'#duration'
do
it
{
expect
(
subject
.
duration
).
to
eq
0
}
end
end
context
'with commits from yesterday and today'
do
subject
{
described_class
.
new
([
commit2
,
commit1_yesterday
])
}
describe
'#commit_per_day'
do
it
{
expect
(
subject
.
commit_per_day
).
to
eq
1
}
end
describe
'#duration'
do
it
{
expect
(
subject
.
duration
).
to
eq
1
}
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