From 22aef3d424187b2178698af7d4f2dda1aef43cb8 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Thu, 18 Jan 2018 02:31:19 +0000 Subject: Fix a bug calculating artifact size for project statistics --- app/models/project_statistics.rb | 2 +- changelogs/unreleased/42154-fix-artifact-size-calc.yml | 5 +++++ spec/models/project_statistics_spec.rb | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/42154-fix-artifact-size-calc.yml diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb index 17b9d2cf7b4..87a4350f022 100644 --- a/app/models/project_statistics.rb +++ b/app/models/project_statistics.rb @@ -37,7 +37,7 @@ class ProjectStatistics < ActiveRecord::Base def update_build_artifacts_size self.build_artifacts_size = project.builds.sum(:artifacts_size) + - Ci::JobArtifact.artifacts_size_for(self) + Ci::JobArtifact.artifacts_size_for(self.project) end def update_storage_size diff --git a/changelogs/unreleased/42154-fix-artifact-size-calc.yml b/changelogs/unreleased/42154-fix-artifact-size-calc.yml new file mode 100644 index 00000000000..3d6911abf09 --- /dev/null +++ b/changelogs/unreleased/42154-fix-artifact-size-calc.yml @@ -0,0 +1,5 @@ +--- +title: Fix a bug calculating artifact size for project statistics +merge_request: 16539 +author: +type: fixed diff --git a/spec/models/project_statistics_spec.rb b/spec/models/project_statistics_spec.rb index e78ed1df821..5cff2af4aca 100644 --- a/spec/models/project_statistics_spec.rb +++ b/spec/models/project_statistics_spec.rb @@ -146,6 +146,12 @@ describe ProjectStatistics do expect(statistics.build_artifacts_size).to be(106365) end + + it 'calculates related build artifacts by project' do + expect(Ci::JobArtifact).to receive(:artifacts_size_for).with(project) { 0 } + + statistics.update_build_artifacts_size + end end context 'when legacy artifacts are used' do -- cgit v1.2.1