FIX: Rake tasks related to uploads were broken (#17085)

This commit is contained in:
Gerhard Schlager 2022-06-14 11:05:03 +02:00 committed by GitHub
parent 4a240f6c90
commit 96e87af605
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 9 deletions

View File

@ -857,11 +857,11 @@ end
def analyze_missing_s3 def analyze_missing_s3
puts "List of posts with missing images:" puts "List of posts with missing images:"
sql = <<~SQL 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 FROM upload_references ur
RIGHT JOIN uploads on uploads.id = ur.upload_id RIGHT JOIN uploads u ON u.id = ur.upload_id
WHERE ur.target_type = 'Post' AND verification_status = :invalid_etag WHERE ur.target_type = 'Post' AND u.verification_status = :invalid_etag
ORDER BY created_at ORDER BY ur.created_at
SQL SQL
lookup = {} 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" puts "Rebaking posts with missing uploads, this can take a while as all rebaking runs inline"
sql = <<~SQL sql = <<~SQL
SELECT target_id SELECT ur.target_id
FROM upload_references ur FROM upload_references ur
JOIN uploads on uploads.id = ur.upload_id JOIN uploads u ON u.id = ur.upload_id
WHERE ur.target_type = 'Post' WHERE ur.target_type = 'Post' AND u.verification_status = :invalid_etag
WHERE verification_status = :invalid_etag ORDER BY ur.target_id DESC
ORDER BY target_id DESC
SQL SQL
DB.query_single(sql, invalid_etag: Upload.verification_statuses[:invalid_etag]).each do |post_id| DB.query_single(sql, invalid_etag: Upload.verification_statuses[:invalid_etag]).each do |post_id|