DEV: Get only matching records to backfill etags

This commit is contained in:
Vinoth Kannan 2019-02-14 06:27:18 +05:30
parent e2f7db5549
commit a9a8855739
1 changed files with 1 additions and 1 deletions

View File

@ -47,7 +47,7 @@ class S3Inventory
end
if backfill_etags
uploads = model.where(etag: nil).joins("LEFT JOIN #{table_name} ON #{model.table_name}.url ILIKE '%' || #{table_name}.key")
uploads = model.where(etag: nil).joins("INNER JOIN #{table_name} ON #{model.table_name}.url ILIKE '%' || #{table_name}.key")
uploads.select(:id, :"#{table_name}.etag").find_each do |upload|
model.where(id: upload.id).update_all(etag: upload.etag)
end