fix: retrieve posts in order by id.

so we can find starting and ending id of the batch.
This commit is contained in:
Vinoth Kannan 2019-04-19 18:30:59 +05:30
parent ce8d30f667
commit 48cedf3ebe

View File

@ -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)