Commit 9b06c6ca authored by Nick Thomas's avatar Nick Thomas

Merge branch 'lfs-storage-statistics' into 'master'

Fix LFS size computation with identical sizes

See merge request gitlab-org/gitlab!70610
parents 3cebe71a d2b2d298
......@@ -70,7 +70,7 @@ class ProjectStatistics < ApplicationRecord
end
def update_lfs_objects_size
self.lfs_objects_size = project.lfs_objects.sum(:size)
self.lfs_objects_size = LfsObject.joins(:lfs_objects_projects).where(lfs_objects_projects: { project_id: project.id }).sum(:size)
end
def update_uploads_size
......
......@@ -294,15 +294,17 @@ RSpec.describe ProjectStatistics do
describe '#update_lfs_objects_size' do
let!(:lfs_object1) { create(:lfs_object, size: 23.megabytes) }
let!(:lfs_object2) { create(:lfs_object, size: 34.megabytes) }
let!(:lfs_object3) { create(:lfs_object, size: 34.megabytes) }
let!(:lfs_objects_project1) { create(:lfs_objects_project, project: project, lfs_object: lfs_object1) }
let!(:lfs_objects_project2) { create(:lfs_objects_project, project: project, lfs_object: lfs_object2) }
let!(:lfs_objects_project3) { create(:lfs_objects_project, project: project, lfs_object: lfs_object3) }
before do
statistics.update_lfs_objects_size
end
it "stores the size of related LFS objects" do
expect(statistics.lfs_objects_size).to eq 57.megabytes
expect(statistics.lfs_objects_size).to eq 91.megabytes
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment