DEV: add unique missing uploads index in post custom fields

https://review.discourse.org/t/feature-send-missing-post-uploads-stat-to-prometheus/2609/6?u=vinothkannans
This commit is contained in:
Vinoth Kannan
2019-04-10 18:09:35 +05:30
parent c523a12187
commit 8d5c900142
3 changed files with 14 additions and 6 deletions

View File

@ -390,8 +390,7 @@ end
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
PostCustomField.where(name: Post::MISSING_UPLOADS).destroy_all
posts = Post.have_uploads.select(:id, :cooked)
count = 0
@ -409,7 +408,7 @@ task 'posts:missing_uploads' => :environment do
end
if missing.present?
missing.each { |src| PostCustomField.create!(post_id: post.id, name: name, value: src) }
PostCustomField.create!(post_id: post.id, name: Post::MISSING_UPLOADS, value: missing.to_json)
count += missing.count
end