Permalink
Browse files

speedup unique impressions by using "Impression#exists?" instead of "…

…#Impression#size == 0"
  • Loading branch information...
1 parent a96aebf commit e5566fad8a28699d99fbed181b0b55fe8e1136b0 Kai Schlichting committed Jan 19, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 app/controllers/impressionist_controller.rb
@@ -48,11 +48,11 @@ def bypass
end
def unique_instance?(impressionable, unique_opts)
- return unique_opts.blank? || impressionable.impressions.where(unique_query(unique_opts)).size == 0
+ return unique_opts.blank? || !impressionable.impressions.where(unique_query(unique_opts)).exists?
end
def unique?(unique_opts)
- return unique_opts.blank? || Impression.where(unique_query(unique_opts)).size == 0
+ return unique_opts.blank? || !Impression.where(unique_query(unique_opts)).exists?
end
# creates the query to check for uniqueness

0 comments on commit e5566fa

Please sign in to comment.