Do application side join to retrieve contacts for fb finder, rather than n query
This commit is contained in:
parent
ae8686ef25
commit
605e70f095
1 changed files with 6 additions and 1 deletions
|
|
@ -38,11 +38,16 @@ class Services::Facebook < Service
|
||||||
end
|
end
|
||||||
|
|
||||||
service_objects = Services::Facebook.where(:uid => data_h.keys).includes(:user => {:person => :profile})
|
service_objects = Services::Facebook.where(:uid => data_h.keys).includes(:user => {:person => :profile})
|
||||||
|
person_ids_and_uids = {}
|
||||||
|
|
||||||
service_objects.each do |s|
|
service_objects.each do |s|
|
||||||
data_h[s.uid][:person] = s.user.person if s.user.person.profile.searchable
|
data_h[s.uid][:person] = s.user.person if s.user.person.profile.searchable
|
||||||
data_h[s.uid][:contact] = self.user.contacts.where(:person_id => s.user.person.id).first
|
person_ids_and_uids[s.user.person.id] = s.uid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
contact_objects = self.user.contacts.where(:person_id => person_ids_and_uids.keys)
|
||||||
|
contact_objects.each{|c| data_h[person_ids_and_uids[c.person_id]][:contact] = c}
|
||||||
|
|
||||||
data_h
|
data_h
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue