Skip to content

Commit

Permalink
FIX: Keep by_users check in S3 inventory
Browse files Browse the repository at this point in the history
Partial revert of 8515d8f - the by_users check is ensuring we don't raise errors for fixtures
  • Loading branch information
davidtaylorhq committed Jul 21, 2020
1 parent ef37460 commit ec4024f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/s3_inventory.rb
Expand Up @@ -62,6 +62,8 @@ def backfill_etags_and_list_missing
#{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")
Expand Down
6 changes: 3 additions & 3 deletions spec/components/s3_inventory_spec.rb
Expand Up @@ -67,7 +67,7 @@

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)
Expand All @@ -76,8 +76,8 @@
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
Expand Down

0 comments on commit ec4024f

Please sign in to comment.