make this scary join a scope [ci skip]
This commit is contained in:
parent
c43bb90794
commit
cc5334ce9a
2 changed files with 3 additions and 2 deletions
|
|
@ -72,6 +72,8 @@ class Person < ActiveRecord::Base
|
||||||
select("DISTINCT people.*")
|
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 :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|
|
scope :who_have_reshared_a_users_posts, lambda{|user|
|
||||||
|
|
|
||||||
|
|
@ -292,8 +292,7 @@ module Diaspora
|
||||||
allowed_aspects = self.aspects & requested_aspects
|
allowed_aspects = self.aspects & requested_aspects
|
||||||
aspect_ids = allowed_aspects.map(&:id)
|
aspect_ids = allowed_aspects.map(&:id)
|
||||||
|
|
||||||
people = Person.joins(:contacts => {:aspect_memberships => :aspect}).
|
people = Person.in_aspects(aspect_ids)
|
||||||
where(Aspect.arel_table[:id].in(aspect_ids))
|
|
||||||
|
|
||||||
if opts[:type] == 'remote'
|
if opts[:type] == 'remote'
|
||||||
people = people.where(:owner_id => nil)
|
people = people.where(:owner_id => nil)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue