Commit cc5334ce authored by Maxwell Salzberg's avatar Maxwell Salzberg

make this scary join a scope [ci skip]

parent c43bb907
......@@ -72,6 +72,8 @@ class Person < ActiveRecord::Base
select("DISTINCT people.*")
}
scope :in_aspects, lambda{|aspect_ids| joins(:contacts => {:aspect_memberships => :aspect}).where(Aspect.arel_table[:id].in(aspect_ids))}
scope :profile_tagged_with, lambda{|tag_name| joins(:profile => :tags).where(:profile => {:tags => {:name => tag_name}}).where('profiles.searchable IS TRUE') }
scope :who_have_reshared_a_users_posts, lambda{|user|
......
......@@ -292,8 +292,7 @@ module Diaspora
allowed_aspects = self.aspects & requested_aspects
aspect_ids = allowed_aspects.map(&:id)
people = Person.joins(:contacts => {:aspect_memberships => :aspect}).
where(Aspect.arel_table[:id].in(aspect_ids))
people = Person.in_aspects(aspect_ids)
if opts[:type] == 'remote'
people = people.where(:owner_id => nil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment