Permalink
Browse files

Fixed group SQL optimization to not duplicate query when just users a…

…re in audience
  • Loading branch information...
1 parent 94a3959 commit 0677618cb4d137637a23c056b675453a6d87c687 Ethan Waldo committed Sep 13, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 app/models/audience.rb
@@ -109,7 +109,7 @@ def prepare_recipients(options = {})
sql += " AND `audiences_jurisdictions`.audience_id = #{self.id} AND `role_memberships`.jurisdiction_id = `audiences_jurisdictions`.jurisdiction_id" if has_jurisdictions
sql += "#{publicsql})"
sql += " UNION DISTINCT " if has_users
- else
+ elsif has_jurisdictions
sql += "(SELECT DISTINCT `users`.id, `users`.last_name, `users`.display_name, `users`.email"
sql += ", (#{subselect}) AS memberships" if options[:role_memberships]
if options[:devices]

0 comments on commit 0677618

Please sign in to comment.