FIX: Keep by_users check in S3 inventory

Partial revert of 8515d8fa - the by_users check is ensuring we don't raise errors for fixtures
This commit is contained in:
David Taylor 2020-07-21 17:19:56 +01:00
parent ef37460c93
commit ec4024fe6d
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
2 changed files with 5 additions and 3 deletions

View File

@ -62,6 +62,8 @@ class S3Inventory
#{model.table_name}.url = #{table_name}.url")
uploads = model.where("updated_at < ?", inventory_date)
uploads = uploads.by_users if model == Upload
missing_uploads = uploads
.joins("LEFT JOIN #{table_name} ON #{table_name}.etag = #{model.table_name}.etag")
.where("#{table_name}.etag IS NULL")

View File

@ -67,7 +67,7 @@ describe "S3Inventory" do
upload = Fabricate(:upload, etag: "ETag", updated_at: 1.days.ago)
Fabricate(:upload, etag: "ETag2", updated_at: Time.now)
Fabricate(:upload, updated_at: 2.days.ago)
no_etag = Fabricate(:upload, updated_at: 2.days.ago)
inventory.expects(:files).returns([{ key: "Key", filename: "#{csv_filename}.gz" }]).times(3)
inventory.expects(:inventory_date).returns(Time.now)
@ -76,8 +76,8 @@ describe "S3Inventory" do
inventory.backfill_etags_and_list_missing
end
expect(output).to eq("#{upload.url}\n1 of 5 uploads are missing\n")
expect(Discourse.stats.get("missing_s3_uploads")).to eq(1)
expect(output).to eq("#{upload.url}\n#{no_etag.url}\n2 of 5 uploads are missing\n")
expect(Discourse.stats.get("missing_s3_uploads")).to eq(2)
end
it "should backfill etags to uploads table correctly" do