changeset 1022:f2ec92061fca browsing

Merge from live branch
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Tue, 13 Nov 2012 10:35:40 +0000
parents 967fb7e62b1d (current diff) e3f78fa30a36 (diff)
children 873d052b361b
files
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/activities_controller.rb	Tue Nov 13 10:35:23 2012 +0000
+++ b/app/controllers/activities_controller.rb	Tue Nov 13 10:35:40 2012 +0000
@@ -44,6 +44,8 @@
     if !@institution_name.blank?
       events = events.select do |e|
         e.respond_to?(:event_author) and e.event_author and
+	  e.event_author.respond_to?(:ssamr_user_detail) and
+          !e.event_author.ssamr_user_detail.nil? and
           e.event_author.ssamr_user_detail.institution_name == @institution_name
       end
       if events.empty?
--- a/app/helpers/activities_helper.rb	Tue Nov 13 10:35:23 2012 +0000
+++ b/app/helpers/activities_helper.rb	Tue Nov 13 10:35:40 2012 +0000
@@ -13,8 +13,14 @@
   end
 
   def busy_institutions(events, count)
-    authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact
-    institutions = authors.map { |a| a.ssamr_user_detail.institution_name }
+    authors = events.map do |e|
+      e.event_author unless !e.respond_to?(:event_author) 
+    end.compact
+    institutions = authors.map do |a|
+      if a.respond_to?(:ssamr_user_detail) and !a.ssamr_user_detail.nil?
+        a.ssamr_user_detail.institution_name
+      end
+    end
     insthash = institutions.compact.sort.group_by { |i| i }
     insthash = insthash.merge(insthash) { |k,v| v.length }
     threshold = insthash.values.sort.last(count).first