From 63590e2e7e56be3760083a5a055f6211c4f0704d Mon Sep 17 00:00:00 2001
From: zhitomirskiyi <ilya@joindiaspora.com>
Date: Tue, 18 Jan 2011 16:57:34 -0800
Subject: [PATCH] restore hashes for person for person#index.  since request
 relations are one way, the building the hash is perhaps simpler than
 alternitives"

---
 app/controllers/people_controller.rb | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb
index 6d2c1c7d81..ffa479f0bd 100644
--- a/app/controllers/people_controller.rb
+++ b/app/controllers/people_controller.rb
@@ -16,6 +16,7 @@ class PeopleController < ApplicationController
       redirect_to @people.first
     else
       @hashes = hashes_for_people(@people, @aspects)
+      @people 
       #only do it if it is an email address
       if params[:q].try(:match, Devise.email_regexp)
         webfinger(params[:q])
@@ -23,6 +24,25 @@ class PeopleController < ApplicationController
     end
   end
 
+  def hashes_for_people people, aspects
+    ids = people.map{|p| p.id}
+    requests = {}
+    Request.where(:sender_id => ids, :recipient_id => current_user.person.id).each do |r|
+      requests[r.id] = r
+    end
+    contacts = {}
+    Contact.where(:user_id => current_user.id, :person_id => ids).each do |contact|
+      contacts[contact.person_id] = contact
+    end
+
+    people.map{|p|
+      {:person => p,
+        :contact => contacts[p.id],
+        :request => requests[p.id],
+        :aspects => aspects}
+    }
+  end
+
   def show
     @person = Person.where(:id => params[:id]).first
     @post_type = :all
@@ -115,5 +135,4 @@ class PeopleController < ApplicationController
   def webfinger(account, opts = {})
     Resque.enqueue(Jobs::SocketWebfinger, current_user.id, account, opts)
   end
-
 end
-- 
GitLab