DEV: save missing s3 uploads count in redis

approved
#1

DEV: save missing s3 uploads count in redis

diff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rb
index e0c8aed..e43ab37 100644
--- a/lib/s3_inventory.rb
+++ b/lib/s3_inventory.rb
@@ -58,6 +58,8 @@ class S3Inventory
           missing_uploads = uploads.joins("LEFT JOIN #{table_name} ON #{table_name}.etag = #{model.table_name}.etag").where("#{table_name}.etag is NULL")
 
           if (missing_count = missing_uploads.count) > 0
+            $redis.set("missing_s3_#{model.table_name}", missing_count)
+
             missing_uploads.select(:id, :url).find_each do |upload|
               log upload.url
             end
diff --git a/spec/components/s3_inventory_spec.rb b/spec/components/s3_inventory_spec.rb
index 3f81fb6..bed0345 100644
--- a/spec/components/s3_inventory_spec.rb
+++ b/spec/components/s3_inventory_spec.rb
@@ -75,6 +75,7 @@ describe "S3Inventory" do
     end
 
     expect(output).to eq("#{upload.url}\n1 of 4 uploads are missing\n")
+    expect($redis.get("missing_s3_uploads")).to eq("1")
   end
 
   it "should backfill etags to uploads table correctly" do

GitHub sha: df6ef856

#3

We should probably have a helper method here and also set it with some sort of expiry, even 1 month is fine.

2 Likes
Follow Up #4
#6

It’s already done as per commit

Approved #7