mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
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:
parent
ef37460c93
commit
ec4024fe6d
@ -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")
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user