REFACTOR: remove duplicate reject loop and implicit return

e8fafbc123
This commit is contained in:
Vinoth Kannan 2019-05-16 10:04:04 +05:30
parent 40328f055e
commit 636b75fa16
1 changed files with 8 additions and 5 deletions

View File

@ -959,13 +959,16 @@ class Post < ActiveRecord::Base
end
count = 0
missing_post_uploads = missing_post_uploads.reject { |_, uploads| uploads.empty? }
missing_post_uploads.reject do |post_id, uploads|
PostCustomField.create!(post_id: post_id, name: Post::MISSING_UPLOADS, value: uploads.to_json)
count += uploads.count
missing_post_uploads = missing_post_uploads.reject do |post_id, uploads|
if uploads.present?
PostCustomField.create!(post_id: post_id, name: Post::MISSING_UPLOADS, value: uploads.to_json)
count += uploads.count
end
uploads.empty?
end
return { uploads: missing_uploads, post_uploads: missing_post_uploads, count: count }
{ uploads: missing_uploads, post_uploads: missing_post_uploads, count: count }
end
private