DEV: Add `START_ID` to `uploads:downsize` task (#18992)

This commit is contained in:
Jarek Radosz 2022-11-11 22:51:48 +01:00 committed by GitHub
parent 88ede43ec5
commit e54a3d5ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -1088,7 +1088,10 @@ end
# WORKER_ID/WORKER_COUNT
# When running the script on a single forum in multiple terminals.
# For example, if you want 4 concurrent scripts use WORKER_COUNT=4
# and WORKER_ID from 0 to 3
# and WORKER_ID from 0 to 3.
#
# START_ID
# Skip uploads with id lower than START_ID.
task "uploads:downsize" => :environment do
min_image_pixels = 500_000 # 0.5 megapixels
default_image_pixels = 1_000_000 # 1 megapixel
@ -1126,6 +1129,10 @@ task "uploads:downsize" => :environment do
scope = scope.where("uploads.id % ? = ?", ENV["WORKER_COUNT"], ENV["WORKER_ID"])
end
if ENV["START_ID"]
scope = scope.where("uploads.id >= ?", ENV["START_ID"])
end
skipped = 0
total_count = scope.count
puts "Uploads to process: #{total_count}"