FIX: Improve S3 inventory logic

FIX: Improve S3 inventory logic

Previously we considered ‘upload rows without etags’ to be exempt from the check. This is bad, because older/migrated sites might not have etags on all their uploads. We should consider rows without etags to be broken, since we can’t check them against the inventory.

This also removes the by_users scope. We need all uploads to be working, even ones created by the system user.

diff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rb
index de273ce..903e50f 100644
--- a/lib/s3_inventory.rb
+++ b/lib/s3_inventory.rb
@@ -61,10 +61,10 @@ class S3Inventory
               WHERE #{model.table_name}.etag IS NULL AND
                 #{model.table_name}.url = #{table_name}.url")
 
-            uploads = model.by_users.where("updated_at < ?", inventory_date)
+            uploads = model.where("updated_at < ?", inventory_date)
             missing_uploads = uploads
               .joins("LEFT JOIN #{table_name} ON #{table_name}.etag = #{model.table_name}.etag")
-              .where("#{table_name}.etag IS NULL AND #{model.table_name}.etag IS NOT NULL")
+              .where("#{table_name}.etag IS NULL")
 
             if (missing_count = missing_uploads.count) > 0
               missing_uploads.select(:id, :url).find_each do |upload|

GitHub sha: 8515d8fa