# HG changeset patch # User Chris Cannam # Date 1352802940 0 # Node ID f2ec92061fca6731bac35576a7426741e196d861 # Parent 967fb7e62b1d7a442ba7a5e398a6b07668792796# Parent e3f78fa30a3603000c432aa7938de8c88db355bc Merge from live branch diff -r 967fb7e62b1d -r f2ec92061fca app/controllers/activities_controller.rb --- 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? diff -r 967fb7e62b1d -r f2ec92061fca app/helpers/activities_helper.rb --- 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