diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-08-01 10:07:31 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-08-01 10:07:31 +0300 |
commit | e53e4d45296c32e699b98cefdcb4bcde5e1a44bf (patch) | |
tree | df8346a2d7e6adad73abc9d05403870057a3b968 | |
parent | 9b433c370688ddb4be261915da6aeb8327429966 (diff) | |
parent | 188692ad2842c2e69c7ffeee0f04b19ae5455b9b (diff) |
Merge branch 'floating-avarage-commit-numbers' into 'master'
Show one digit after dot in commit_per_day value in charts page.
Closes #26512
See merge request gitlab-org/gitlab-ce!20896
-rw-r--r-- | changelogs/unreleased/floating-avarage-commit-numbers.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/graphs/commits.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/graphs/commits_spec.rb | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/changelogs/unreleased/floating-avarage-commit-numbers.yml b/changelogs/unreleased/floating-avarage-commit-numbers.yml new file mode 100644 index 00000000000..7f91ab16af4 --- /dev/null +++ b/changelogs/unreleased/floating-avarage-commit-numbers.yml @@ -0,0 +1,5 @@ +--- +title: Show one digit after dot in commit_per_day value in charts page. +merge_request: +author: msdundar +type: changed diff --git a/lib/gitlab/graphs/commits.rb b/lib/gitlab/graphs/commits.rb index 3caf9036459..c4ffc19df09 100644 --- a/lib/gitlab/graphs/commits.rb +++ b/lib/gitlab/graphs/commits.rb @@ -18,7 +18,7 @@ module Gitlab end def commit_per_day - @commit_per_day ||= @commits.size / (@duration + 1) + @commit_per_day ||= (@commits.size.to_f / (@duration + 1)).round(1) end def collect_data diff --git a/spec/lib/gitlab/graphs/commits_spec.rb b/spec/lib/gitlab/graphs/commits_spec.rb index b2084f56640..530d4a981bf 100644 --- a/spec/lib/gitlab/graphs/commits_spec.rb +++ b/spec/lib/gitlab/graphs/commits_spec.rb @@ -29,7 +29,7 @@ describe Gitlab::Graphs::Commits do 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 } + it { expect(subject.commit_per_day).to eq 1.0 } end describe '#duration' do |