REFACTOR: remove duplicate reject loop and implicit return

REFACTOR: remove duplicate reject loop and implicit return

e8fafbc123170dd1f7d2a8adea4e7810585d3e76

diff --git a/app/models/post.rb b/app/models/post.rb
index df85b4c..d8be7ea 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

GitHub sha: 636b75fa

1 Like