Permalink
Browse files

PERF: omit needless query

  • Loading branch information...
SamSaffron committed Sep 28, 2015
1 parent aefedfa commit edfd8702493393067dbdd84856ac504a6fd15e1b
Showing with 1 addition and 1 deletion.
  1. +1 −1 app/models/post_action.rb
@@ -66,7 +66,7 @@ def self.flagged_posts_count
end

def self.counts_for(collection, user)
return {} if collection.blank?
return {} if collection.blank? || !user

collection_ids = collection.map(&:id)
user_id = user.try(:id) || 0

This comment has been minimized.

@RStankov

RStankov Oct 10, 2015

By checking if user exists on the top this can be just: user_id = user.id

0 comments on commit edfd870

Please sign in to comment.