Skip to content

Commit

Permalink
speedup unique impressions by using "Impression#exists?" instead of "…
Browse files Browse the repository at this point in the history
…#Impression#size == 0"
  • Loading branch information
Kai Schlichting committed Jan 19, 2012
1 parent a96aebf commit e5566fa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/impressionist_controller.rb
Expand Up @@ -48,11 +48,11 @@ def bypass
end end


def unique_instance?(impressionable, unique_opts) 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 end


def unique?(unique_opts) 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 end


# creates the query to check for uniqueness # creates the query to check for uniqueness
Expand Down

0 comments on commit e5566fa

Please sign in to comment.