From bfdd0fe64cc90707569a158b0dbdecedf3d03986 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Wed, 10 Apr 2019 11:20:26 +0530 Subject: [PATCH] FIX: empty the missing list on each post loop --- lib/tasks/posts.rake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake index 09f2242ac3..adbc892238 100644 --- a/lib/tasks/posts.rake +++ b/lib/tasks/posts.rake @@ -392,10 +392,12 @@ desc 'Finds missing post upload records from cooked HTML content' task 'posts:missing_uploads' => :environment do name = "missing_uploads" PostCustomField.where(name: name).destroy_all - posts = Post.where("posts.cooked LIKE '% :environment do missing << src unless Upload.get_from_url(src) || OptimizedImage.get_from_url(src) end - missing.each { |src| PostCustomField.create!(post_id: post.id, name: name, value: src) } + if missing.present? + missing.each { |src| PostCustomField.create!(post_id: post.id, name: name, value: src) } + count += missing.count + end + putc "." end - puts "", "#{missing.count} post uploads are missing.", "" + puts "", "#{count} post uploads are missing.", "" end