diff --git a/lib/gitlab/graphs/commits.rb b/lib/gitlab/graphs/commits.rb
index 2122339d2db89cbe72393837b713e274626d2dff..3caf90364592ba5fe48ca9ed04456d0dacd5db6d 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.to_f / @duration).round(1)
+        @commit_per_day ||= @commits.size / (@duration + 1)
       end
 
       def collect_data
diff --git a/spec/lib/gitlab/graphs/commits_spec.rb b/spec/lib/gitlab/graphs/commits_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..f5c064303ad11292f9323967d05120b61a8b9061
--- /dev/null
+++ b/spec/lib/gitlab/graphs/commits_spec.rb
@@ -0,0 +1,39 @@
+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