speedup unique impressions by using "Impression#exists?" instead of "#Impression#size == 0"

This commit is contained in:
Kai Schlichting 2012-01-19 21:27:36 +01:00
parent a96aebfb64
commit e5566fad8a
1 changed files with 2 additions and 2 deletions

View File

@ -48,11 +48,11 @@ module ImpressionistController
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