From 48cedf3ebe16e11d665cdb0698ab4523ca459258 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Fri, 19 Apr 2019 18:30:59 +0530 Subject: [PATCH] fix: retrieve posts in order by id. so we can find starting and ending id of the batch. --- lib/tasks/posts.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake index 9f612a55a1..c237ebe913 100644 --- a/lib/tasks/posts.rake +++ b/lib/tasks/posts.rake @@ -399,7 +399,7 @@ task 'posts:missing_uploads' => :environment do PostCustomField.where(name: Post::MISSING_UPLOADS).delete_all count = 0 - Post.have_uploads.select(:id, :cooked).find_in_batches do |posts| + Post.have_uploads.order(:id).select(:id, :cooked).find_in_batches do |posts| ids = posts.pluck(:id) sha1s = Upload.joins(:post_uploads).where("post_uploads.post_id >= ? AND post_uploads.post_id <= ?", ids.min, ids.max).pluck(:sha1)