Skip to content

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

REFACTOR: remove duplicate reject loop and implicit return

Vinoth Kannan636b75fa162f
diff --git a/app/models/post.rb b/app/models/post.rb
index df85b4c7642..d8be7ea48f7 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -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