From 59012fc0f7adedd69406d51370a6f263406f6bcf Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Wed, 22 May 2019 08:39:25 +1000 Subject: [PATCH] PERF: mark posts for rebake vs forcing a rebake inline when migrating to s3 Rebaking posts can be expensive instead of blocking here simply mark posts for rebake. We can then work through them faster in other jobs, plus this should not hold of a datacenter migration. --- lib/tasks/uploads.rake | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake index ebeeca9e7a..b322c70d18 100644 --- a/lib/tasks/uploads.rake +++ b/lib/tasks/uploads.rake @@ -475,13 +475,10 @@ def migrate_to_s3 .where("u.id IS NOT NULL AND u.url LIKE '//%' AND optimized_images.url NOT LIKE '//%'") .delete_all - puts "Rebaking posts with lightboxes..." + puts "Flagging all posts containing oneboxes for rebake..." - Post.where("cooked LIKE '%class=\"lightbox\"%'").find_each do |post| - putc "." - post.rebake!(priority: :ultra_low) - end - puts + count = Post.where("cooked LIKE '%class=\"lightbox\"%'").update_all(baked_version: Post::BAKED_VERSION - 1) + puts "#{count} posts were flagged for a rebake" end end