From 635393b50bae8fea3eb8e78ae423707c34b1f554 Mon Sep 17 00:00:00 2001 From: msdundar Date: Mon, 30 Jul 2018 03:37:47 +0300 Subject: [PATCH] Show one digit after dot in commit_per_day value in charts page. Closes #26512 --- changelogs/unreleased/floating-avarage-commit-numbers.yml | 5 +++++ lib/gitlab/graphs/commits.rb | 2 +- spec/lib/gitlab/graphs/commits_spec.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/floating-avarage-commit-numbers.yml 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..035d97cccbc 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 0.7 } end describe '#duration' do