# HG changeset patch # User Chris Cannam # Date 1352732111 0 # Node ID b98f60a6d231b660b56273ce7b631fb8cd6d7fa0 # Parent bbca6f4eebc7612d27e43fd547fcf6e17fbc9c75 Avoid crashing out with weird event types that don't give us a proper author record diff -r bbca6f4eebc7 -r b98f60a6d231 app/helpers/activities_helper.rb --- a/app/helpers/activities_helper.rb Mon Nov 12 14:40:09 2012 +0000 +++ b/app/helpers/activities_helper.rb Mon Nov 12 14:55:11 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