Skip to content

A platform for community discussion. Free, open, simple.

fix: retrieve posts in order by id.

Vinoth Kannan48cedf3ebe16
diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake
index 9f612a55a1b..c237ebe913a 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)