speedup unique impressions by using "Impression#exists?" instead of "#Impression#size == 0"
This commit is contained in:
parent
a96aebfb64
commit
e5566fad8a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue