From 96e87af6053c39a4bf2f5e91d80a7025ff040b57 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Tue, 14 Jun 2022 11:05:03 +0200 Subject: [PATCH] FIX: Rake tasks related to uploads were broken (#17085) --- lib/tasks/uploads.rake | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake index 898f21cd972..8a12c168cef 100644 --- a/lib/tasks/uploads.rake +++ b/lib/tasks/uploads.rake @@ -857,11 +857,11 @@ end def analyze_missing_s3 puts "List of posts with missing images:" sql = <<~SQL - SELECT post_id, url, sha1, extension, uploads.id + SELECT ur.target_id, u.url, u.sha1, u.extension, u.id FROM upload_references ur - RIGHT JOIN uploads on uploads.id = ur.upload_id - WHERE ur.target_type = 'Post' AND verification_status = :invalid_etag - ORDER BY created_at + RIGHT JOIN uploads u ON u.id = ur.upload_id + WHERE ur.target_type = 'Post' AND u.verification_status = :invalid_etag + ORDER BY ur.created_at SQL lookup = {} @@ -1047,12 +1047,11 @@ def fix_missing_s3 puts "Rebaking posts with missing uploads, this can take a while as all rebaking runs inline" sql = <<~SQL - SELECT target_id + SELECT ur.target_id FROM upload_references ur - JOIN uploads on uploads.id = ur.upload_id - WHERE ur.target_type = 'Post' - WHERE verification_status = :invalid_etag - ORDER BY target_id DESC + JOIN uploads u ON u.id = ur.upload_id + WHERE ur.target_type = 'Post' AND u.verification_status = :invalid_etag + ORDER BY ur.target_id DESC SQL DB.query_single(sql, invalid_etag: Upload.verification_statuses[:invalid_etag]).each do |post_id|